cfengine-3.2.4/0000755000175000017500000000000011715233356010305 500000000000000cfengine-3.2.4/install-sh0000755000175000017500000003325611715232774012245 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-01-19.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 # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for `test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-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 X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: cfengine-3.2.4/LICENSE0000644000175000017500000012627411707771421011247 00000000000000This file contains a copy of: 1) The GNU General Public License version 3 1) The Commericial Open Source License (COSL) ---------------------------------------------------------------------------- CFEngine is provided under the terms of the GNU General Public License (below), with explicit permission to link with the OpenSSL library, BerkeleyDB library and and PCRE library. On some systems, code under the Frontier Artistic License (/pub/snprintf) might become compiled. This is compatible with the GPL. Users of the software may, at their option, choose the COSL license below as part of the enterprise CFEngine product. ---------------------------------------------------------------------------- GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. 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. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 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 state 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 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 . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program 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, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU 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. But first, please read . ------------------------------------------------------------------------------ COMMERCIAL OPEN SOURCE LICENSE This CFEngine commercial open source license ("COSL") is entered into between Cfengine AS, a Norwegian company, as licensor and a) the Customer entity stipulated on a complete agreement front page (“Front page”), b) any entity or natural person downloading, installing or taking the Software or any part of it into use, or c) any entity or person who otherwise has agreed to be bound by these terms (collectively the "Licensee"). 1 LICENSE 1.1 General The Software is licensed on a consecutive basis (rental) or perpetually, as stipulated on the Front page. See 1.2 and 1.3 below respectively. The following shall apply to either type of license grants. Subject to the terms of this COSL and other agreement between the parties, Cfengine hereby grants to Licensee a non-exclusive, non-transferable, non-sublicensable and limited license to install, use, study and modify the number of copies of the Software on the number of Instances stipulated on the Front page for use within its organization. The number of Instances the Software may be installed on may be changed by the Customer from time to time, provided ample notice is given to Cfengine. See Front page for reporting. The Licensee may modify, adapt and create derivative works based upon the Software, for use within its organisation and for sharing between other consecutive licensees under the COSL. Therefore, the Licensee shall have access to the source code of the Software. However, the Licensee shall not reproduce, distribute, resell, rent, lease or disclose the Software in any manner or form to any other third party not holding a COSL to the Software. Licensee may not transfer any of its rights under this COSL without the prior and express written consent of Cfengine. Any CFEngine software component used by both the CFEngine enterprise version and CFEngine community edition is licensed under the terms of this COSL if the Licensee does not state in writing to Cfengine that the Licensee instead wish to license the component in question under the GNU General Public License (GPL) v.3.0 or other applicable license. Third party software is licensed under the license of such third party. 1.2 Consecutive license grant (subscription) If the license grant is agreed to be consecutive (see stipulation on Front page), it shall be effective for the period the consecutive license fee (subscription fee) is paid and this license is otherwise complied to. The payment of the consecutive license fee entitles the Customer to Updates and New versions of the Software (as stipulated in appendix 1). 1.3 Perpetual license grant If the license grant is agreed to be perpetual (see stipulation on Front page), the grant is for ever, provided the license terms are complied to. The perpetual license grant is limited to current the version of the Software at the Effective date. Updates or New versions of the Software are not included, unless stated on the Front page (subject to additional fee). 2 DEFINITIONS The following definitions shall apply to the COSL: “Instances” means each physical or virtual computer (server or client), onto which an installation of the Software takes place. “New version” (of the Software) means a new edition of the Software containing functionality or properties not present in the previous edition of the Software. "Software" means: a) the CFEngine enterprise edition Nova, Constellation and Galaxy data centre administration software downloaded by the Licensee or otherwise given access to including bundled documentation and other material, as described at http://www.cfengine.com/; and b) new versions and updates to such software provided by Cfengine, and “Update” (of Software) means smaller adjustments of the Software with the existing functionality, normally by way of installation of new copy of the Software. 3 FEES The Licensee shall pay a license fee per Instance the Software is installed on for the license granted herein; either: a) per time unit (as agreed) e.g. year, for consecutive license grants, or b) once, for perpetual license grants, for the number of Instances stated on the Front page, or any later adjustments. See the Front page for further details. 4 INTELLECTUAL PROPERTY RIGHTS Cfengine and its suppliers do not by this COSL transfer any copyrights or other intellectual property rights relating to the Software to the Licensee. Such rights are protected by intellectual property legislation in the United States, Europe and other jurisdictions and by international treaty provisions. Cfengine and its suppliers retain all rights in the Software that are not expressly granted to the Licensee through this COSL. Licensee is not allowed to remove, alter or destroy any proprietary, trademark or copyright markings or notices placed upon or contained within the Software. 5 TERMINATION Cfengine may terminate the COSL if the Licensee fails to comply with the terms of this COSL, hereunder fails to pay the stipulated fees. In the event of such termination, the Licensee shall immediately stop using the Software, return any received media and documentation, and destroy or permanently delete any installed versions of the Software, and confirm such destruction or deletion in writing within 7 days. 6 IDEMNINFICATION If the Software (except for third party software) during the term of the license grant is held by a court of competent jurisdiction to infringe any third party intellectual property rights and the Licensee incurs loss or expense as a result of such holding, then Licenee's sole remedy shall be, and Cfengine will, at its option: (i) obtain the right for Licensse to continue to use the Software consistent with the COSL; (ii) modify the Software so that it becomes non-infringing; (iii) replace the infringing component with a non-infringing component, or (iv) refund monies paid by Licensee under the Agreement during the prior six (6) months to the court holding (for consecutive license grants) or a forth of any perpetual license fee paid, and all Licensees rights and licenses under this Agreement shall automatically terminate. The Licensee is aware that the Software is also comprised of third party software, mostly open source software. Such third party software are subject to its individual license terms, and any claims shall be directed at the ultimate right holder to that software. Consequently Cfengine is not liable for any defective title in such third party software. See schedule 5 for a list of software contained by the Software with related licenses. 7 NO WARRANTY To the maximum extent permitted by law, Cfengine disclaims any warranty for the Software (except as stated in clause 6). The Software, any services and any related documentation is provided on an "as is" basis without warranty of any kind, whether express or implied, including, but not limited to, implied warranties of merchantability, fitness for a particular purpose or non-infringement (except as stated in clause 6). Hereunder the parties acknowledges that Cfengine does not warrant for the performance of any data centre on which the Software runs, or the absence of any errors in the Software, and that any such errors does not constitute a contractual defect. 8 LIABILITY The liability of the parties in contract, tort (including negligence) or otherwise shall for all incidents during the entire term of the COSL be limited to a fifth of the fees paid for a perpetual license or the annual consecutive license fees paid for the Software causing the damage or loss, up to a maximum of NOK 100 000. Cfengine or its suppliers shall not be liable for any special, incidental, indirect or consequential damages whatsoever (including, without limitation, damages for loss of business profits, lost savings, business interruption, loss of business information, personal injury, loss of privacy, loss of goodwill or any other financial loss) arising out of the use of or inability to use the Software, even if advised of the possibility of such damages. 9 THIRD-PARTY TERMS For third-party software that is made available to the Licensee by Cfengine, the current terms of the relevant third party software supplier shall apply. cfengine-3.2.4/src/0000755000175000017500000000000011715233355011073 500000000000000cfengine-3.2.4/src/nfs.c0000644000175000017500000004267511715232734011763 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: nfs.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #ifndef MINGW static void AugmentMountInfo(struct Rlist **list,char *host,char *source,char *mounton,char *options); static int MatchFSInFstab(char *match); static void DeleteThisItem(struct Item **liststart,struct Item *entry); #endif /*******************************************************************/ #ifndef MINGW // use samba on windows ? int LoadMountInfo(struct Rlist **list) /* This is, in fact, the most portable way to read the mount info! */ /* Depressing, isn't it? */ { FILE *pp; char buf1[CF_BUFSIZE],buf2[CF_BUFSIZE],buf3[CF_BUFSIZE]; char host[CF_MAXVARSIZE],source[CF_BUFSIZE],mounton[CF_BUFSIZE],vbuff[CF_BUFSIZE]; int i, nfs = false; for (i=0; VMOUNTCOMM[VSYSTEMHARDCLASS][i] != ' '; i++) { buf1[i] = VMOUNTCOMM[VSYSTEMHARDCLASS][i]; } buf1[i] = '\0'; SetTimeOut(RPCTIMEOUT); if ((pp = cf_popen(buf1,"r")) == NULL) { CfOut(cf_error,"cf_popen","Can't open %s\n",buf1); return false; } do { vbuff[0] = buf1[0] = buf2[0] = buf3[0] = source[0] = '\0'; if (ferror(pp)) /* abortable */ { CfOut(cf_error,"ferror","Error getting mount info\n"); break; } CfReadLine(vbuff,CF_BUFSIZE,pp); if (ferror(pp)) /* abortable */ { CfOut(cf_error,"ferror","Error getting mount info\n"); break; } if (strstr(vbuff,"nfs")) { nfs = true; } sscanf(vbuff,"%s%s%s",buf1,buf2,buf3); if (vbuff[0] == '\0' || vbuff[0] == '\n') { break; } if (strstr(vbuff,"not responding")) { CfOut(cf_error,"","%s\n",vbuff); } if (strstr(vbuff,"be root")) { CfOut(cf_error,"","Mount access is denied. You must be root.\n"); CfOut(cf_error,"","Use the -n option to run safely."); } if (strstr(vbuff,"retrying") || strstr(vbuff,"denied") || strstr(vbuff,"backgrounding")) { continue; } if (strstr(vbuff,"exceeded") || strstr(vbuff,"busy")) { continue; } if (strstr(vbuff,"RPC")) { CfOut(cf_inform,"","There was an RPC timeout. Aborting mount operations.\n"); CfOut(cf_inform,"","Session failed while trying to talk to remote host\n"); CfOut(cf_inform,"","%s\n",vbuff); cf_pclose(pp); return false; } switch (VSYSTEMHARDCLASS) { case darwin: case sun4: case sun3: case ultrx: case irix: case irix4: case irix64: case linuxx: case GnU: case unix_sv: case freebsd: case netbsd: case openbsd: case bsd_i: case nextstep: case bsd4_3: case newsos: case aos: case osf: case qnx: case crayos: case dragonfly: if (IsAbsoluteFileName(buf1)) { strcpy(host,"localhost"); strcpy(mounton,buf3); } else { sscanf(buf1,"%[^:]:%s",host,source); strcpy(mounton,buf3); } break; case solaris: case solarisx86: case hp: if (IsAbsoluteFileName(buf3)) { strcpy(host,"localhost"); strcpy(mounton,buf1); } else { sscanf(buf1,"%[^:]:%s",host,source); strcpy(mounton,buf1); } break; case aix: /* skip header */ if (IsAbsoluteFileName(buf1)) { strcpy(host,"localhost"); strcpy(mounton,buf2); } else { strcpy(host,buf1); strcpy(source,buf1); strcpy(mounton,buf3); } break; case cfnt: strcpy(mounton,buf2); strcpy(host,buf1); break; case unused2: case unused3: break; case cfsco: CfOut(cf_error,"","Don't understand SCO mount format, no data"); default: printf("cfengine software error: case %d = %s\n",VSYSTEMHARDCLASS,CLASSTEXT[VSYSTEMHARDCLASS]); FatalError("System error in GetMountInfo - no such class!"); } Debug("GOT: host=%s, source=%s, mounton=%s\n",host,source,mounton); if (nfs) { AugmentMountInfo(list,host,source,mounton,"nfs"); } else { AugmentMountInfo(list,host,source,mounton,NULL); } } while (!feof(pp)); alarm(0); signal(SIGALRM,SIG_DFL); cf_pclose(pp); return true; } /*******************************************************************/ static void AugmentMountInfo(struct Rlist **list,char *host,char *source,char *mounton,char *options) { struct CfMount *entry; if ((entry = malloc(sizeof(struct CfMount))) == NULL) { CfOut(cf_error,"malloc","Memory allocation error - augmenting mount info"); return; } entry->host = entry->source = entry->mounton = entry->options = NULL; if (host) { entry->host = strdup(host); } if (source) { entry->source = strdup(source); } if (mounton) { entry->mounton = strdup(mounton); } if (options) { entry->options = strdup(options); } AppendRlistAlien(list,(void *)entry); } /*******************************************************************/ void DeleteMountInfo(struct Rlist *list) { struct Rlist *rp, *sp; struct CfMount *entry; for (rp = list; rp != NULL; rp = sp) { sp = rp->next; entry = (struct CfMount *)rp->item; if (entry->host) { free (entry->host); } if (entry->source) { free (entry->source); } if (entry->mounton) { free (entry->mounton); } if (entry->options) { free (entry->options); } free((char *)entry); } } /*******************************************************************/ int VerifyInFstab(char *name,struct Attributes a,struct Promise *pp) /* Ensure filesystem IS in fstab, and return no of changes */ { char fstab[CF_BUFSIZE]; char *host,*rmountpt,*mountpt,*fstype,*opts; if (!FSTABLIST) { if (!LoadFileAsItemList(&FSTABLIST,VFSTAB[VSYSTEMHARDCLASS],a,pp)) { CfOut(cf_error,"","Couldn't open %s!\n",VFSTAB[VSYSTEMHARDCLASS]); return false; } else { FSTAB_EDITS = 0; } } if (a.mount.mount_options) { opts = Rlist2String(a.mount.mount_options,","); } else { opts = strdup(VMOUNTOPTS[VSYSTEMHARDCLASS]); } host = a.mount.mount_server; rmountpt = a.mount.mount_source; mountpt = name; fstype = a.mount.mount_type; switch (VSYSTEMHARDCLASS) { case osf: case bsd4_3: case irix: case irix4: case irix64: case sun3: case aos: case nextstep: case newsos: case qnx: case sun4: snprintf(fstab,CF_BUFSIZE,"%s:%s \t %s %s\t%s 0 0",host,rmountpt,mountpt,fstype,opts); break; case crayos: snprintf(fstab,CF_BUFSIZE,"%s:%s \t %s %s\t%s",host,rmountpt,mountpt,ToUpperStr(fstype),opts); break; case ultrx: //snprintf(fstab,CF_BUFSIZE,"%s@%s:%s:%s:0:0:%s:%s",rmountpt,host,mountpt,mode,fstype,opts); break; case hp: snprintf(fstab,CF_BUFSIZE,"%s:%s %s \t %s \t %s 0 0",host,rmountpt,mountpt,fstype,opts); break; case aix: snprintf(fstab,CF_BUFSIZE,"%s:\n\tdev\t= %s\n\ttype\t= %s\n\tvfs\t= %s\n\tnodename\t= %s\n\tmount\t= true\n\toptions\t= %s\n\taccount\t= false\n",mountpt,rmountpt,fstype,fstype,host,opts); break; case GnU: case linuxx: snprintf(fstab,CF_BUFSIZE,"%s:%s \t %s \t %s \t %s",host,rmountpt,mountpt,fstype,opts); break; case netbsd: case openbsd: case bsd_i: case dragonfly: case freebsd: snprintf(fstab,CF_BUFSIZE,"%s:%s \t %s \t %s \t %s 0 0",host,rmountpt,mountpt,fstype,opts); break; case unix_sv: case solarisx86: case solaris: snprintf(fstab,CF_BUFSIZE,"%s:%s - %s %s - yes %s",host,rmountpt,mountpt,fstype,opts); break; case cfnt: snprintf(fstab,CF_BUFSIZE,"/bin/mount %s:%s %s",host,rmountpt,mountpt); break; case cfsco: CfOut(cf_error,"","Don't understand filesystem format on SCO, no data - please fix me"); break; case unused1: case unused2: case unused3: default: free(opts); return false; } CfOut(cf_verbose,"","Verifying %s in %s\n",mountpt,VFSTAB[VSYSTEMHARDCLASS]); if (!MatchFSInFstab(mountpt)) { AppendItem(&FSTABLIST,fstab,NULL); FSTAB_EDITS++; cfPS(cf_inform,CF_CHG,"",pp,a,"Adding file system %s:%s seems to %s.\n",host,rmountpt,VFSTAB[VSYSTEMHARDCLASS]); } free(opts); return 0; } /*******************************************************************/ int VerifyNotInFstab(char *name,struct Attributes a,struct Promise *pp) /* Ensure filesystem is NOT in fstab, and return no of changes */ { char regex[CF_BUFSIZE],aixcomm[CF_BUFSIZE],line[CF_BUFSIZE]; char *host,*rmountpt,*mountpt,*fstype,*opts; FILE *pfp; struct Item *ip; if (!FSTABLIST) { if (!LoadFileAsItemList(&FSTABLIST,VFSTAB[VSYSTEMHARDCLASS],a,pp)) { CfOut(cf_error,"","Couldn't open %s!\n",VFSTAB[VSYSTEMHARDCLASS]); return false; } else { FSTAB_EDITS = 0; } } if (a.mount.mount_options) { opts = Rlist2String(a.mount.mount_options,","); } else { opts = VMOUNTOPTS[VSYSTEMHARDCLASS]; } host = a.mount.mount_server; rmountpt = a.mount.mount_source; mountpt = name; fstype = a.mount.mount_type; if (MatchFSInFstab(mountpt)) { if (a.mount.editfstab) { switch (VSYSTEMHARDCLASS) { case aix: snprintf(aixcomm, CF_BUFSIZE, "/usr/sbin/rmnfsmnt -f %s", mountpt); if ((pfp = cf_popen(aixcomm,"r")) == NULL) { cfPS(cf_error,CF_FAIL,"",pp,a,"Failed to invoke /usr/sbin/rmnfsmnt to edit fstab"); return 0; } while(!feof(pfp)) { CfReadLine(line,CF_BUFSIZE,pfp); if (line[0] == '#') { continue; } if (strstr(line,"busy")) { cfPS(cf_inform,CF_INTERPT,"",pp,a,"The device under %s cannot be removed from %s\n",mountpt,VFSTAB[VSYSTEMHARDCLASS]); return 0; } } cf_pclose(pfp); return 0; /* ignore internal editing for aix , always returns 0 changes */ break; default: snprintf(regex,CF_BUFSIZE,".*[\\s]+%s[\\s]+.*",mountpt); for (ip = FSTABLIST; ip != NULL; ip=ip->next) { if (FullTextMatch(regex,ip->name)) { cfPS(cf_inform,CF_CHG,"",pp,a,"Deleting file system mounted on %s.\n",host,rmountpt,VFSTAB[VSYSTEMHARDCLASS]); // Check host name matches too? DeleteThisItem(&FSTABLIST,ip); FSTAB_EDITS++; } } break; } } } if (a.mount.mount_options) { free(opts); } return 0; } /*******************************************************************/ int VerifyMount(char *name,struct Attributes a,struct Promise *pp) { char comm[CF_BUFSIZE],line[CF_BUFSIZE]; FILE *pfp; char *host,*rmountpt,*mountpt,*fstype; host = a.mount.mount_server; rmountpt = a.mount.mount_source; mountpt = name; fstype = a.mount.mount_type; if (! DONTDO) { snprintf(comm,CF_BUFSIZE,"%s %s:%s %s",GetArg0(VMOUNTCOMM[VSYSTEMHARDCLASS]),host,rmountpt,mountpt); if ((pfp = cf_popen(comm,"r")) == NULL) { CfOut(cf_error,""," !! Failed to open pipe from %s\n",GetArg0(VMOUNTCOMM[VSYSTEMHARDCLASS])); return 0; } CfReadLine(line,CF_BUFSIZE,pfp); if (strstr(line,"busy") || strstr(line,"Busy")) { cfPS(cf_inform,CF_INTERPT,"",pp,a," !! The device under %s cannot be mounted\n",mountpt); cf_pclose(pfp); return 1; } cf_pclose(pfp); } cfPS(cf_inform,CF_CHG,"",pp,a," -> Mounting %s to keep promise\n",mountpt); return 0; } /*******************************************************************/ int VerifyUnmount(char *name,struct Attributes a,struct Promise *pp) { char comm[CF_BUFSIZE],line[CF_BUFSIZE]; FILE *pfp; char *host,*rmountpt,*mountpt,*fstype; host = a.mount.mount_server; rmountpt = a.mount.mount_source; mountpt = name; fstype = a.mount.mount_type; if (! DONTDO) { snprintf(comm,CF_BUFSIZE,"%s %s",VUNMOUNTCOMM[VSYSTEMHARDCLASS],mountpt); if ((pfp = cf_popen(comm,"r")) == NULL) { CfOut(cf_error,""," !! Failed to open pipe from %s\n",VUNMOUNTCOMM[VSYSTEMHARDCLASS]); return 0; } CfReadLine(line,CF_BUFSIZE,pfp); if (strstr(line,"busy") || strstr(line,"Busy")) { cfPS(cf_inform,CF_INTERPT,"",pp,a," !! The device under %s cannot be unmounted\n",mountpt); cf_pclose(pfp); return 1; } cf_pclose(pfp); } cfPS(cf_inform,CF_CHG,"",pp,a," -> Unmounting %s to keep promise\n",mountpt); return 0; } /*******************************************************************/ static int MatchFSInFstab(char *match) { struct Item *ip; for (ip = FSTABLIST; ip != NULL; ip=ip->next) { if (strstr(ip->name,match)) { return true; } } return false; } /*******************************************************************/ void MountAll() { struct stat sb; char line[CF_BUFSIZE]; int fd; FILE *pp; if (DONTDO) { CfOut(cf_verbose,"","Promised to mount filesystem, but not on this trial run\n"); return; } else { CfOut(cf_verbose,""," -> Attempting to mount all filesystems.\n"); } if (VSYSTEMHARDCLASS == cfnt) { /* This is a shell script. Make sure it hasn't been compromised. */ if (cfstat("/etc/fstab",&sb) == -1) { if ((fd = creat("/etc/fstab",0755)) > 0) { write(fd,"#!/bin/sh\n\n",10); close(fd); } else { if (sb.st_mode & (S_IWOTH | S_IWGRP)) { CfOut(cf_error,"","File /etc/fstab was insecure. Cannot mount filesystems.\n"); return; } } } } SetTimeOut(RPCTIMEOUT); if ((pp = cf_popen(VMOUNTCOMM[VSYSTEMHARDCLASS],"r")) == NULL) { CfOut(cf_error,"cf_popen","Failed to open pipe from %s\n",VMOUNTCOMM[VSYSTEMHARDCLASS]); return; } while (!feof(pp)) { if (ferror(pp)) /* abortable */ { CfOut(cf_inform,"ferror","Error mounting filesystems\n"); break; } CfReadLine(line,CF_BUFSIZE,pp); if (ferror(pp)) /* abortable */ { CfOut(cf_inform,"ferror","Error mounting filesystems\n"); break; } if (strstr(line,"already mounted") || strstr(line,"exceeded") || strstr(line,"determined")) { continue; } if (strstr(line,"not supported")) { continue; } if (strstr(line,"denied") || strstr(line,"RPC")) { CfOut(cf_error,"","There was a mount error, trying to mount one of the filesystems on this host.\n"); break; } if (strstr(line,"trying") && !strstr(line,"NFS version 2")&& !strstr(line, "vers 3")) { CfOut(cf_error,"","Attempting abort because mount went into a retry loop.\n"); break; } } alarm(0); signal(SIGALRM,SIG_DFL); cf_pclose(pp); } /*******************************************************************/ /* Addendum */ /*******************************************************************/ static void DeleteThisItem(struct Item **liststart,struct Item *entry) { struct Item *ip, *sp; if (entry != NULL) { if (entry->name != NULL) { free(entry->name); } sp = entry->next; if (entry == *liststart) { *liststart = sp; } else { for (ip = *liststart; ip->next != entry; ip=ip->next) { } ip->next = sp; } free((char *)entry); } } #endif /* NOT MINGW */ cfengine-3.2.4/src/mod_access.c0000644000175000017500000000752011715232734013263 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_access.c */ /* */ /*****************************************************************************/ /* This file can act as a template for adding functionality to cfengine 3. All functionality can be added by extending the main array CF_MOD_SUBTYPES[CF3_MODULES] and its array dimension, in mod_common, in the manner shown here. */ #define CF3_MOD_ACCESS #include "cf3.defs.h" #include "cf3.extern.h" /***********************************************************/ /* Read this module file backwards, as dependencies have */ /* to be defined first - these arrays declare pairs of */ /* constraints */ /* */ /* lval => rval */ /* */ /* in the form (lval,type,range) */ /* */ /* If the type is cf_body then the range is a pointer */ /* to another array of pairs, like in a body "sub-routine" */ /* */ /***********************************************************/ /* This is the primary set of constraints for a server object */ struct BodySyntax CF_REMACCESS_BODIES[] = { {"admit",cf_slist,"","List of host names or IP addresses to grant access to file objects"}, {"deny",cf_slist,"","List of host names or IP addresses to deny access to file objects"}, {"maproot",cf_slist,"","List of host names or IP addresses to grant full read-privilege on the server"}, {"ifencrypted",cf_opts,CF_BOOL,"true/false whether the current file access promise is conditional on the connection from the client being encrypted"}, {"resource_type",cf_opts,"path,literal,context,query","The type of object being granted access (the default grants access to files)"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ struct BodySyntax CF_REMROLE_BODIES[] = { {"authorize",cf_slist,"","List of public-key user names that are allowed to activate the promised class during remote agent activation"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_REMACCESS_SUBTYPES[] = { {"server","access",CF_REMACCESS_BODIES}, {"server","roles",CF_REMROLE_BODIES}, {NULL,NULL,NULL}, }; cfengine-3.2.4/src/exec.c0000644000175000017500000007403311715232734012112 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: exec.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" int main (int argc,char *argv[]); #ifdef NT #include #endif /*******************************************************************/ /* GLOBAL VARIABLES */ /*******************************************************************/ int NO_FORK = false; int ONCE = false; char MAILTO[CF_BUFSIZE]; char MAILFROM[CF_BUFSIZE]; char EXECCOMMAND[CF_BUFSIZE]; char VMAILSERVER[CF_BUFSIZE]; struct Item *SCHEDULE = NULL; pid_t MYTWIN = 0; int MAXLINES = 30; int SPLAYTIME = 0; const int INF_LINES = -2; int NOSPLAY = false; int NOWINSERVICE = false; int THREADS = 0; extern struct BodySyntax CFEX_CONTROLBODY[]; /*******************************************************************/ void StartServer(int argc,char **argv); int ScheduleRun(void); void *LocalExec(void *scheduled_run); int FileChecksum(char *filename,unsigned char digest[EVP_MAX_MD_SIZE+1],char type); int CompareResult(char *filename,char *prev_file); void MailResult(char *file,char *to); int Dialogue(int sd,char *s); void Apoptosis(void); /*******************************************************************/ /* Command line options */ /*******************************************************************/ const char *ID = "The executor daemon is a scheduler and wrapper for\n" "execution of cf-agent. It collects the output of the\n" "agent and can email it to a specified address. It can\n" "splay the start time of executions across the network\n" "and work as a class-based clock for scheduling."; const struct option OPTIONS[15] = { { "help",no_argument,0,'h' }, { "debug",optional_argument,0,'d' }, { "verbose",no_argument,0,'v' }, { "dry-run",no_argument,0,'n'}, { "version",no_argument,0,'V' }, { "file",required_argument,0,'f'}, { "define",required_argument,0,'D' }, { "negate",required_argument,0,'N' }, { "no-lock",no_argument,0,'K'}, { "inform",no_argument,0,'I'}, { "diagnostic",no_argument,0,'x'}, { "no-fork",no_argument,0,'F' }, { "no-winsrv",no_argument,0,'W' }, { "ld-library-path",required_argument,0,'L'}, { NULL,0,0,'\0' } }; const char *HINTS[15] = { "Print the help message", "Set debugging level 0,1,2,3", "Output verbose information about the behaviour of the agent", "All talk and no action mode - make no changes, only inform of promises not kept", "Output the version of the software", "Specify an alternative input file than the default", "Define a list of comma separated classes to be defined at the start of execution", "Define a list of comma separated classes to be undefined at the start of execution", "Ignore locking constraints during execution (ifelapsed/expireafter) if \"too soon\" to run", "Print basic information about changes made to the system, i.e. promises repaired", "Activate internal diagnostics (developers only)", "Run as a foreground processes (do not fork)", "Do not run as a service on windows - use this when running from a command shell (Cfengine Nova only)", "Set the internal value of LD_LIBRARY_PATH for child processes", NULL }; /*****************************************************************************/ int main(int argc,char *argv[]) { CheckOpts(argc,argv); GenericInitialize(argc,argv,"executor"); ThisAgentInit(); KeepPromises(); #ifdef MINGW if(NOWINSERVICE) { StartServer(argc,argv); } else { NovaWin_StartExecService(); } #else /* NOT MINGW */ StartServer(argc,argv); #endif /* NOT MINGW */ return 0; } /*****************************************************************************/ /* Level 1 */ /*****************************************************************************/ void CheckOpts(int argc,char **argv) { extern char *optarg; char arg[CF_BUFSIZE]; int optindex = 0; int c; char ld_library_path[CF_BUFSIZE]; while ((c=getopt_long(argc,argv,"d:vnKIf:D:N:VxL:hFV1gMW",OPTIONS,&optindex)) != EOF) { switch ((char) c) { case 'f': if (optarg && strlen(optarg) < 5) { snprintf(arg,CF_MAXVARSIZE," -f used but argument \"%s\" incorrect",optarg); FatalError(arg); } strncpy(VINPUTFILE,optarg,CF_BUFSIZE-1); VINPUTFILE[CF_BUFSIZE-1] = '\0'; MINUSF = true; break; case 'd': NewClass("opt_debug"); switch ((optarg==NULL) ? '3' : *optarg) { case '1': D1 = true; DEBUG = true; break; case '2': D2 = true; DEBUG = true; break; default: DEBUG = true; break; } break; case 'K': IGNORELOCK = true; break; case 'D': NewClassesFromString(optarg); break; case 'N': NegateClassesFromString(optarg,&VNEGHEAP); break; case 'I': INFORM = true; break; case 'v': VERBOSE = true; NO_FORK = true; break; case 'n': DONTDO = true; IGNORELOCK = true; NewClass("opt_dry_run"); break; case 'q': NOSPLAY = true; break; case 'L': snprintf(ld_library_path,CF_BUFSIZE-1,"LD_LIBRARY_PATH=%s",optarg); if (putenv(strdup(ld_library_path)) != 0) { } break; case 'W': NOWINSERVICE = true; break; case 'F': ONCE = true; NO_FORK = true; break; case 'V': PrintVersionBanner("cf-execd"); exit(0); case 'h': Syntax("cf-execd - cfengine's execution agent",OPTIONS,HINTS,ID); exit(0); case 'M': ManPage("cf-execd - cfengine's execution agent",OPTIONS,HINTS,ID); exit(0); case 'x': SelfDiagnostic(); exit(0); default: Syntax("cf-execd - cfengine's execution agent",OPTIONS,HINTS,ID); exit(1); } } if (argv[optind] != NULL) { CfOut(cf_error,"","Unexpected argument with no preceding option: %s\n",argv[optind]); } } /*****************************************************************************/ void ThisAgentInit() { umask(077); LOGGING = true; MAILTO[0] = '\0'; MAILFROM[0] = '\0'; VMAILSERVER[0] = '\0'; EXECCOMMAND[0] = '\0'; if (SCHEDULE == NULL) { AppendItem(&SCHEDULE,"Min00",NULL); AppendItem(&SCHEDULE,"Min05",NULL); AppendItem(&SCHEDULE,"Min10",NULL); AppendItem(&SCHEDULE,"Min15",NULL); AppendItem(&SCHEDULE,"Min20",NULL); AppendItem(&SCHEDULE,"Min25",NULL); AppendItem(&SCHEDULE,"Min30",NULL); AppendItem(&SCHEDULE,"Min35",NULL); AppendItem(&SCHEDULE,"Min40",NULL); AppendItem(&SCHEDULE,"Min45",NULL); AppendItem(&SCHEDULE,"Min50",NULL); AppendItem(&SCHEDULE,"Min55",NULL); } } /*****************************************************************************/ void KeepPromises() { struct Constraint *cp; char rettype,splay[CF_BUFSIZE]; void *retval; for (cp = ControlBodyConstraints(cf_executor); cp != NULL; cp=cp->next) { if (IsExcluded(cp->classes)) { continue; } if (GetVariable("control_executor",cp->lval,&retval,&rettype) == cf_notype) { CfOut(cf_error,"","Unknown lval %s in exec control body",cp->lval); continue; } if (strcmp(cp->lval,CFEX_CONTROLBODY[cfex_mailfrom].lval) == 0) { strcpy(MAILFROM,retval); Debug("mailfrom = %s\n",MAILFROM); } if (strcmp(cp->lval,CFEX_CONTROLBODY[cfex_mailto].lval) == 0) { strcpy(MAILTO,retval); Debug("mailto = %s\n",MAILTO); } if (strcmp(cp->lval,CFEX_CONTROLBODY[cfex_smtpserver].lval) == 0) { strcpy(VMAILSERVER,retval); Debug("smtpserver = %s\n",VMAILSERVER); } if (strcmp(cp->lval,CFEX_CONTROLBODY[cfex_execcommand].lval) == 0) { strcpy(EXECCOMMAND,retval); Debug("exec_command = %s\n",EXECCOMMAND); } if (strcmp(cp->lval,CFEX_CONTROLBODY[cfex_executorfacility].lval) == 0) { SetFacility(retval); continue; } if (strcmp(cp->lval,CFEX_CONTROLBODY[cfex_mailmaxlines].lval) == 0) { MAXLINES = Str2Int(retval); Debug("maxlines = %d\n",MAXLINES); } if (strcmp(cp->lval,CFEX_CONTROLBODY[cfex_splaytime].lval) == 0) { int hash,time = Str2Int(retval); snprintf(splay,CF_BUFSIZE,"%s+%s+%d",VFQNAME,VIPADDRESS,getuid()); hash = GetHash(splay); SPLAYTIME = (int)(time*60*hash/CF_HASHTABLESIZE); } if (strcmp(cp->lval,CFEX_CONTROLBODY[cfex_schedule].lval) == 0) { struct Rlist *rp; Debug("schedule ...\n"); DeleteItemList(SCHEDULE); SCHEDULE = NULL; for (rp = (struct Rlist *) retval; rp != NULL; rp = rp->next) { if (!IsItemIn(SCHEDULE,rp->item)) { AppendItem(&SCHEDULE,rp->item,NULL); } } } } } /*****************************************************************************/ void StartServer(int argc,char **argv) { int time_to_run = false; time_t now = time(NULL); struct Promise *pp = NewPromise("exec_cfengine","the executor agent"); struct Attributes dummyattr; struct CfLock thislock; Banner("Starting executor"); memset(&dummyattr,0,sizeof(dummyattr)); dummyattr.restart_class = "nonce"; dummyattr.transaction.ifelapsed = CF_EXEC_IFELAPSED; dummyattr.transaction.expireafter = CF_EXEC_EXPIREAFTER; if (!ONCE) { thislock = AcquireLock(pp->promiser,VUQNAME,CFSTARTTIME,dummyattr,pp,false); if (thislock.lock == NULL) { DeletePromise(pp); return; } } Apoptosis(); #ifdef MINGW if (!NO_FORK) { CfOut(cf_verbose, "", "Windows does not support starting processes in the background - starting in foreground"); } #else /* NOT MINGW */ if ((!NO_FORK) && (fork() != 0)) { CfOut(cf_inform,"","cf-execd starting %.24s\n",cf_ctime(&now)); exit(0); } if (!NO_FORK) { ActAsDaemon(0); } #endif /* NOT MINGW */ WritePID("cf-execd.pid"); signal(SIGINT,HandleSignals); signal(SIGTERM,HandleSignals); signal(SIGHUP,SIG_IGN); signal(SIGPIPE,SIG_IGN); signal(SIGUSR1,HandleSignals); signal(SIGUSR2,HandleSignals); umask(077); if (ONCE) { CfOut(cf_verbose,"","Sleeping for splaytime %d seconds\n\n",SPLAYTIME); sleep(SPLAYTIME); LocalExec((void *)0); } else { #ifdef HAVE_PTHREAD_H pthread_t tid; #endif #if defined NT && !(defined HAVE_LIBPTHREAD || defined BUILDTIN_GCC_THREAD) int i; char **nargv; /* * Append --once option to our arguments for spawned monitor process. */ nargv = malloc(sizeof(char *) * (argc+2)); for (i = 0; i < argc; i++) { nargv[i] = argv[i]; } nargv[i++] = strdup("-FK"); nargv[i++] = NULL; #endif while (true) { time_to_run = ScheduleRun(); if (time_to_run) { CfOut(cf_verbose,"","Sleeping for splaytime %d seconds\n\n",SPLAYTIME); sleep(SPLAYTIME); #if defined NT && !(defined HAVE_LIBPTHREAD || defined BUILDTIN_GCC_THREAD) /* * Spawn a separate process - spawn will work if the cfexecd binary * has changed (where cygwin's fork() would fail). */ Debug("Spawning %s\n", nargv[0]); pid = _spawnvp((int)_P_NOWAIT,(char *)(nargv[0]),(char **)nargv); if (pid < 1) { CfOut(cf_error,"_spawnvp","Can't spawn run"); } #endif #if (defined HAVE_LIBPTHREAD || defined BUILDTIN_GCC_THREAD) pthread_attr_init(&PTHREADDEFAULTS); pthread_attr_setdetachstate(&PTHREADDEFAULTS,PTHREAD_CREATE_DETACHED); #ifdef HAVE_PTHREAD_ATTR_SETSTACKSIZE pthread_attr_setstacksize(&PTHREADDEFAULTS,(size_t)2048*1024); #endif if (pthread_create(&tid,&PTHREADDEFAULTS,LocalExec,(void *)1) != 0) { CfOut(cf_inform,"pthread_create","Can't create thread!"); LocalExec((void *)1); } ThreadLock(cft_system); pthread_attr_destroy(&PTHREADDEFAULTS); ThreadUnlock(cft_system); #else LocalExec((void *)1); #endif } } } if (!ONCE) { YieldCurrentLock(thislock); } } /*****************************************************************************/ /* Level */ /*****************************************************************************/ void Apoptosis() { struct Promise pp = {0}; struct Rlist *signals = NULL, *owners = NULL; char mypid[32]; static char promiserBuf[CF_SMALLBUF]; if (ONCE || VSYSTEMHARDCLASS == cfnt) { /* Otherwise we'll just kill off long jobs */ return; } CfOut(cf_verbose,""," !! Programmed pruning of the scheduler cluster"); #ifdef MINGW snprintf(promiserBuf, sizeof(promiserBuf), "cf-execd"); // using '\' causes regexp problems #else snprintf(promiserBuf, sizeof(promiserBuf), "%s/bin/cf-execd", CFWORKDIR); #endif pp.promiser = promiserBuf; pp.promisee = "cfengine"; pp.classes = "any"; pp.petype = CF_SCALAR; pp.lineno = 0; pp.audit = NULL; pp.conlist = NULL; pp.bundletype = "agent"; pp.bundle = "exec_apoptosis"; pp.ref = "Programmed death"; pp.agentsubtype = "processes"; pp.done = false; pp.next = NULL; pp.cache = NULL; pp.inode_cache = NULL; pp.this_server = NULL; pp.donep = &(pp.done); pp.conn = NULL; GetCurrentUserName(mypid,31); PrependRlist(&signals,"term",CF_SCALAR); PrependRlist(&owners,mypid,CF_SCALAR); AppendConstraint(&(pp.conlist),"signals",signals,CF_LIST,"any",false); AppendConstraint(&(pp.conlist),"process_select",strdup("true"),CF_SCALAR,"any",false); AppendConstraint(&(pp.conlist),"process_owner",owners,CF_LIST,"any",false); AppendConstraint(&(pp.conlist),"ifelapsed",strdup("0"),CF_SCALAR,"any",false); AppendConstraint(&(pp.conlist),"process_count",strdup("true"),CF_SCALAR,"any",false); AppendConstraint(&(pp.conlist),"match_range",strdup("0,2"),CF_SCALAR,"any",false); AppendConstraint(&(pp.conlist),"process_result",strdup("process_owner.process_count"),CF_SCALAR,"any",false); CfOut(cf_verbose,""," -> Looking for cf-execd processes owned by %s",mypid); if (LoadProcessTable(&PROCESSTABLE)) { VerifyProcessesPromise(&pp); } DeleteItemList(PROCESSTABLE); if (pp.conlist) { DeleteConstraintList(pp.conlist); } CfOut(cf_verbose,""," !! Pruning complete"); } /*****************************************************************************/ int ScheduleRun() { struct Item *ip; CfOut(cf_verbose,"","Sleeping...\n"); sleep(CFPULSETIME); /* 1 Minute resolution is enough */ // recheck license (in case of license updates or expiry) if (EnterpriseExpiry()) { CfOut(cf_error,"","Cfengine - autonomous configuration engine. This enterprise license is invalid.\n"); exit(1); } ThreadLock(cft_system); DeleteAlphaList(&VHEAP); InitAlphaList(&VHEAP); DeleteAlphaList(&VADDCLASSES); InitAlphaList(&VADDCLASSES); DeleteItemList(IPADDRESSES); IPADDRESSES = NULL; DeleteScope("this"); DeleteScope("mon"); DeleteScope("sys"); NewScope("this"); NewScope("mon"); NewScope("sys"); CfGetInterfaceInfo(cf_executor); Get3Environment(); BuiltinClasses(); OSClasses(); SetReferenceTime(true); ThreadUnlock(cft_system); for (ip = SCHEDULE; ip != NULL; ip = ip->next) { CfOut(cf_verbose,"","Checking schedule %s...\n",ip->name); if (IsDefinedClass(ip->name)) { CfOut(cf_verbose,"","Waking up the agent at %s ~ %s \n",cf_ctime(&CFSTARTTIME),ip->name); return true; } } return false; } /*************************************************************************/ void *LocalExec(void *scheduled_run) { FILE *pp; char line[CF_BUFSIZE],lineEscaped[sizeof(line)*2],filename[CF_BUFSIZE],*sp; char cmd[CF_BUFSIZE],esc_command[CF_BUFSIZE]; int print,count = 0; void *threadName; time_t starttime = time(NULL); FILE *fp; #ifdef HAVE_PTHREAD_SIGMASK sigset_t sigmask; sigemptyset(&sigmask); pthread_sigmask(SIG_BLOCK,&sigmask,NULL); #endif #ifdef HAVE_PTHREAD threadName = ThreadUniqueName(pthread_self()); #else threadName = NULL; #endif CfOut(cf_verbose,"","------------------------------------------------------------------\n\n"); CfOut(cf_verbose,""," LocalExec(%sscheduled) at %s\n", scheduled_run ? "" : "not ", cf_ctime(&starttime)); CfOut(cf_verbose,"","------------------------------------------------------------------\n"); /* Need to make sure we have LD_LIBRARY_PATH here or children will die */ if (strlen(EXECCOMMAND) > 0) { strncpy(cmd,EXECCOMMAND,CF_BUFSIZE-1); if (!strstr(EXECCOMMAND,"-Dfrom_cfexecd")) { strcat(EXECCOMMAND," -Dfrom_cfexecd"); } } else { struct stat sb; int twin_exists = false; // twin is bin-twin\cf-agent.exe on windows, bin/cf-twin on Unix if (VSYSTEMHARDCLASS == mingw || VSYSTEMHARDCLASS == cfnt) { snprintf(cmd,CF_BUFSIZE-1,"%s/bin-twin/cf-agent.exe",CFWORKDIR); MapName(cmd); if (stat(cmd,&sb) == 0) { twin_exists = true; } if (twin_exists && IsExecutable(cmd)) { snprintf(cmd,CF_BUFSIZE-1,"\"%s/bin-twin/cf-agent.exe\" -f failsafe.cf && \"%s/bin/cf-agent.exe%s\" -Dfrom_cfexecd%s", CFWORKDIR, CFWORKDIR, NOSPLAY ? " -q" : "", scheduled_run ? ":scheduled_run" : ""); } else { snprintf(cmd,CF_BUFSIZE-1,"\"%s/bin/cf-agent.exe\" -f failsafe.cf && \"%s/bin/cf-agent.exe%s\" -Dfrom_cfexecd%s", CFWORKDIR, CFWORKDIR, NOSPLAY ? " -q" : "", scheduled_run ? ":scheduled_run" : ""); } } else { snprintf(cmd,CF_BUFSIZE-1,"%s/bin/cf-twin",CFWORKDIR); if (stat(cmd,&sb) == 0) { twin_exists = true; } if (twin_exists && IsExecutable(cmd)) { snprintf(cmd,CF_BUFSIZE-1,"\"%s/bin/cf-twin\" -f failsafe.cf && \"%s/bin/cf-agent%s\" -Dfrom_cfexecd%s", CFWORKDIR, CFWORKDIR, NOSPLAY ? " -q" : "", scheduled_run ? ":scheduled_run" : ""); } else { snprintf(cmd,CF_BUFSIZE-1,"\"%s/bin/cf-agent\" -f failsafe.cf && \"%s/bin/cf-agent%s\" -Dfrom_cfexecd%s", CFWORKDIR, CFWORKDIR, NOSPLAY ? " -q" : "", scheduled_run ? ":scheduled_run" : ""); } } } strncpy(esc_command,MapName(cmd),CF_BUFSIZE-1); snprintf(line,CF_BUFSIZE-1,"_%d_%s",starttime,CanonifyName(cf_ctime(&starttime))); snprintf(filename,CF_BUFSIZE-1,"%s/outputs/cf_%s_%s_%x",CFWORKDIR,CanonifyName(VFQNAME),line,threadName); MapName(filename); /* What if no more processes? Could sacrifice and exec() - but we need a sentinel */ if ((fp = fopen(filename,"w")) == NULL) { CfOut(cf_error,"fopen","!! Couldn't open \"%s\" - aborting exec\n",filename); return NULL; } CfOut(cf_verbose,""," -> Command => %s\n",cmd); if ((pp = cf_popen_sh(esc_command,"r")) == NULL) { CfOut(cf_error,"cf_popen","!! Couldn't open pipe to command \"%s\"\n",cmd); fclose(fp); return NULL; } CfOut(cf_verbose,""," -> Command is executing...%s\n",esc_command); while (!feof(pp) && CfReadLine(line,CF_BUFSIZE,pp)) { if (ferror(pp)) { fflush(pp); break; } print = false; for (sp = line; *sp != '\0'; sp++) { if (!isspace((int)*sp)) { print = true; break; } } if (print) { // we must escape print format chars (%) from output ReplaceStr(line,lineEscaped,sizeof(lineEscaped),"%","%%"); fprintf(fp,"%s\n",lineEscaped); count++; /* If we can't send mail, log to syslog */ if (strlen(MAILTO) == 0) { strncat(lineEscaped,"\n",sizeof(lineEscaped)-1-strlen(lineEscaped)); if ((strchr(lineEscaped,'\n')) == NULL) { lineEscaped[sizeof(lineEscaped)-2] = '\n'; } CfOut(cf_inform,"",lineEscaped); } line[0] = '\0'; lineEscaped[0] = '\0'; } } cf_pclose(pp); Debug("Closing fp\n"); fclose(fp); if (ONCE) { Cf3CloseLog(); } CfOut(cf_verbose,""," -> Command is complete\n",cmd); if (count) { CfOut(cf_verbose,""," -> Mailing result\n",cmd); MailResult(filename,MAILTO); } else { CfOut(cf_verbose,""," -> No output\n",cmd); unlink(filename); } return NULL; } /******************************************************************************/ /* Level 4 */ /******************************************************************************/ int FileChecksum(char *filename,unsigned char digest[EVP_MAX_MD_SIZE+1],char type) { FILE *file; EVP_MD_CTX context; int len; unsigned int md_len; unsigned char buffer[1024]; const EVP_MD *md = NULL; Debug2("FileChecksum(%c,%s)\n",type,filename); if ((file = fopen(filename,"rb")) == NULL) { printf ("%s can't be opened\n", filename); } else { switch (type) { case 's': md = EVP_get_digestbyname("sha"); break; case 'm': md = EVP_get_digestbyname("md5"); break; default: FatalError("Software failure in ChecksumFile"); } if (!md) { return 0; } EVP_DigestInit(&context,md); while ((len = fread(buffer,1,1024,file))) { EVP_DigestUpdate(&context,buffer,len); } EVP_DigestFinal(&context,digest,&md_len); fclose (file); return(md_len); } return 0; } /*******************************************************************/ int CompareResult(char *filename,char *prev_file) { int i; unsigned char digest1[EVP_MAX_MD_SIZE+1]; unsigned char digest2[EVP_MAX_MD_SIZE+1]; int md_len1, md_len2; FILE *fp; int rtn = 0; CfOut(cf_verbose,"","Comparing files %s with %s\n", prev_file, filename); if ((fp=fopen(prev_file,"r")) != NULL) { fclose(fp); md_len1 = FileChecksum(prev_file, digest1, 'm'); md_len2 = FileChecksum(filename, digest2, 'm'); if (md_len1 != md_len2) { rtn = 1; } else { for (i = 0; i < md_len1; i++) { if (digest1[i] != digest2[i]) { rtn = 1; break; } } } } else { /* no previous file */ rtn = 1; } if (!ThreadLock(cft_count)) { CfOut(cf_error, "", "!! Severe lock error when mailing in exec"); return 1; } /* replace old file with new*/ unlink(prev_file); if(!LinkOrCopy(filename,prev_file,true)) { CfOut(cf_inform,"","Could not symlink or copy %s to %s",filename,prev_file); rtn = 1; } ThreadUnlock(cft_count); return(rtn); } /***********************************************************************/ void MailResult(char *file,char *to) { int sd, sent, count = 0, anomaly = false; char prev_file[CF_BUFSIZE],vbuff[CF_BUFSIZE]; struct hostent *hp; struct sockaddr_in raddr; struct servent *server; struct stat statbuf; time_t now = time(NULL); FILE *fp; CfOut(cf_verbose,"","Mail result...\n"); if (cfstat(file,&statbuf) == -1) { return; } snprintf(prev_file,CF_BUFSIZE-1,"%s/outputs/previous",CFWORKDIR); MapName(prev_file); if (statbuf.st_size == 0) { unlink(file); Debug("Nothing to report in %s\n",file); return; } if (CompareResult(file,prev_file) == 0) { CfOut(cf_verbose,"","Previous output is the same as current so do not mail it\n"); return; } if ((strlen(VMAILSERVER) == 0) || (strlen(to) == 0)) { /* Syslog should have done this */ CfOut(cf_verbose, "", "Empty mail server or address - skipping"); return; } if (MAXLINES == 0) { Debug("Not mailing: EmailMaxLines was zero\n"); return; } Debug("Mailing results of (%s) to (%s)\n",file,to); /* Check first for anomalies - for subject header */ if ((fp = fopen(file,"r")) == NULL) { CfOut(cf_inform,"fopen","!! Couldn't open file %s",file); return; } while (!feof(fp)) { vbuff[0] = '\0'; fgets(vbuff,CF_BUFSIZE,fp); if (strstr(vbuff,"entropy")) { anomaly = true; break; } } fclose(fp); if ((fp = fopen(file,"r")) == NULL) { CfOut(cf_inform,"fopen","Couldn't open file %s",file); return; } Debug("Looking up hostname %s\n\n",VMAILSERVER); if ((hp = gethostbyname(VMAILSERVER)) == NULL) { printf("Unknown host: %s\n", VMAILSERVER); printf("Make sure that fully qualified names can be looked up at your site.\n"); fclose(fp); return; } if ((server = getservbyname("smtp","tcp")) == NULL) { CfOut(cf_inform,"getservbyname","Unable to lookup smtp service"); fclose(fp); return; } memset(&raddr,0,sizeof(raddr)); raddr.sin_port = (unsigned int) server->s_port; raddr.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr; raddr.sin_family = AF_INET; Debug("Connecting...\n"); if ((sd = socket(AF_INET,SOCK_STREAM,0)) == -1) { CfOut(cf_inform,"socket","Couldn't open a socket"); fclose(fp); return; } if (connect(sd,(void *) &raddr,sizeof(raddr)) == -1) { CfOut(cf_inform,"connect","Couldn't connect to host %s\n",VMAILSERVER); fclose(fp); cf_closesocket(sd); return; } /* read greeting */ if (!Dialogue(sd,NULL)) { goto mail_err; } sprintf(vbuff,"HELO %s\r\n",VFQNAME); Debug("%s",vbuff); if (!Dialogue(sd,vbuff)) { goto mail_err; } if (strlen(MAILFROM) == 0) { sprintf(vbuff,"MAIL FROM: \r\n",VFQNAME); Debug("%s",vbuff); } else { sprintf(vbuff,"MAIL FROM: <%s>\r\n",MAILFROM); Debug("%s",vbuff); } if (!Dialogue(sd,vbuff)) { goto mail_err; } sprintf(vbuff,"RCPT TO: <%s>\r\n",to); Debug("%s",vbuff); if (!Dialogue(sd,vbuff)) { goto mail_err; } if (!Dialogue(sd,"DATA\r\n")) { goto mail_err; } if (anomaly) { sprintf(vbuff,"Subject: %s **!! [%s/%s]\r\n",MailSubject(),VFQNAME,VIPADDRESS); Debug("%s",vbuff); } else { sprintf(vbuff,"Subject: %s [%s/%s]\r\n",MailSubject(),VFQNAME,VIPADDRESS); Debug("%s",vbuff); } sent = send(sd,vbuff,strlen(vbuff),0); #if defined LINUX || defined NETBSD || defined FREEBSD || defined OPENBSD strftime(vbuff,CF_BUFSIZE,"Date: %a, %d %b %Y %H:%M:%S %z\r\n",localtime(&now)); sent=send(sd,vbuff,strlen(vbuff),0); #endif if (strlen(MAILFROM) == 0) { sprintf(vbuff,"From: cfengine@%s\r\n",VFQNAME); Debug("%s",vbuff); } else { sprintf(vbuff,"From: %s\r\n",MAILFROM); Debug("%s",vbuff); } sent = send(sd,vbuff,strlen(vbuff),0); sprintf(vbuff,"To: %s\r\n\r\n",to); Debug("%s",vbuff); sent = send(sd,vbuff,strlen(vbuff),0); while(!feof(fp)) { vbuff[0] = '\0'; fgets(vbuff,CF_BUFSIZE,fp); Debug("%s",vbuff); if (strlen(vbuff) > 0) { vbuff[strlen(vbuff)-1] = '\r'; strcat(vbuff, "\n"); count++; sent = send(sd,vbuff,strlen(vbuff),0); } if ((MAXLINES != INF_LINES) && (count > MAXLINES)) { sprintf(vbuff,"\r\n[Mail truncated by cfengine. File is at %s on %s]\r\n",file,VFQNAME); sent = send(sd,vbuff,strlen(vbuff),0); break; } } if (!Dialogue(sd,".\r\n")) { Debug("mail_err\n"); goto mail_err; } Dialogue(sd,"QUIT\r\n"); Debug("Done sending mail\n"); fclose(fp); cf_closesocket(sd); return; mail_err: fclose(fp); cf_closesocket(sd); CfOut(cf_log,"","Cannot mail to %s.", to); } /******************************************************************/ /* Level 5 */ /******************************************************************/ int Dialogue(int sd,char *s) { int sent; char ch,f = '\0'; int charpos,rfclinetype = ' '; if ((s != NULL) && (*s != '\0')) { sent = send(sd,s,strlen(s),0); Debug("SENT(%d)->%s",sent,s); } else { Debug("Nothing to send .. waiting for opening\n"); } charpos = 0; while (recv(sd,&ch,1,0)) { charpos++; if (f == '\0') { f = ch; } if (charpos == 4) /* Multiline RFC in form 222-Message with hyphen at pos 4 */ { rfclinetype = ch; } Debug("%c",ch); if (ch == '\n' || ch == '\0') { charpos = 0; if (rfclinetype == ' ') { break; } } } return ((f == '2') || (f == '3')); /* return code 200 or 300 from smtp*/ } /* EOF */ cfengine-3.2.4/src/signals.c0000644000175000017500000000517311715232734012625 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: signals.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" void HandleSignals(int signum) { if (signum != SIGCHLD) { CfOut(cf_error,"","Received signal %d (%s) while doing [%s]",signum,SIGNALS[signum],CFLOCK); CfOut(cf_error,"","Logical start time %s ",cf_ctime(&CFSTARTTIME)); CfOut(cf_error,"","This sub-task started really at %s\n",cf_ctime(&CFINITSTARTTIME)); fflush(stdout); if (signum == SIGTERM || signum == SIGINT || signum == SIGHUP || signum == SIGSEGV || signum == SIGKILL|| signum == SIGPIPE) { SelfTerminatePrelude(); exit(0); } else if (signum == SIGUSR1) { DEBUG= true; D2= true; } else if (signum == SIGUSR2) { DEBUG= false; D2= false; } else /* zombie cleanup - how hard does it have to be? */ { } /* Reset the signal handler */ signal(signum,HandleSignals); } } /*****************************************************************************/ void SelfTerminatePrelude() { struct CfLock best_guess; CfOut(cf_verbose,"","Trying to remove lock - try %s",CFLOCK); best_guess.lock = strdup(CFLOCK); best_guess.last = strdup(CFLAST); best_guess.log = strdup(CFLOG); YieldCurrentLock(best_guess); unlink(PIDFILE); EndAudit(); GenericDeInitialize(); } cfengine-3.2.4/src/compiler.h0000644000175000017500000000235411715232734013002 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifndef CFENGINE_COMPILER_H #define CFENGINE_COMPILER_H /* Compiler-specific options/defines */ #if defined(__GNUC__) && (__GNUC__ * 100 >= 3) # define FUNC_ATTR_NORETURN __attribute__((noreturn)) #else /* not gcc >= 3.0 */ # define FUNC_ATTR_NORETURN #endif #endif cfengine-3.2.4/src/instrumentation.c0000644000175000017500000003374711715232734014440 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: instrumentation.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #include static void NotePerformance(char *eventname,time_t t,double value); static void UpdateLastSawHost(char *rkey,char *ipaddress); static void PurgeMultipleIPReferences(CF_DB *dbp,char *rkey,char *ipaddress); /* Alter this code at your peril. Berkeley DB is very sensitive to errors. */ /***************************************************************/ struct timespec BeginMeasure() { struct timespec start; if (clock_gettime(CLOCK_REALTIME, &start) == -1) { CfOut(cf_verbose,"clock_gettime","Clock gettime failure"); } return start; } /***************************************************************/ void EndMeasurePromise(struct timespec start,struct Promise *pp) { char id[CF_BUFSIZE], *mid = NULL; mid = GetConstraint("measurement_class",pp,CF_SCALAR); if (mid) { snprintf(id,CF_BUFSIZE,"%s:%s:%.100s",(char *)mid,pp->agentsubtype,pp->promiser); Chop(id); EndMeasure(id,start); } } /***************************************************************/ void EndMeasure(char *eventname,struct timespec start) { struct timespec stop; int measured_ok = true; double dt; if (clock_gettime(CLOCK_REALTIME, &stop) == -1) { CfOut(cf_verbose,"clock_gettime","Clock gettime failure"); measured_ok = false; } dt = (double)(stop.tv_sec - start.tv_sec)+(double)(stop.tv_nsec-start.tv_nsec)/(double)CF_BILLION; if (measured_ok) { NotePerformance(eventname,start.tv_sec,dt); } } /***************************************************************/ static void NotePerformance(char *eventname,time_t t,double value) { CF_DB *dbp; char name[CF_BUFSIZE]; struct Event e,newe; double lastseen,delta2; int lsea = CF_WEEK; time_t now = time(NULL); Debug("PerformanceEvent(%s,%.1f s)\n",eventname,value); snprintf(name,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,CF_PERFORMANCE); if (!OpenDB(name,&dbp)) { return; } if (ReadDB(dbp,eventname,&e,sizeof(e))) { lastseen = now - e.t; newe.t = t; newe.Q.q = value; newe.Q.expect = GAverage(value,e.Q.expect,0.3); delta2 = (value - e.Q.expect)*(value - e.Q.expect); newe.Q.var = GAverage(delta2,e.Q.var,0.3); /* Have to kickstart variance computation, assume 1% to start */ if (newe.Q.var <= 0.0009) { newe.Q.var = newe.Q.expect / 100.0; } } else { lastseen = 0.0; newe.t = t; newe.Q.q = value; newe.Q.expect = value; newe.Q.var = 0.001; } if (lastseen > (double)lsea) { Debug("Performance record %s expired\n",eventname); DeleteDB(dbp,eventname); } else { CfOut(cf_verbose,"","Performance(%s): time=%.4lf secs, av=%.4lf +/- %.4lf\n",eventname,value,newe.Q.expect,sqrt(newe.Q.var)); WriteDB(dbp,eventname,&newe,sizeof(newe)); } CloseDB(dbp); } /***************************************************************/ void NoteClassUsage(struct AlphaList baselist) { CF_DB *dbp; CF_DBC *dbcp; void *stored; char *key,name[CF_BUFSIZE]; int i,j,ksize,vsize; struct Event e,entry,newe; double lsea = CF_WEEK * 52; /* expire after a year */ time_t now = time(NULL); struct Item *ip,*list = NULL; double lastseen,delta2; double vtrue = 1.0; /* end with a rough probability */ /* Only do this for the default policy, too much "downgrading" otherwise */ if (MINUSF) { return; } Debug("RecordClassUsage\n"); for (i = 0; i < CF_ALPHABETSIZE; i++) { for (ip = baselist.list[i]; ip != NULL; ip=ip->next) { if (IGNORECLASS(ip->name)) { Debug("Ignoring class %s (not packing)", ip->name); continue; } for (j = 0; j < 4; j++) { if (strcmp(ip->name,SHIFT_TEXT[j]) == 0) { continue; } } for (j = 0; j < 7; j++) { if (strcmp(ip->name,DAY_TEXT[j]) == 0) { continue; } } for (j = 0; j < 12; j++) { if (strcmp(ip->name,MONTH_TEXT[j]) == 0) { continue; } } IdempPrependItem(&list,ip->name,NULL); } } snprintf(name,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,CF_CLASSUSAGE); MapName(name); if (!OpenDB(name,&dbp)) { return; } /* First record the classes that are in use */ for (ip = list; ip != NULL; ip=ip->next) { if (ReadDB(dbp,ip->name,&e,sizeof(e))) { lastseen = now - e.t; newe.t = now; newe.Q.q = vtrue; newe.Q.expect = GAverage(vtrue,e.Q.expect,0.7); delta2 = (vtrue - e.Q.expect)*(vtrue - e.Q.expect); newe.Q.var = GAverage(delta2,e.Q.var,0.7); } else { lastseen = 0.0; newe.t = now; newe.Q.q = 0.5*vtrue; newe.Q.expect = 0.5*vtrue; /* With no data it's 50/50 what we can say */ newe.Q.var = 0.000; } if (lastseen > lsea) { Debug("Class usage record %s expired\n",ip->name); DeleteDB(dbp,ip->name); } else { Debug("Upgrading %s %f\n",ip->name,newe.Q.expect); WriteDB(dbp,ip->name,&newe,sizeof(newe)); } } /* Then update with zero the ones we know about that are not active */ /* Acquire a cursor for the database. */ if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan class db"); CloseDB(dbp); DeleteItemList(list); return; } memset(&entry, 0, sizeof(entry)); OpenDBTransaction(dbp); while(NextDB(dbp,dbcp,&key,&ksize,&stored,&vsize)) { double measure,av,var; time_t then; char eventname[CF_BUFSIZE]; memset(eventname,0,CF_BUFSIZE); strncpy(eventname,(char *)key,ksize); if (stored != NULL) { memcpy(&entry,stored,sizeof(entry)); then = entry.t; measure = entry.Q.q; av = entry.Q.expect; var = entry.Q.var; lastseen = now - then; if (lastseen > lsea) { Debug("Class usage record %s expired\n",eventname); DeleteDB(dbp,eventname); } else if (!IsItemIn(list,eventname)) { newe.t = then; newe.Q.q = 0; newe.Q.expect = GAverage(0.0,av,0.5); delta2 = av*av; newe.Q.var = GAverage(delta2,var,0.5); Debug("Downgrading class %s from %lf to %lf\n",eventname,entry.Q.expect,newe.Q.expect); WriteDB(dbp,eventname,&newe,sizeof(newe)); } } } CommitDBTransaction(dbp); DeleteDBCursor(dbp,dbcp); CloseDB(dbp); DeleteItemList(list); } /***************************************************************/ /* Last saw handling */ /***************************************************************/ void LastSaw(char *username,char *ipaddress,unsigned char digest[EVP_MAX_MD_SIZE+1],enum roles role) { char databuf[CF_BUFSIZE]; time_t now = time(NULL); int known = false; char *mapip; if (strlen(ipaddress) == 0) { CfOut(cf_inform,"","LastSeen registry for empty IP with role %d",role); return; } ThreadLock(cft_output); switch (role) { case cf_accept: snprintf(databuf,CF_BUFSIZE-1,"-%s",HashPrint(CF_DEFAULT_DIGEST,digest)); break; case cf_connect: snprintf(databuf,CF_BUFSIZE-1,"+%s",HashPrint(CF_DEFAULT_DIGEST,digest)); break; } ThreadUnlock(cft_output); mapip = MapAddress(ipaddress); UpdateLastSawHost(databuf,mapip); } /*****************************************************************************/ static void UpdateLastSawHost(char *rkey,char *ipaddress) { CF_DB *dbpent = NULL,*dbp = NULL; struct CfKeyHostSeen q,newq; double lastseen,delta2; void *stored; char name[CF_BUFSIZE],*key; time_t now = time(NULL); int intermittency = false; char timebuf[26]; if (BooleanControl("control_agent",CFA_CONTROLBODY[cfa_intermittency].lval)) { CfOut(cf_inform,""," -> Recording intermittency"); intermittency = true; } snprintf(name,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,CF_LASTDB_FILE); MapName(name); if (!OpenDB(name,&dbp)) { CfOut(cf_inform,""," !! Unable to open last seen db"); return; } if (intermittency) { /* Open special file for peer entropy record - INRIA-like intermittency */ snprintf(name,CF_BUFSIZE-1,"%s/lastseen/%s.%s",CFWORKDIR,CF_LASTDB_FILE,rkey); MapName(name); if (!OpenDB(name,&dbpent)) { intermittency = false; } } if (ReadDB(dbp,rkey,&q,sizeof(q))) { lastseen = (double)now - q.Q.q; if (q.Q.q <= 0) { lastseen = 300; q.Q.expect = 0; q.Q.var = 0; } newq.Q.q = (double)now; newq.Q.expect = GAverage(lastseen,q.Q.expect,0.4); delta2 = (lastseen - q.Q.expect)*(lastseen - q.Q.expect); newq.Q.var = GAverage(delta2,q.Q.var,0.4); strncpy(newq.address,ipaddress,CF_ADDRSIZE-1); } else { lastseen = 0.0; newq.Q.q = (double)now; newq.Q.expect = 0.0; newq.Q.var = 0.0; strncpy(newq.address,ipaddress,CF_ADDRSIZE-1); } if (strcmp(rkey+1,PUBKEY_DIGEST) == 0) { struct Item *ip; int match = false; for (ip = IPADDRESSES; ip != NULL; ip=ip->next) { if (strcmp(ipaddress,ip->name) == 0) { match = true; } } if (!match) { CfOut(cf_verbose,""," ! Not updating last seen, as this appears to be a host with a duplicate key"); CloseDB(dbp); if (intermittency && dbpent) { CloseDB(dbpent); } return; } } CfOut(cf_verbose,""," -> Last saw %s (alias %s) at %s\n",rkey,ipaddress,cf_strtimestamp_local(now,timebuf)); PurgeMultipleIPReferences(dbp,rkey,ipaddress); WriteDB(dbp,rkey,&newq,sizeof(newq)); if (intermittency) { WriteDB(dbpent,GenTimeKey(now),&newq,sizeof(newq)); } if (intermittency && dbpent) { CloseDB(dbpent); } CloseDB(dbp); } /*****************************************************************************/ bool RemoveHostFromLastSeen(const char *hostname, char *hostkey) { char ip[CF_BUFSIZE]; char digest[CF_BUFSIZE]={0}; if(!hostkey) { strcpy(ip, Hostname2IPString(hostname)); IPString2KeyDigest(ip, digest); } else { snprintf(digest,sizeof(digest),"%s",hostkey); } CF_DB *dbp; char name[CF_BUFSIZE], key[CF_BUFSIZE]; snprintf(name,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,CF_LASTDB_FILE); MapName(name); if (!OpenDB(name, &dbp)) { CfOut(cf_error, "", " !! Unable to open last seen DB"); return false; } snprintf(key, CF_BUFSIZE, "-%s", digest); DeleteComplexKeyDB(dbp, key, strlen(key) + 1); snprintf(key, CF_BUFSIZE, "+%s", digest); DeleteComplexKeyDB(dbp, key, strlen(key) + 1); CloseDB(dbp); return true; } /*****************************************************************************/ static void PurgeMultipleIPReferences(CF_DB *dbp,char *rkey,char *ipaddress) { CF_DBC *dbcp; struct CfKeyHostSeen q,newq; double lastseen,delta2,lsea = LASTSEENEXPIREAFTER; void *stored; char name[CF_BUFSIZE],*key; time_t now = time(NULL); int qsize,ksize,update_address,keys_match; // This is an expensive call, but it is the price we pay for consistency // Make sure we only call it if we have to if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan the last seen db"); return; } while(NextDB(dbp,dbcp,&key,&ksize,&stored,&qsize)) { keys_match = false; if (strcmp(key+1,rkey+1) == 0) { keys_match = true; } memcpy(&q,stored,sizeof(q)); lastseen = (double)now - q.Q.q; if (lastseen > lsea) { CfOut(cf_verbose,""," -> Last-seen record for %s expired after %.1lf > %.1lf hours\n",key,lastseen/3600,lsea/3600); DeleteDB(dbp,key); continue; } // Avoid duplicate address/key pairs if (keys_match && strcmp(q.address,ipaddress) != 0) { CfOut(cf_verbose,""," ! Synchronizing %s's address as this host %s seems to have moved from location %s to %s",key,rkey,q.address,ipaddress); strcpy(q.address,ipaddress); update_address = true; } else if (!keys_match && strcmp(q.address,ipaddress) == 0) { CfOut(cf_verbose,""," ! Updating %s's address (%s) as this host %s seems to have gone off line",key,ipaddress,rkey); strcpy(q.address,CF_UNKNOWN_IP); update_address = true; } else { update_address = false; } if (update_address) { WriteDB(dbp,key,&q,sizeof(q)); } } DeleteDBCursor(dbp,dbcp); } /*****************************************************************************/ /* Toolkit */ /*****************************************************************************/ double GAverage(double anew,double aold,double p) /* return convex mixture - p is the trust/confidence in the new value */ { return (p*anew + (1.0-p)*aold); } cfengine-3.2.4/src/verify_services.c0000644000175000017500000000777111715232734014402 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: verify_services.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int ServicesSanityChecks(struct Attributes a,struct Promise *pp); static void SetServiceDefaults(struct Attributes *a); /*****************************************************************************/ void VerifyServicesPromise(struct Promise *pp) { struct Attributes a = {{0}}; a = GetServicesAttributes(pp); SetServiceDefaults(&a); if (ServicesSanityChecks(a,pp)) { VerifyServices(a,pp); } } /*****************************************************************************/ static int ServicesSanityChecks(struct Attributes a,struct Promise *pp) { struct Rlist *dep; switch(a.service.service_policy) { case cfsrv_start: break; case cfsrv_stop: case cfsrv_disable: if(strcmp(a.service.service_autostart_policy, "none") != 0) { CfOut(cf_error,"","!! Autostart policy of service promiser \"%s\" needs to be \"none\" when service policy is not \"start\", but is \"%s\"", pp->promiser, a.service.service_autostart_policy); PromiseRef(cf_error,pp); return false; } break; default: CfOut(cf_error,"","!! Invalid service policy for service \"%s\"", pp->promiser); PromiseRef(cf_error,pp); return false; } for(dep = a.service.service_depend; dep != NULL; dep = dep->next) { if(strcmp(pp->promiser, dep->item) == 0) { CfOut(cf_error,"","!! Service promiser \"%s\" has itself as dependency", pp->promiser); PromiseRef(cf_error,pp); return false; } } if(a.service.service_type == NULL) { CfOut(cf_error,"","!! Service type for service \"%s\" is not known", pp->promiser); PromiseRef(cf_error,pp); return false; } #ifdef MINGW if(strcmp(a.service.service_type, "windows") != 0) { CfOut(cf_error,"","!! Service type for promiser \"%s\" must be \"windows\" on this system, but is \"%s\"", pp->promiser, a.service.service_type); PromiseRef(cf_error,pp); return false; } #endif /* MINGW */ return true; } /*****************************************************************************/ static void SetServiceDefaults(struct Attributes *a) { if(a->service.service_autostart_policy == NULL) { a->service.service_autostart_policy = "none"; } if(a->service.service_depend_chain == NULL) { a->service.service_depend_chain = "ignore"; } // default service type to "windows" on windows platforms #ifdef MINGW if(a->service.service_type == NULL) { a->service.service_type = "windows"; } #endif /* MINGW */ } cfengine-3.2.4/src/communication.c0000644000175000017500000002045511715232734014032 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*******************************************************************/ /* */ /* IP layers */ /* */ /*******************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static char *IPString2UQHostname(char *ipaddress); /*********************************************************************/ struct cfagent_connection *NewAgentConn() { struct cfagent_connection *ap; if ((ap = (struct cfagent_connection *)malloc(sizeof(struct cfagent_connection))) == NULL) { return NULL; } Debug("New server connection...\n"); ap->sd = (int)CF_NOT_CONNECTED; ap->family = AF_INET; ap->trust = false; ap->localip[0] = '\0'; ap->remoteip[0] = '\0'; ap->session_key = NULL; ap->encryption_type = 'c'; ap->error = false; return ap; }; /*********************************************************************/ void DeleteAgentConn(struct cfagent_connection *ap) { if (ap->session_key != NULL) { free(ap->session_key); } free(ap); ap = NULL; } /**********************************************************************/ void DePort(char *address) { char *sp,*chop,*fc = NULL,*fd = NULL,*ld = NULL; int ccount = 0, dcount = 0; /* Start looking for ethernet/ipv6 addresses */ for (sp = address; *sp != '\0'; sp++) { if (*sp == ':') { if (!fc) { fc = sp; } ccount++; } if (*sp == '.') { if (!fd) { fd = sp; } ld = sp; dcount++; } } if (!fd) { /* This does not look like an IP address+port, maybe ethernet */ return; } if (dcount == 4) { chop = ld; } else if (dcount > 1 && fc != NULL) { chop = fc; } else if (ccount > 1 && fd != NULL) { chop = fd; } else { /* Don't recognize address */ return; } if (chop < address+strlen(address)) { *chop = '\0'; } return; } /*******************************************************************/ int IsIPV6Address(char *name) { char *sp; int count,max = 0; Debug("IsIPV6Address(%s)\n",name); if (name == NULL) { return false; } count = 0; for (sp = name; *sp != '\0'; sp++) { if (isalnum((int)*sp)) { count++; } else if ((*sp != ':') && (*sp != '.')) { return false; } if (*sp == 'r') { return false; } if (count > max) { max = count; } else { count = 0; } } if (max <= 2) { Debug("Looks more like a MAC address"); return false; } if (strstr(name,":") == NULL) { return false; } if (StrStr(name,"scope")) { return false; } return true; } /*******************************************************************/ int IsIPV4Address(char *name) { char *sp; int count = 0; Debug("IsIPV4Address(%s)\n",name); if (name == NULL) { return false; } for (sp = name; *sp != '\0'; sp++) { if (!isdigit((int)*sp) && (*sp != '.')) { return false; } if (*sp == '.') { count++; } } if (count != 3) { return false; } return true; } /*****************************************************************************/ const char *Hostname2IPString(const char *hostname) { static char ipbuffer[CF_SMALLBUF]; int err; #if defined(HAVE_GETADDRINFO) struct addrinfo query, *response, *ap; memset(&query,0,sizeof(struct addrinfo)); query.ai_family = AF_UNSPEC; query.ai_socktype = SOCK_STREAM; memset(ipbuffer,0,CF_SMALLBUF-1); if ((err = getaddrinfo(hostname,NULL,&query,&response)) != 0) { CfOut(cf_inform,"","Unable to lookup hostname (%s) or cfengine service: %s",hostname,gai_strerror(err)); return hostname; } for (ap = response; ap != NULL; ap = ap->ai_next) { strncpy(ipbuffer,sockaddr_ntop(ap->ai_addr),64); Debug("Found address (%s) for host %s\n",ipbuffer,hostname); if (strlen(ipbuffer) == 0) { snprintf(ipbuffer,CF_SMALLBUF-1,"Empty IP result for %s",hostname); } freeaddrinfo(response); return ipbuffer; } #else struct hostent *hp; struct sockaddr_in cin; memset(&cin,0,sizeof(cin)); memset(ipbuffer,0,CF_SMALLBUF-1); if ((hp = gethostbyname(hostname)) != NULL) { cin.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr; strncpy(ipbuffer,inet_ntoa(cin.sin_addr),CF_SMALLBUF-1); CfOut(cf_verbose,"","Found address (%s) for host %s\n",ipbuffer,hostname); return ipbuffer; } #endif snprintf(ipbuffer,CF_SMALLBUF-1,"Unknown IP %s",hostname); return ipbuffer; } /*****************************************************************************/ char *IPString2Hostname(char *ipaddress) { static char hostbuffer[MAXHOSTNAMELEN]; int err; #if defined(HAVE_GETADDRINFO) struct addrinfo query, *response, *ap; memset(&query,0,sizeof(query)); memset(&response,0,sizeof(response)); query.ai_flags = AI_CANONNAME; memset(hostbuffer,0,MAXHOSTNAMELEN); if ((err = getaddrinfo(ipaddress,NULL,&query,&response)) != 0) { CfOut(cf_inform,"","Unable to lookup IP address (%s): %s",ipaddress,gai_strerror(err)); snprintf(hostbuffer,MAXHOSTNAMELEN,ipaddress); return hostbuffer; } for (ap = response; ap != NULL; ap = ap->ai_next) { if ((err = getnameinfo(ap->ai_addr,ap->ai_addrlen,hostbuffer,MAXHOSTNAMELEN,0,0,0)) != 0) { snprintf(hostbuffer,MAXHOSTNAMELEN,ipaddress); freeaddrinfo(response); return hostbuffer; } Debug("Found address (%s) for host %s\n",hostbuffer,ipaddress); freeaddrinfo(response); return hostbuffer; } snprintf(hostbuffer,MAXHOSTNAMELEN-1,ipaddress); #else struct hostent *hp; struct sockaddr_in myaddr; struct in_addr iaddr; memset(hostbuffer,0,MAXHOSTNAMELEN); if ((iaddr.s_addr = inet_addr(ipaddress)) != -1) { hp = gethostbyaddr((void *)&iaddr,sizeof(struct sockaddr_in),AF_INET); if ((hp == NULL) || (hp->h_name == NULL)) { strcpy(hostbuffer,ipaddress); return hostbuffer; } strncpy(hostbuffer,hp->h_name,MAXHOSTNAMELEN-1); } else { strcpy(hostbuffer,"(non registered IP)"); } #endif return hostbuffer; } /*****************************************************************************/ static char *IPString2UQHostname(char *ipaddress) /* Return an unqualified hostname */ { static char hostbuffer[MAXHOSTNAMELEN]; char *sp; strcpy(hostbuffer,IPString2Hostname(ipaddress)); for (sp = hostbuffer; *sp != '\0'; sp++) { if (*sp == '.') { *sp = '\0'; break; } } return hostbuffer; } /*****************************************************************************/ int GetMyHostInfo(char nameBuf[MAXHOSTNAMELEN], char ipBuf[MAXIP4CHARLEN]) { char *ip; struct hostent *hostinfo; if (gethostname(nameBuf, MAXHOSTNAMELEN) == 0) { if ((hostinfo = gethostbyname(nameBuf)) != NULL) { ip = inet_ntoa(*(struct in_addr *)*hostinfo->h_addr_list); strncpy(ipBuf, ip, MAXIP4CHARLEN - 1); ipBuf[MAXIP4CHARLEN - 1] = '\0'; return true; } else { CfOut(cf_error, "gethostbyname", "!! Could not get host entry for local host"); } } else { CfOut(cf_error, "gethostname", "!! Could not get host name"); } return false; } cfengine-3.2.4/src/install.c0000644000175000017500000002046311715232734012632 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: install.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void DeleteSubTypes(struct SubType *tp); /*******************************************************************/ int RelevantBundle(char *agent,char *blocktype) { struct Item *ip; if (strcmp(agent,CF_AGENTTYPES[cf_common]) == 0 || strcmp(CF_COMMONC,P.blocktype) == 0) { return true; } /* Here are some additional bundle types handled by cfAgent */ ip = SplitString("edit_line,edit_xml",','); if (strcmp(agent,CF_AGENTTYPES[cf_agent]) == 0) { if (IsItemIn(ip,blocktype)) { DeleteItemList(ip); return true; } } DeleteItemList(ip); return false; } /*******************************************************************/ struct Bundle *AppendBundle(struct Bundle **start,char *name, char *type, struct Rlist *args) { struct Bundle *bp,*lp; if (INSTALL_SKIP) { return NULL; } Debug("Appending new bundle %s %s (",type,name); if (DEBUG) { ShowRlist(stdout,args); } Debug(")\n"); CheckBundle(name,type); if ((bp = (struct Bundle *)malloc(sizeof(struct Bundle))) == NULL) { CfOut(cf_error,"malloc","Unable to alloc Bundle"); FatalError(""); } if (*start == NULL) { *start = bp; } else { for (lp = *start; lp->next != NULL; lp=lp->next) { } lp->next = bp; } bp->name = strdup(name); bp->next = NULL; bp->type = strdup(type); bp->args = args; bp->subtypes = NULL; return bp; } /*******************************************************************/ struct Body *AppendBody(struct Body **start,char *name, char *type, struct Rlist *args) { struct Body *bp,*lp; struct Rlist *rp; Debug("Appending new promise body %s %s(",type,name); CheckBody(name,type); for (rp = args; rp!= NULL; rp=rp->next) { Debug("%s,",(char *)rp->item); } Debug(")\n"); if ((bp = (struct Body *)malloc(sizeof(struct Body))) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Body"); FatalError(""); } if (*start == NULL) { *start = bp; } else { for (lp = *start; lp->next != NULL; lp=lp->next) { } lp->next = bp; } bp->name = strdup(name); bp->next = NULL; bp->type = strdup(type); bp->args = args; bp->conlist = NULL; return bp; } /*******************************************************************/ struct SubType *AppendSubType(struct Bundle *bundle,char *typename) { struct SubType *tp,*lp; char *sp; if (INSTALL_SKIP) { return NULL; } Debug("Appending new type section %s\n",typename); if (bundle == NULL) { yyerror("Software error. Attempt to add a type without a bundle\n"); FatalError("Stopped"); } for (lp = bundle->subtypes; lp != NULL; lp=lp->next) { if (strcmp(lp->name,typename) == 0) { return lp; } } if ((tp = (struct SubType *)malloc(sizeof(struct SubType))) == NULL) { CfOut(cf_error,"malloc","Unable to allocate SubType"); FatalError(""); } if ((sp = strdup(typename)) == NULL) { CfOut(cf_error,"malloc","Unable to allocate SubType"); FatalError(""); } if (bundle->subtypes == NULL) { bundle->subtypes = tp; } else { for (lp = bundle->subtypes; lp->next != NULL; lp=lp->next) { } lp->next = tp; } tp->promiselist = NULL; tp->name = sp; tp->next = NULL; return tp; } /*******************************************************************/ struct Promise *AppendPromise(struct SubType *type,char *promiser, void *promisee,char petype,char *classes,char *bundle,char *bundletype) { struct Promise *pp,*lp; char *sp = NULL,*spe = NULL; char output[CF_BUFSIZE]; if (INSTALL_SKIP) { return NULL; } if (type == NULL) { yyerror("Software error. Attempt to add a promise without a type\n"); FatalError("Stopped"); } /* Check here for broken promises - or later with more info? */ Debug("Appending Promise from bundle %s %s if context %s\n",bundle,promiser,classes); if ((pp = (struct Promise *)malloc(sizeof(struct Promise))) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Promise"); FatalError(""); } if ((sp = strdup(promiser)) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Promise"); FatalError(""); } if (strlen(classes) > 0) { if ((spe = strdup(classes)) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Promise"); FatalError(""); } } else { if ((spe = strdup("any")) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Promise"); FatalError(""); } } if (strcmp(type->name,"classes") == 0 || strcmp(type->name,"vars") == 0) { if (isdigit(*promiser) && Str2Int(promiser) != CF_NOINT) { yyerror("Variable or class identifier is purely numerical, which is not allowed"); } } if (strcmp(type->name,"vars") == 0) { if (!CheckParseVariableName(promiser)) { snprintf(output,CF_BUFSIZE,"Use of a reserved or illegal variable name \"%s\" ",promiser); ReportError(output); } } if (type->promiselist == NULL) { type->promiselist = pp; } else { for (lp = type->promiselist; lp->next != NULL; lp=lp->next) { } lp->next = pp; } pp->audit = AUDITPTR; pp->lineno = P.line_no; pp->bundle = strdup(bundle); pp->promiser = sp; pp->promisee = promisee; /* this is a list allocated separately */ pp->petype = petype; /* rtype of promisee - list or scalar recipient? */ pp->classes = spe; pp->conlist = NULL; pp->done = false; pp->donep = &(pp->done); pp->this_server = NULL; pp->cache = NULL; pp->conn = NULL; pp->inode_cache = NULL; pp->bundletype = strdup(bundletype); /* cache agent,common,server etc*/ pp->agentsubtype = type->name; /* Cache the typename */ pp->ref = NULL; /* cache a reference if given*/ pp->ref_alloc = 'n'; pp->next = NULL; return pp; } /*******************************************************************/ /* Cleanup */ /*******************************************************************/ void DeleteBundles(struct Bundle *bp) { if (bp == NULL) { return; } if (bp->next != NULL) { DeleteBundles(bp->next); } if (bp->name != NULL) { free(bp->name); } if (bp->type != NULL) { free(bp->type); } DeleteRlist(bp->args); DeleteSubTypes(bp->subtypes); free(bp); } /*******************************************************************/ static void DeleteSubTypes(struct SubType *tp) { if (tp == NULL) { return; } if (tp->next != NULL) { DeleteSubTypes(tp->next); } DeletePromises(tp->promiselist); if (tp->name != NULL) { free(tp->name); } free(tp); } /*******************************************************************/ void DeleteBodies(struct Body *bp) { if (bp == NULL) { return; } if (bp->next != NULL) { DeleteBodies(bp->next); } if (bp->name != NULL) { free(bp->name); } if (bp->type != NULL) { free(bp->type); } DeleteRlist(bp->args); DeleteConstraintList(bp->conlist); free(bp); } cfengine-3.2.4/src/server_transform.c0000644000175000017500000005737511715232734014601 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: server_transform.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #include "cf3.server.h" static void KeepContextBundles(void); static void KeepServerPromise(struct Promise *pp); static void InstallServerAuthPath(char *path,struct Auth **list,struct Auth **listtop); static void KeepServerRolePromise(struct Promise *pp); extern struct BodySyntax CFS_CONTROLBODY[]; extern struct BodySyntax CF_REMROLE_BODIES[]; /*******************************************************************/ /* GLOBAL VARIABLES */ /*******************************************************************/ extern int CLOCK_DRIFT; extern int CFD_MAXPROCESSES; extern int ACTIVE_THREADS; extern int NO_FORK; extern int MULTITHREAD; extern int CHECK_RFC931; extern int CFD_INTERVAL; extern int DENYBADCLOCKS; extern int MULTIPLECONNS; extern int TRIES; extern int MAXTRIES; extern int LOGCONNS; extern int LOGENCRYPT; extern struct Item *CONNECTIONLIST; extern struct Auth *ROLES; extern struct Auth *ROLESTOP; /*******************************************************************/ void KeepFileAccessPromise(struct Promise *pp); void KeepLiteralAccessPromise(struct Promise *pp, char *type); void KeepQueryAccessPromise(struct Promise *pp,char *type); /*******************************************************************/ /* Level */ /*******************************************************************/ void KeepPromises() { KeepContextBundles(); KeepControlPromises(); KeepPromiseBundles(); } /*******************************************************************/ void Summarize() { struct Auth *ptr; struct Item *ip,*ipr; CfOut(cf_verbose,"","Summarize control promises\n"); CfOut(cf_verbose, "", "Granted access to paths :\n"); for (ptr = VADMIT; ptr != NULL; ptr=ptr->next) { CfOut(cf_verbose, "", "Path: %s (encrypt=%d)\n",ptr->path,ptr->encrypt); for (ip = ptr->accesslist; ip != NULL; ip=ip->next) { CfOut(cf_verbose, "", " Admit: %s root=",ip->name); for (ipr = ptr->maproot; ipr !=NULL; ipr=ipr->next) { CfOut(cf_verbose, "", "%s,",ipr->name); } } } CfOut(cf_verbose, "", "Denied access to paths :\n"); for (ptr = VDENY; ptr != NULL; ptr=ptr->next) { CfOut(cf_verbose, "", "Path: %s\n",ptr->path); for (ip = ptr->accesslist; ip != NULL; ip=ip->next) { CfOut(cf_verbose, "", " Deny: %s\n",ip->name); } } CfOut(cf_verbose,""," -> Host IPs allowed connection access :\n"); for (ip = NONATTACKERLIST; ip != NULL; ip=ip->next) { CfOut(cf_verbose,""," .... IP: %s\n",ip->name); } CfOut(cf_verbose,"","Host IPs denied connection access :\n"); for (ip = ATTACKERLIST; ip != NULL; ip=ip->next) { CfOut(cf_verbose,""," .... IP: %s\n",ip->name); } CfOut(cf_verbose,"","Host IPs allowed multiple connection access :\n"); for (ip = MULTICONNLIST; ip != NULL; ip=ip->next) { CfOut(cf_verbose,""," .... IP: %s\n",ip->name); } CfOut(cf_verbose,"","Host IPs from whom we shall accept public keys on trust :\n"); for (ip = TRUSTKEYLIST; ip != NULL; ip=ip->next) { CfOut(cf_verbose,""," .... IP: %s\n",ip->name); } CfOut(cf_verbose,"","Users from whom we accept connections :\n"); for (ip = ALLOWUSERLIST; ip != NULL; ip=ip->next) { CfOut(cf_verbose,""," .... USERS: %s\n",ip->name); } CfOut(cf_verbose,"","Host IPs from NAT which we don't verify :\n"); for (ip = SKIPVERIFY; ip != NULL; ip=ip->next) { CfOut(cf_verbose,""," .... IP: %s\n",ip->name); } CfOut(cf_verbose,"","Dynamical Host IPs (e.g. DHCP) whose bindings could vary over time :\n"); for (ip = DHCPLIST; ip != NULL; ip=ip->next) { CfOut(cf_verbose,""," .... IP: %s\n",ip->name); } } /*******************************************************************/ /* Level */ /*******************************************************************/ void KeepControlPromises() { struct Constraint *cp; char rettype; void *retval; CFD_MAXPROCESSES = 30; MAXTRIES = 5; CFD_INTERVAL = 0; CHECKSUMUPDATES = true; DENYBADCLOCKS = true; CFRUNCOMMAND[0] = '\0'; CHECK_RFC931 = false; /* Keep promised agent behaviour - control bodies */ Banner("Server control promises.."); HashControls(); /* Now expand */ for (cp = ControlBodyConstraints(cf_server); cp != NULL; cp=cp->next) { if (IsExcluded(cp->classes)) { continue; } if (GetVariable("control_server",cp->lval,&retval,&rettype) == cf_notype) { CfOut(cf_error,"","Unknown lval %s in server control body",cp->lval); continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_serverfacility].lval) == 0) { SetFacility(retval); continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_denybadclocks].lval) == 0) { DENYBADCLOCKS = GetBoolean(retval); CfOut(cf_verbose,"","SET denybadclocks = %d\n",DENYBADCLOCKS); continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_logencryptedtransfers].lval) == 0) { LOGENCRYPT = GetBoolean(retval); CfOut(cf_verbose,"","SET LOGENCRYPT = %d\n",LOGENCRYPT); continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_logallconnections].lval) == 0) { LOGCONNS = GetBoolean(retval); CfOut(cf_verbose,"","SET LOGCONNS = %d\n",LOGCONNS); continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_maxconnections].lval) == 0) { CFD_MAXPROCESSES = (int)Str2Int(retval); MAXTRIES = CFD_MAXPROCESSES / 3; CfOut(cf_verbose,"","SET maxconnections = %d\n",CFD_MAXPROCESSES); continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_cfruncommand].lval) == 0) { strncpy(CFRUNCOMMAND,retval,CF_BUFSIZE-1); CfOut(cf_verbose,"","SET cfruncommand = %s\n",CFRUNCOMMAND); continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_allowconnects].lval) == 0) { struct Rlist *rp; CfOut(cf_verbose,"","SET Allowing connections from ...\n"); for (rp = (struct Rlist *) retval; rp != NULL; rp = rp->next) { if (!IsItemIn(NONATTACKERLIST,rp->item)) { AppendItem(&NONATTACKERLIST,rp->item,cp->classes); } } continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_denyconnects].lval) == 0) { struct Rlist *rp; CfOut(cf_verbose,"","SET Denying connections from ...\n"); for (rp = (struct Rlist *) retval; rp != NULL; rp = rp->next) { if (!IsItemIn(ATTACKERLIST,rp->item)) { AppendItem(&ATTACKERLIST,rp->item,cp->classes); } } continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_skipverify].lval) == 0) { struct Rlist *rp; CfOut(cf_verbose,"","SET Skip verify connections from ...\n"); for (rp = (struct Rlist *) retval; rp != NULL; rp = rp->next) { if (!IsItemIn(SKIPVERIFY,rp->item)) { AppendItem(&SKIPVERIFY,rp->item,cp->classes); } } continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_dynamicaddresses].lval) == 0) { struct Rlist *rp; CfOut(cf_verbose,"","SET Dynamic addresses from ...\n"); for (rp = (struct Rlist *)retval; rp != NULL; rp = rp->next) { if (!IsItemIn(DHCPLIST,rp->item)) { AppendItem(&DHCPLIST,rp->item,cp->classes); } } continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_allowallconnects].lval) == 0) { struct Rlist *rp; CfOut(cf_verbose,"","SET Allowing multiple connections from ...\n"); for (rp = (struct Rlist *)retval; rp != NULL; rp = rp->next) { if (!IsItemIn(MULTICONNLIST,rp->item)) { AppendItem(&MULTICONNLIST,rp->item,cp->classes); } } continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_allowusers].lval) == 0) { struct Rlist *rp; CfOut(cf_verbose,"","SET Allowing users ...\n"); for (rp = (struct Rlist *)retval; rp != NULL; rp = rp->next) { if (!IsItemIn(ALLOWUSERLIST,rp->item)) { AppendItem(&ALLOWUSERLIST,rp->item,cp->classes); } } continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_trustkeysfrom].lval) == 0) { struct Rlist *rp; CfOut(cf_verbose,"","SET Trust keys from ...\n"); for (rp = (struct Rlist *)retval; rp != NULL; rp = rp->next) { if (!IsItemIn(TRUSTKEYLIST,rp->item)) { AppendItem(&TRUSTKEYLIST,rp->item,cp->classes); } } continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_portnumber].lval) == 0) { SHORT_CFENGINEPORT = (short)Str2Int(retval); strncpy(STR_CFENGINEPORT,retval,15); CfOut(cf_verbose,"","SET default portnumber = %u = %s = %s\n",(int)SHORT_CFENGINEPORT,STR_CFENGINEPORT,retval); SHORT_CFENGINEPORT = htons((short)Str2Int(retval)); continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_keyttl].lval) == 0) { KEYTTL = (short)Str2Int(retval); CfOut(cf_verbose,"","SET key TTL = %d\n",KEYTTL); continue; } if (strcmp(cp->lval,CFS_CONTROLBODY[cfs_bindtointerface].lval) == 0) { strncpy(BINDINTERFACE,retval,CF_BUFSIZE-1); CfOut(cf_verbose,"","SET bindtointerface = %s\n",BINDINTERFACE); continue; } } if (GetVariable("control_common",CFG_CONTROLBODY[cfg_syslog_host].lval,&retval,&rettype) != cf_notype) { SYSLOGPORT = (unsigned short)Str2Int(retval); } if (GetVariable("control_common",CFG_CONTROLBODY[cfg_syslog_port].lval,&retval,&rettype) != cf_notype) { strncpy(SYSLOGHOST,Hostname2IPString(retval),CF_MAXVARSIZE-1); } if (GetVariable("control_common",CFG_CONTROLBODY[cfg_fips_mode].lval,&retval,&rettype) != cf_notype) { FIPS_MODE = GetBoolean(retval); CfOut(cf_verbose,"","SET FIPS_MODE = %d\n",FIPS_MODE); } } /*********************************************************************/ static void KeepContextBundles() { struct Bundle *bp; struct SubType *sp; struct Promise *pp; char *scope; /* Dial up the generic promise expansion with a callback */ for (bp = BUNDLES; bp != NULL; bp = bp->next) /* get schedule */ { scope = bp->name; SetNewScope(bp->name); if ((strcmp(bp->type,CF_AGENTTYPES[cf_server]) == 0) || (strcmp(bp->type,CF_AGENTTYPES[cf_common]) == 0)) { DeletePrivateClassContext(); // Each time we change bundle BannerBundle(bp,NULL); scope = bp->name; for (sp = bp->subtypes; sp != NULL; sp = sp->next) /* get schedule */ { if (strcmp(sp->name,"vars") != 0 && strcmp(sp->name,"classes") != 0) { continue; } BannerSubType(scope,sp->name,0); SetScope(scope); AugmentScope(scope,NULL,NULL); for (pp = sp->promiselist; pp != NULL; pp=pp->next) { ExpandPromise(cf_server,scope,pp,KeepServerPromise); } } } } } /*********************************************************************/ void KeepPromiseBundles() { struct Bundle *bp; struct SubType *sp; struct Promise *pp; char *scope; /* Dial up the generic promise expansion with a callback */ for (bp = BUNDLES; bp != NULL; bp = bp->next) /* get schedule */ { scope = bp->name; SetNewScope(bp->name); if ((strcmp(bp->type,CF_AGENTTYPES[cf_server]) == 0) || (strcmp(bp->type,CF_AGENTTYPES[cf_common]) == 0)) { DeletePrivateClassContext(); // Each time we change bundle BannerBundle(bp,NULL); scope = bp->name; for (sp = bp->subtypes; sp != NULL; sp = sp->next) /* get schedule */ { if (strcmp(sp->name,"access") != 0 && strcmp(sp->name,"roles") != 0) { continue; } BannerSubType(scope,sp->name,0); SetScope(scope); AugmentScope(scope,NULL,NULL); for (pp = sp->promiselist; pp != NULL; pp=pp->next) { ExpandPromise(cf_server,scope,pp,KeepServerPromise); } } } } } /*********************************************************************/ /* Level */ /*********************************************************************/ static void KeepServerPromise(struct Promise *pp) { char *sp = NULL; if (!IsDefinedClass(pp->classes)) { CfOut(cf_verbose,"","Skipping whole promise, as context is %s\n",pp->classes); return; } if (VarClassExcluded(pp,&sp)) { CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,"",". . . . . . . . . . . . . . . . . . . . . . . . . . . . \n"); CfOut(cf_verbose,"","Skipping whole next promise (%s), as var-context %s is not relevant\n",pp->promiser,sp); CfOut(cf_verbose,"",". . . . . . . . . . . . . . . . . . . . . . . . . . . . \n"); return; } if (strcmp(pp->agentsubtype,"classes") == 0) { KeepClassContextPromise(pp); return; } sp = (char *)GetConstraint("resource_type",pp,CF_SCALAR); if (strcmp(pp->agentsubtype,"access") == 0 && sp && strcmp(sp,"literal") == 0) { KeepLiteralAccessPromise(pp,"literal"); return; } if (strcmp(pp->agentsubtype,"access") == 0 && sp && strcmp(sp,"query") == 0) { KeepQueryAccessPromise(pp,"query"); return; } if (strcmp(pp->agentsubtype,"access") == 0 && sp && strcmp(sp,"context") == 0) { KeepLiteralAccessPromise(pp,"context"); return; } /* Default behaviour is file access */ if (strcmp(pp->agentsubtype,"access") == 0) { KeepFileAccessPromise(pp); return; } if (strcmp(pp->agentsubtype,"roles") == 0) { KeepServerRolePromise(pp); return; } } /*********************************************************************/ void KeepFileAccessPromise(struct Promise *pp) { struct Constraint *cp; struct Rlist *rp; struct Auth *ap,*dp; char *val; if (strlen(pp->promiser) != 1) { DeleteSlash(pp->promiser); } if (!GetAuthPath(pp->promiser,VADMIT)) { InstallServerAuthPath(pp->promiser,&VADMIT,&VADMITTOP); } if (!GetAuthPath(pp->promiser,VDENY)) { InstallServerAuthPath(pp->promiser,&VDENY,&VDENYTOP); } ap = GetAuthPath(pp->promiser,VADMIT); dp = GetAuthPath(pp->promiser,VDENY); for (cp = pp->conlist; cp != NULL; cp = cp->next) { if (!IsDefinedClass(cp->classes)) { continue; } switch (cp->type) { case CF_SCALAR: val = (char *)cp->rval; if (strcmp(cp->lval,CF_REMACCESS_BODIES[cfs_encrypted].lval) == 0) { ap->encrypt = true; } break; case CF_LIST: for (rp = (struct Rlist *)cp->rval; rp != NULL; rp=rp->next) { if (strcmp(cp->lval,CF_REMACCESS_BODIES[cfs_admit].lval) == 0) { PrependItem(&(ap->accesslist),rp->item,NULL); continue; } if (strcmp(cp->lval,CF_REMACCESS_BODIES[cfs_deny].lval) == 0) { PrependItem(&(dp->accesslist),rp->item,NULL); continue; } if (strcmp(cp->lval,CF_REMACCESS_BODIES[cfs_maproot].lval) == 0) { PrependItem(&(ap->maproot),rp->item,NULL); continue; } } break; case CF_FNCALL: /* Shouldn't happen */ break; } } } /*********************************************************************/ void KeepLiteralAccessPromise(struct Promise *pp,char *type) { struct Constraint *cp; struct Rlist *rp; struct Auth *ap,*dp; char *handle = GetConstraint("handle",pp,CF_SCALAR); char *val; if (handle == NULL) { CfOut(cf_error,"","Access to literal server data requires you to define a promise handle for reference"); return; } if (!GetAuthPath(handle,VARADMIT)) { InstallServerAuthPath(handle,&VARADMIT,&VARADMITTOP); } RegisterLiteralServerData(handle,pp); if (!GetAuthPath(handle,VARDENY)) { InstallServerAuthPath(handle,&VARDENY,&VARDENYTOP); } ap = GetAuthPath(handle,VARADMIT); dp = GetAuthPath(handle,VARDENY); if (strcmp(type,"literal") == 0) { ap->literal = true; } if (strcmp(type,"context") == 0) { ap->classpattern = true; } for (cp = pp->conlist; cp != NULL; cp = cp->next) { if (!IsDefinedClass(cp->classes)) { continue; } switch (cp->type) { case CF_SCALAR: val = (char *)cp->rval; if (strcmp(cp->lval,CF_REMACCESS_BODIES[cfs_encrypted].lval) == 0) { ap->encrypt = true; } break; case CF_LIST: for (rp = (struct Rlist *)cp->rval; rp != NULL; rp=rp->next) { if (strcmp(cp->lval,CF_REMACCESS_BODIES[cfs_admit].lval) == 0) { PrependItem(&(ap->accesslist),rp->item,NULL); continue; } if (strcmp(cp->lval,CF_REMACCESS_BODIES[cfs_deny].lval) == 0) { PrependItem(&(dp->accesslist),rp->item,NULL); continue; } if (strcmp(cp->lval,CF_REMACCESS_BODIES[cfs_maproot].lval) == 0) { PrependItem(&(ap->maproot),rp->item,NULL); continue; } } break; case CF_FNCALL: /* Shouldn't happen */ break; } } } /*********************************************************************/ void KeepQueryAccessPromise(struct Promise *pp,char *type) { struct Constraint *cp; struct Rlist *rp; struct Auth *ap,*dp; char *val; if (!GetAuthPath(pp->promiser,VARADMIT)) { InstallServerAuthPath(pp->promiser,&VARADMIT,&VARADMITTOP); } RegisterLiteralServerData(pp->promiser,pp); if (!GetAuthPath(pp->promiser,VARDENY)) { InstallServerAuthPath(pp->promiser,&VARDENY,&VARDENYTOP); } ap = GetAuthPath(pp->promiser,VARADMIT); dp = GetAuthPath(pp->promiser,VARDENY); if (strcmp(type,"query") == 0) { ap->literal = true; } for (cp = pp->conlist; cp != NULL; cp = cp->next) { if (!IsDefinedClass(cp->classes)) { continue; } switch (cp->type) { case CF_SCALAR: val = (char *)cp->rval; if (strcmp(cp->lval,CF_REMACCESS_BODIES[cfs_encrypted].lval) == 0) { ap->encrypt = true; } break; case CF_LIST: for (rp = (struct Rlist *)cp->rval; rp != NULL; rp=rp->next) { if (strcmp(cp->lval,CF_REMACCESS_BODIES[cfs_admit].lval) == 0) { PrependItem(&(ap->accesslist),rp->item,NULL); continue; } if (strcmp(cp->lval,CF_REMACCESS_BODIES[cfs_deny].lval) == 0) { PrependItem(&(dp->accesslist),rp->item,NULL); continue; } if (strcmp(cp->lval,CF_REMACCESS_BODIES[cfs_maproot].lval) == 0) { PrependItem(&(ap->maproot),rp->item,NULL); continue; } } break; case CF_FNCALL: /* Shouldn't happen */ break; } } } /*********************************************************************/ static void KeepServerRolePromise(struct Promise *pp) { struct Constraint *cp; struct Rlist *rp; struct Auth *ap; if (!GetAuthPath(pp->promiser,ROLES)) { InstallServerAuthPath(pp->promiser,&ROLES,&ROLESTOP); } ap = GetAuthPath(pp->promiser,ROLES); for (cp = pp->conlist; cp != NULL; cp = cp->next) { if (!IsDefinedClass(cp->classes)) { continue; } switch (cp->type) { case CF_LIST: for (rp = (struct Rlist *)cp->rval; rp != NULL; rp=rp->next) { if (strcmp(cp->lval,CF_REMROLE_BODIES[cfs_authorize].lval) == 0) { PrependItem(&(ap->accesslist),rp->item,NULL); continue; } } break; case CF_FNCALL: /* Shouldn't happen */ break; default: if (strcmp(cp->lval,"comment") == 0 || strcmp(cp->lval,"handle") == 0) { } else { CfOut(cf_error,"","RHS of authorize promise for %s should be a list\n",pp->promiser); } break; } } } /***********************************************************************/ /* Level */ /***********************************************************************/ static void InstallServerAuthPath(char *path,struct Auth **list,struct Auth **listtop) { struct Auth *ptr; #ifdef MINGW int i; for(i = 0; path[i] != '\0'; i++) { path[i] = ToLower(path[i]); } #endif /* MINGW */ if ((ptr = (struct Auth *)malloc(sizeof(struct Auth))) == NULL) { FatalError("Memory Allocation failed for InstallAuthPath() #1"); } if ((ptr->path = strdup(path)) == NULL) { FatalError("Memory Allocation failed for InstallAuthPath() #3"); } if (*listtop == NULL) /* First element in the list */ { *list = ptr; } else { (*listtop)->next = ptr; } ptr->accesslist = NULL; ptr->maproot = NULL; ptr->literal = false; ptr->encrypt = false; ptr->next = NULL; *listtop = ptr; } /***********************************************************************/ /* Level */ /***********************************************************************/ struct Auth *GetAuthPath(char *path,struct Auth *list) { struct Auth *ap; #ifdef MINGW int i; for(i = 0; path[i] != '\0'; i++) { path[i] = ToLower(path[i]); } #endif /* MINGW */ if (strlen(path) != 1) { DeleteSlash(path); } for (ap = list; ap != NULL; ap=ap->next) { if (strcmp(ap->path,path) == 0) { return ap; } } return NULL; } /***********************************************************************/ cfengine-3.2.4/src/logging.c0000644000175000017500000003417511715232734012617 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: logging.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void ExtractOperationLock(char *op); static void AddAllClasses(struct Rlist *list,int persist,enum statepolicy policy); static void DeleteAllClasses(struct Rlist *list); /*****************************************************************************/ void BeginAudit() { struct Promise dummyp = {0}; struct Attributes dummyattr = {{0}}; if (THIS_AGENT_TYPE != cf_agent) { return; } memset(&dummyp,0,sizeof(dummyp)); memset(&dummyattr,0,sizeof(dummyattr)); ClassAuditLog(&dummyp,dummyattr,"Cfagent starting",CF_NOP,""); } /*****************************************************************************/ void EndAudit() { double total; char *sp,rettype,string[CF_BUFSIZE]; void *retval; struct Promise dummyp = {0}; struct Attributes dummyattr = {{0}}; if (THIS_AGENT_TYPE != cf_agent) { return; } memset(&dummyp,0,sizeof(dummyp)); memset(&dummyattr,0,sizeof(dummyattr)); if (BooleanControl("control_agent",CFA_CONTROLBODY[cfa_track_value].lval)) { FILE *fout; char name[CF_MAXVARSIZE],datestr[CF_MAXVARSIZE]; time_t now = time(NULL); CfOut(cf_inform,""," -> Recording promise valuations"); snprintf(name,CF_MAXVARSIZE,"%s/state/%s",CFWORKDIR,CF_VALUE_LOG); snprintf(datestr,CF_MAXVARSIZE,"%s",cf_ctime(&now)); if ((fout = fopen(name,"a")) == NULL) { CfOut(cf_inform,""," !! Unable to write to the value log %s\n",name); return; } Chop(datestr); fprintf(fout,"%s,%.4lf,%.4lf,%.4lf\n",datestr,VAL_KEPT,VAL_REPAIRED,VAL_NOTKEPT); TrackValue(datestr,VAL_KEPT,VAL_REPAIRED,VAL_NOTKEPT); fclose(fout); } total = (double)(PR_KEPT+PR_NOTKEPT+PR_REPAIRED)/100.0; if (GetVariable("control_common","version",&retval,&rettype) != cf_notype) { sp = (char *)retval; } else { sp = "(not specified)"; } if (total == 0) { *string = '\0'; CfOut(cf_verbose,"","Outcome of version %s: No checks were scheduled\n",sp); return; } else { snprintf(string,CF_BUFSIZE,"Outcome of version %s (%s-%d): Promises observed to be kept %.0f%%, Promises repaired %.0f%%, Promises not repaired %.0f\%%", sp, THIS_AGENT, CFA_BACKGROUND, (double)PR_KEPT/total, (double)PR_REPAIRED/total, (double)PR_NOTKEPT/total); CfOut(cf_verbose,"","%s",string); PromiseLog(string); } if (strlen(string) > 0) { ClassAuditLog(&dummyp,dummyattr,string,CF_REPORT,""); } ClassAuditLog(&dummyp,dummyattr,"Cfagent closing",CF_NOP,""); } /*****************************************************************************/ void ClassAuditLog(struct Promise *pp,struct Attributes attr,char *str,char status,char *reason) { time_t now = time(NULL); char date[CF_BUFSIZE],lock[CF_BUFSIZE],key[CF_BUFSIZE],operator[CF_BUFSIZE]; struct AuditLog newaudit; struct Audit *ap = pp->audit; struct timespec t; double keyval; int lineno = pp->lineno; char name[CF_BUFSIZE]; const char *noStatusTypes[] = { "vars", "classes", NULL }; const char *noLogTypes[] = { "insert_lines", "delete_lines", "replace_patterns", "field_edits", NULL }; bool log = true; Debug("ClassAuditLog(%s)\n",str); // never count vars or classes as repaired (creates messy reports) if (pp && (pp->agentsubtype == NULL || IsStrIn(pp->agentsubtype,noStatusTypes))) { return; } if (pp && IsStrIn(pp->agentsubtype,noLogTypes)) { log = false; } switch(status) { case CF_CHG: if (!EDIT_MODEL) { PR_REPAIRED++; VAL_REPAIRED += attr.transaction.value_repaired; } AddAllClasses(attr.classes.change,attr.classes.persist,attr.classes.timer); DeleteAllClasses(attr.classes.del_change); if (log) { NotePromiseCompliance(pp,0.5,cfn_repaired,reason); SummarizeTransaction(attr,pp,attr.transaction.log_repaired); } break; case CF_WARN: PR_NOTKEPT++; VAL_NOTKEPT += attr.transaction.value_notkept; if (log) { NotePromiseCompliance(pp,1.0,cfn_notkept,reason); } break; case CF_TIMEX: PR_NOTKEPT++; VAL_NOTKEPT += attr.transaction.value_notkept; AddAllClasses(attr.classes.timeout,attr.classes.persist,attr.classes.timer); DeleteAllClasses(attr.classes.del_notkept); if(log) { NotePromiseCompliance(pp,0.0,cfn_notkept,reason); SummarizeTransaction(attr,pp,attr.transaction.log_failed); } break; case CF_FAIL: PR_NOTKEPT++; VAL_NOTKEPT += attr.transaction.value_notkept; AddAllClasses(attr.classes.failure,attr.classes.persist,attr.classes.timer); DeleteAllClasses(attr.classes.del_notkept); if(log) { NotePromiseCompliance(pp,0.0,cfn_notkept,reason); SummarizeTransaction(attr,pp,attr.transaction.log_failed); } break; case CF_DENIED: PR_NOTKEPT++; VAL_NOTKEPT += attr.transaction.value_notkept; AddAllClasses(attr.classes.denied,attr.classes.persist,attr.classes.timer); DeleteAllClasses(attr.classes.del_notkept); if(log) { NotePromiseCompliance(pp,0.0,cfn_notkept,reason); SummarizeTransaction(attr,pp,attr.transaction.log_failed); } break; case CF_INTERPT: PR_NOTKEPT++; VAL_NOTKEPT += attr.transaction.value_notkept; AddAllClasses(attr.classes.interrupt,attr.classes.persist,attr.classes.timer); DeleteAllClasses(attr.classes.del_notkept); if(log) { NotePromiseCompliance(pp,0.0,cfn_notkept,reason); SummarizeTransaction(attr,pp,attr.transaction.log_failed); } break; case CF_UNKNOWN: case CF_NOP: AddAllClasses(attr.classes.kept,attr.classes.persist,attr.classes.timer); DeleteAllClasses(attr.classes.del_kept); if(log) { NotePromiseCompliance(pp,1.0,cfn_nop,reason); SummarizeTransaction(attr,pp,attr.transaction.log_kept); } PR_KEPT++; VAL_KEPT += attr.transaction.value_kept; break; } if (!(attr.transaction.audit || AUDIT)) { return; } snprintf(name,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,CF_AUDITDB_FILE); MapName(name); if (!OpenDB(name,&AUDITDBP)) { return; } if (AUDITDBP == NULL || THIS_AGENT_TYPE != cf_agent) { return; } snprintf(date,CF_BUFSIZE,"%s",cf_ctime(&now)); Chop(date); ExtractOperationLock(lock); snprintf(operator,CF_BUFSIZE-1,"[%s] op %s",date,lock); strncpy(newaudit.operator,operator,CF_AUDIT_COMMENT-1); if (clock_gettime(CLOCK_REALTIME,&t) == -1) { CfOut(cf_verbose,"clock_gettime","Clock gettime failure during audit transaction"); return; } // Auditing key needs microsecond precision to separate entries keyval = (double)(t.tv_sec)+(double)(t.tv_nsec)/(double)CF_BILLION; snprintf(key,CF_BUFSIZE-1,"%lf",keyval); if (DEBUG) { AuditStatusMessage(stdout,status); } if (ap != NULL) { strncpy(newaudit.comment,str,CF_AUDIT_COMMENT-1); strncpy(newaudit.filename,ap->filename,CF_AUDIT_COMMENT-1); if (ap->version == NULL || strlen(ap->version) == 0) { Debug("Promised in %s bundle %s (unamed version last edited at %s) at/before line %d\n",ap->filename,pp->bundle,ap->date,lineno); newaudit.version[0] = '\0'; } else { Debug("Promised in %s bundle %s (version %s last edited at %s) at/before line %d\n",ap->filename,pp->bundle,ap->version,ap->date,lineno); strncpy(newaudit.version,ap->version,CF_AUDIT_VERSION-1); } strncpy(newaudit.date,ap->date,CF_AUDIT_DATE); newaudit.lineno = lineno; } else { strcpy(newaudit.date,date); strncpy(newaudit.comment,str,CF_AUDIT_COMMENT-1); strcpy(newaudit.filename,"schedule"); strcpy(newaudit.version,""); newaudit.lineno = 0; } newaudit.status = status; if (AUDITDBP && (attr.transaction.audit || AUDIT)) { WriteDB(AUDITDBP,key,&newaudit,sizeof(newaudit)); } CloseDB(AUDITDBP); } /*****************************************************************************/ static void AddAllClasses(struct Rlist *list,int persist,enum statepolicy policy) { struct Rlist *rp; int slot; char *string; if (list == NULL) { return; } for (rp = list; rp != NULL; rp=rp->next) { char *classname = strdup(rp->item); CanonifyNameInPlace(classname); if (IsHardClass(classname)) { CfOut(cf_error,""," !! You cannot use reserved hard class \"%s\" as post-condition class",classname); } if (persist > 0) { CfOut(cf_verbose,""," ?> defining persistent promise result class %s\n", classname); NewPersistentContext(CanonifyName(rp->item),persist,policy); } else { CfOut(cf_verbose,""," ?> defining promise result class %s\n", classname); } IdempPrependAlphaList(&VHEAP, classname); } } /*****************************************************************************/ static void DeleteAllClasses(struct Rlist *list) { struct Rlist *rp; char *string; int slot; if (list == NULL) { return; } for (rp = list; rp != NULL; rp=rp->next) { if (!CheckParseClass("class cancellation",(char *)rp->item,CF_IDRANGE)) { return; } if (IsHardClass((char *)rp->item)) { CfOut(cf_error,""," !! You cannot cancel a reserved hard class \"%s\" in post-condition classes", rp->item); } string = (char *)(rp->item); slot = (int)*string; CfOut(cf_verbose,""," -> Cancelling class %s\n",string); DeletePersistentContext(string); DeleteItemLiteral(&(VHEAP.list[slot]),CanonifyName(string)); DeleteItemLiteral(&(VADDCLASSES.list[slot]),CanonifyName(string)); AppendItem(&VDELCLASSES,CanonifyName(string),NULL); } } /************************************************************************/ static void ExtractOperationLock(char *op) { char *sp, lastch = 'x'; int i = 0, dots = 0; int offset = strlen("lock...")+strlen(VUQNAME); /* Use the global copy of the lock from the main serial thread */ for (sp = CFLOCK+offset; *sp != '\0'; sp++) { switch (*sp) { case '_': if (lastch == '_') { break; } else { op[i] = '/'; } break; case '.': dots++; op[i] = *sp; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': dots = 9; break; default: op[i] = *sp; break; } lastch = *sp; i++; if (dots > 1) { break; } } op[i] = '\0'; } /************************************************************************/ void PromiseLog(char *s) { char filename[CF_BUFSIZE]; time_t now = time(NULL); FILE *fout; if (s == NULL || strlen(s) == 0) { return; } snprintf(filename,CF_BUFSIZE,"%s/%s",CFWORKDIR,CF_PROMISE_LOG); MapName(filename); if ((fout = fopen(filename,"a")) == NULL) { CfOut(cf_error,"fopen","Could not open %s",filename); return; } fprintf(fout,"%ld,%ld: %s\n",CFSTARTTIME,now,s); fclose(fout); } /************************************************************************/ void FatalError(char *s, ...) { struct CfLock best_guess; if (s) { va_list ap; char buf[CF_BUFSIZE] = ""; va_start(ap, s); vsnprintf(buf, CF_BUFSIZE - 1, s, ap); va_end(ap); CfOut(cf_error,"","Fatal cfengine error: %s", buf); } if (strlen(CFLOCK) > 0) { best_guess.lock = strdup(CFLOCK); best_guess.last = strdup(CFLAST); best_guess.log = strdup(CFLOG); YieldCurrentLock(best_guess); } unlink(PIDFILE); EndAudit(); GenericDeInitialize(); exit(1); } /*****************************************************************************/ void AuditStatusMessage(FILE *fp,char status) { switch (status) /* Reminder */ { case CF_CHG: fprintf(fp,"made a system correction"); break; case CF_WARN: fprintf(fp,"promise not kept, no action taken"); break; case CF_TIMEX: fprintf(fp,"timed out"); break; case CF_FAIL: fprintf(fp,"failed to make a correction"); break; case CF_DENIED: fprintf(fp,"was denied access to an essential resource"); break; case CF_INTERPT: fprintf(fp,"was interrupted\n"); break; case CF_NOP: fprintf(fp,"was applied but performed no required actions"); break; case CF_UNKNOWN: fprintf(fp,"was applied but status unknown"); break; case CF_REPORT: fprintf(fp,"report"); break; } } cfengine-3.2.4/src/server.c0000644000175000017500000031270211715232734012472 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: server.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #include "cf3.server.h" int main (int argc,char *argv[]); void StartServer (int argc, char **argv); int OpenReceiverChannel (void); void PurgeOldConnections (struct Item **list,time_t now); void SpawnConnection (int sd_reply, char *ipaddr); void CheckFileChanges (int argc, char **argv, int sd); void *HandleConnection (struct cfd_connection *conn); int BusyWithConnection (struct cfd_connection *conn); int MatchClasses (struct cfd_connection *conn); void DoExec (struct cfd_connection *conn, char *sendbuffer, char *args); int GetCommand (char *str); int VerifyConnection (struct cfd_connection *conn, char *buf); void RefuseAccess (struct cfd_connection *conn, char *sendbuffer, int size, char *errormsg); int AccessControl(const char *oldFilename,struct cfd_connection *conn,int encrypt,struct Auth *admit, struct Auth *deny); int LiteralAccessControl(char *filename,struct cfd_connection *conn,int encrypt,struct Auth *admit, struct Auth *deny); struct Item *ContextAccessControl(char *in,struct cfd_connection *conn,int encrypt,struct Auth *vadmit, struct Auth *vdeny); void ReplyServerContext(struct cfd_connection *conn,char *sendbuffer,char *recvbuffer,int encrypted,struct Item *classes); int CheckStoreKey (struct cfd_connection *conn, RSA *key); int StatFile (struct cfd_connection *conn, char *sendbuffer, char *filename); void CfGetFile (struct cfd_get_arg *args); void CfEncryptGetFile(struct cfd_get_arg *args); void CompareLocalHash(struct cfd_connection *conn, char *sendbuffer, char *recvbuffer); void GetServerLiteral(struct cfd_connection *conn,char *sendbuffer,char *recvbuffer,int encrypted); int GetServerQuery(struct cfd_connection *conn,char *sendbuffer,char *recvbuffer); int CfOpenDirectory (struct cfd_connection *conn, char *sendbuffer, char *oldDirname); int CfSecOpenDirectory (struct cfd_connection *conn, char *sendbuffer, char *dirname); void Terminate (int sd); void DeleteAuthList (struct Auth *ap); int AllowedUser (char *user); int AuthorizeRoles(struct cfd_connection *conn,char *args); int TransferRights(char *filename,int sd,struct cfd_get_arg *args,char *sendbuffer, struct stat *sb); void AbortTransfer(int sd,char *sendbuffer,char *filename); void FailedTransfer(int sd,char *sendbuffer,char *filename); void ReplyNothing (struct cfd_connection *conn); struct cfd_connection *NewConn (int sd); void DeleteConn (struct cfd_connection *conn); time_t SecondsTillAuto (void); void SetAuto (int seconds); int cfscanf (char *in, int len1, int len2, char *out1, char *out2, char *out3); int AuthenticationDialogue (struct cfd_connection *conn,char *buffer, int buffersize); int IsKnownHost (RSA *oldkey,RSA *newkey,char *addr,char *user); void AddToKeyDB (RSA *key,char *addr); int SafeOpen (char *filename); void SafeClose (int fd); int OptionFound(char *args, char *pos, char *word); in_addr_t GetInetAddr (char *host); extern struct BodySyntax CFS_CONTROLBODY[]; char CFRUNCOMMAND[CF_BUFSIZE]; time_t CFDSTARTTIME; /*******************************************************************/ /* Command line options */ /*******************************************************************/ const char *ID = "The server daemon provides two services: it acts as a\n" "file server for remote file copying and it allows an\n" "authorized cf-runagent to start start a cf-agent process\n" "and set certain additional classes with role-based access\n" "control.\n"; const struct option OPTIONS[15] = { { "help",no_argument,0,'h' }, { "debug",optional_argument,0,'d' }, { "verbose",no_argument,0,'v' }, { "version",no_argument,0,'V' }, { "file",required_argument,0,'f'}, { "define",required_argument,0,'D' }, { "negate",required_argument,0,'N' }, { "no-lock",no_argument,0,'K'}, { "inform",no_argument,0,'I'}, { "diagnostic",no_argument,0,'x'}, { "no-fork",no_argument,0,'F' }, { "ld-library-path",required_argument,0,'L'}, { NULL,0,0,'\0' } }; const char *HINTS[15] = { "Print the help message", "Set debugging level 0,1,2,3", "Output verbose information about the behaviour of the agent", "Output the version of the software", "Specify an alternative input file than the default", "Define a list of comma separated classes to be defined at the start of execution", "Define a list of comma separated classes to be undefined at the start of execution", "Ignore locking constraints during execution (ifelapsed/expireafter) if \"too soon\" to run", "Print basic information about changes made to the system, i.e. promises repaired", "Activate internal diagnostics (developers only)", "Run as a foreground processes (do not fork)", "Set the internal value of LD_LIBRARY_PATH for child processes", NULL }; /*******************************************************************/ /* GLOBAL VARIABLES */ /*******************************************************************/ int CLOCK_DRIFT = 3600; /* 1hr */ int CFD_MAXPROCESSES = 0; int ACTIVE_THREADS = 0; int NO_FORK = false; int MULTITHREAD = false; int CHECK_RFC931 = false; int CFD_INTERVAL = 0; int DENYBADCLOCKS = true; int MULTIPLECONNS = false; int TRIES = 0; int MAXTRIES = 5; int LOGCONNS = false; int LOGENCRYPT = false; struct Item *CONNECTIONLIST = NULL; struct Auth *ROLES = NULL; struct Auth *ROLESTOP = NULL; struct Auth *VADMIT = NULL; struct Auth *VADMITTOP = NULL; struct Auth *VDENY = NULL; struct Auth *VDENYTOP = NULL; struct Auth *VARADMIT = NULL; struct Auth *VARADMITTOP = NULL; struct Auth *VARDENY = NULL; struct Auth *VARDENYTOP = NULL; /*****************************************************************************/ int main(int argc,char *argv[]) { CheckOpts(argc,argv); GenericInitialize(argc,argv,"server"); ThisAgentInit(); KeepPromises(); Summarize(); StartServer(argc,argv); return 0; } /*******************************************************************/ void CheckOpts(int argc,char **argv) { extern char *optarg; char ld_library_path[CF_BUFSIZE]; char arg[CF_BUFSIZE]; int optindex = 0; int c; while ((c=getopt_long(argc,argv,"d:vIKf:D:N:VSxLFM",OPTIONS,&optindex)) != EOF) { switch ((char) c) { case 'f': if (optarg && strlen(optarg) < 5) { snprintf(arg,CF_MAXVARSIZE," -f used but argument \"%s\" incorrect",optarg); FatalError(arg); } strncpy(VINPUTFILE,optarg,CF_BUFSIZE-1); VINPUTFILE[CF_BUFSIZE-1] = '\0'; MINUSF = true; break; case 'd': switch ((optarg==NULL) ? '3' : *optarg) { case '1': D1 = true; DEBUG = true; break; case '2': D2 = true; DEBUG = true; break; default: DEBUG = true; break; } NO_FORK = true; break; case 'K': IGNORELOCK = true; break; case 'D': NewClassesFromString(optarg); break; case 'N': NegateClassesFromString(optarg,&VNEGHEAP); break; case 'I': INFORM = true; break; case 'v': VERBOSE = true; NO_FORK = true; break; case 'F': NO_FORK = true; break; case 'L': CfOut(cf_verbose,"","Setting LD_LIBRARY_PATH=%s\n",optarg); snprintf(ld_library_path,CF_BUFSIZE-1,"LD_LIBRARY_PATH=%s",optarg); putenv(ld_library_path); break; case 'V': PrintVersionBanner("cf-serverd"); exit(0); case 'h': Syntax("cf-serverd - cfengine's server agent",OPTIONS,HINTS,ID); exit(0); case 'M': ManPage("cf-serverd - cfengine's server agent",OPTIONS,HINTS,ID); exit(0); case 'x': SelfDiagnostic(); exit(0); default: Syntax("cf-serverd - cfengine's server agent",OPTIONS,HINTS,ID); exit(1); } } if (argv[optind] != NULL) { CfOut(cf_error,"","Unexpected argument with no preceding option: %s\n",argv[optind]); FatalError("Aborted"); } Debug("Set debugging\n"); } /*******************************************************************/ void ThisAgentInit() { NewScope("remote_access"); umask(077); CFDSTARTTIME = time(NULL); KEYTTL = 24; } /*******************************************************************/ void StartServer(int argc,char **argv) { char ipaddr[CF_MAXVARSIZE],intime[64]; int sd,sd_reply; fd_set rset; time_t now; struct timeval timeout; int ret_val; struct Promise *pp = NewPromise("server_cfengine","the server daemon"); struct Attributes dummyattr = {{0}}; struct CfLock thislock; #if defined(HAVE_GETADDRINFO) int addrlen=sizeof(struct sockaddr_in6); struct sockaddr_in6 cin; #else int addrlen=sizeof(struct sockaddr_in); struct sockaddr_in cin; #endif memset(&dummyattr,0,sizeof(dummyattr)); if ((sd = OpenReceiverChannel()) == -1) { CfOut(cf_error,"","Unable to start server"); exit(1); } signal(SIGINT,HandleSignals); signal(SIGTERM,HandleSignals); signal(SIGHUP,SIG_IGN); signal(SIGPIPE,SIG_IGN); signal(SIGCHLD,SIG_IGN); signal(SIGUSR1,HandleSignals); signal(SIGUSR2,HandleSignals); if (listen(sd,queuesize) == -1) { CfOut(cf_error,"listen","listen failed"); exit(1); } dummyattr.transaction.ifelapsed = 0; dummyattr.transaction.expireafter = 1; thislock = AcquireLock(pp->promiser,VUQNAME,CFSTARTTIME,dummyattr,pp,false); if (thislock.lock == NULL) { return; } CfOut(cf_verbose,"","Listening for connections ...\n"); #ifdef MINGW if(!NO_FORK) { CfOut(cf_verbose, "", "Windows does not support starting processes in the background - starting in foreground"); } #else /* NOT MINGW */ if ((!NO_FORK) && (fork() != 0)) { CfOut(cf_inform,"","cf-serverd starting %.24s\n",cf_ctime(&CFDSTARTTIME)); GenericDeInitialize(); exit(0); } if (!NO_FORK) { ActAsDaemon(sd); } #endif /* NOT MINGW */ WritePID("cf-serverd.pid"); /* Andrew Stribblehill -- close sd on exec */ #ifndef MINGW fcntl(sd, F_SETFD, FD_CLOEXEC); #endif while (true) { if (ThreadLock(cft_server_children)) { if (ACTIVE_THREADS == 0) { CheckFileChanges(argc,argv,sd); } ThreadUnlock(cft_server_children); } FD_ZERO(&rset); FD_SET(sd,&rset); timeout.tv_sec = 10; /* Set a 10 second timeout for select */ timeout.tv_usec = 0; Debug(" -> Waiting at incoming select...\n"); ret_val = select((sd+1),&rset,NULL,NULL,&timeout); if (ret_val == -1) /* Error received from call to select */ { if (errno == EINTR) { continue; } else { CfOut(cf_error,"select","select failed"); exit(1); } } else if (!ret_val) /* No data waiting, we must have timed out! */ { continue; } CfOut(cf_verbose,""," -> Accepting a connection\n"); if ((sd_reply = accept(sd,(struct sockaddr *)&cin,&addrlen)) != -1) { memset(ipaddr,0,CF_MAXVARSIZE); ThreadLock(cft_getaddr); snprintf(ipaddr,CF_MAXVARSIZE-1,"%s",sockaddr_ntop((struct sockaddr *)&cin)); ThreadUnlock(cft_getaddr); Debug("Obtained IP address of %s on socket %d from accept\n",ipaddr,sd_reply); if (NONATTACKERLIST && !IsMatchItemIn(NONATTACKERLIST,MapAddress(ipaddr))) { CfOut(cf_error,"","Not allowing connection from non-authorized IP %s\n",ipaddr); cf_closesocket(sd_reply); continue; } if (IsMatchItemIn(ATTACKERLIST,MapAddress(ipaddr))) { CfOut(cf_error,"","Denying connection from non-authorized IP %s\n",ipaddr); cf_closesocket(sd_reply); continue; } if ((now = time((time_t *)NULL)) == -1) { now = 0; } PurgeOldConnections(&CONNECTIONLIST,now); if (!IsMatchItemIn(MULTICONNLIST,MapAddress(ipaddr))) { if (IsItemIn(CONNECTIONLIST,MapAddress(ipaddr))) { CfOut(cf_error,"","Denying repeated connection from \"%s\"\n",ipaddr); cf_closesocket(sd_reply); continue; } } if (LOGCONNS) { CfOut(cf_log,"","Accepting connection from \"%s\"\n",ipaddr); } else { CfOut(cf_inform,"","Accepting connection from \"%s\"\n",ipaddr); } snprintf(intime,63,"%d",(int)now); if (!ThreadLock(cft_count)) { return; } PrependItem(&CONNECTIONLIST,MapAddress(ipaddr),intime); if (!ThreadUnlock(cft_count)) { return; } SpawnConnection(sd_reply,ipaddr); } } YieldCurrentLock(thislock); /* We never get here - this is done by a signal handler */ } /*******************************************************************************/ in_addr_t GetInetAddr(char *host) { struct in_addr addr; struct hostent *hp; char output[CF_BUFSIZE]; addr.s_addr = inet_addr(host); if ((addr.s_addr == INADDR_NONE) || (addr.s_addr == 0)) { if ((hp = gethostbyname(host)) == 0) { snprintf(output,CF_BUFSIZE,"\nhost not found: %s\n",host); FatalError(output); } if (hp->h_addrtype != AF_INET) { snprintf(output,CF_BUFSIZE,"unexpected address family: %d\n",hp->h_addrtype); FatalError(output); } if (hp->h_length != sizeof(addr)) { snprintf(output,CF_BUFSIZE,"unexpected address length %d\n",hp->h_length); FatalError(output); } memcpy((char *) &addr, hp->h_addr, hp->h_length); } return (addr.s_addr); } /*********************************************************************/ /* Level 2 */ /*********************************************************************/ int OpenReceiverChannel() { int sd; int yes=1; char *ptr = NULL; struct linger cflinger; #if defined(HAVE_GETADDRINFO) struct addrinfo query,*response,*ap; #else struct sockaddr_in sin; #endif cflinger.l_onoff = 1; cflinger.l_linger = 60; #if defined(HAVE_GETADDRINFO) memset(&query,0,sizeof(struct addrinfo)); query.ai_flags = AI_PASSIVE; query.ai_family = AF_UNSPEC; query.ai_socktype = SOCK_STREAM; /* * HvB : Bas van der Vlies */ if (BINDINTERFACE[0] != '\0' ) { ptr = BINDINTERFACE; } if (getaddrinfo(ptr,STR_CFENGINEPORT,&query,&response) != 0) { CfOut(cf_error,"getaddrinfo","DNS/service lookup failure"); return -1; } sd = -1; for (ap = response ; ap != NULL; ap=ap->ai_next) { if ((sd = socket(ap->ai_family,ap->ai_socktype,ap->ai_protocol)) == -1) { continue; } if (setsockopt(sd, SOL_SOCKET,SO_REUSEADDR,(char *)&yes,sizeof (int)) == -1) { CfOut(cf_error,"setsockopt","Socket options were not accepted"); exit(1); } if (setsockopt(sd, SOL_SOCKET, SO_LINGER,(char *)&cflinger,sizeof (struct linger)) == -1) { CfOut(cf_error,"setsockopt","Socket options were not accepted"); exit(1); } if (bind(sd,ap->ai_addr,ap->ai_addrlen) == 0) { if (DEBUG) { ThreadLock(cft_getaddr); printf("Bound to address %s on %s=%d\n",sockaddr_ntop(ap->ai_addr),CLASSTEXT[VSYSTEMHARDCLASS],VSYSTEMHARDCLASS); ThreadUnlock(cft_getaddr); } if (VSYSTEMHARDCLASS == mingw || VSYSTEMHARDCLASS == openbsd || VSYSTEMHARDCLASS == freebsd || VSYSTEMHARDCLASS == netbsd || VSYSTEMHARDCLASS == dragonfly) { continue; /* *bsd doesn't map ipv6 addresses */ } else { break; } } CfOut(cf_error,"bind","Could not bind server address"); cf_closesocket(sd); sd = -1; } if (sd < 0) { CfOut(cf_error,"","Couldn't open bind an open socket\n"); exit(1); } if (response != NULL) { freeaddrinfo(response); } #else memset(&sin,0,sizeof(sin)); if (BINDINTERFACE[0] != '\0' ) { sin.sin_addr.s_addr = GetInetAddr(BINDINTERFACE); } else { sin.sin_addr.s_addr = INADDR_ANY; } sin.sin_port = (unsigned short)SHORT_CFENGINEPORT; sin.sin_family = AF_INET; if ((sd = socket(AF_INET,SOCK_STREAM,0)) == -1) { CfOut(cf_error,"socket","Couldn't open socket"); exit (1); } if (setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (char *) &yes, sizeof (int)) == -1) { CfOut(cf_error,"sockopt","Couldn't set socket options"); exit (1); } if (setsockopt(sd, SOL_SOCKET, SO_LINGER, (char *) &cflinger, sizeof (struct linger)) == -1) { CfOut(cf_error,"sockopt","Couldn't set socket options"); exit (1); } if (bind(sd,(struct sockaddr *)&sin,sizeof(sin)) == -1) { CfOut(cf_error,"bind","Couldn't bind to socket"); exit(1); } #endif return sd; } /*********************************************************************/ /* Level 3 */ /*********************************************************************/ void PurgeOldConnections(struct Item **list,time_t now) /* Some connections might not terminate properly. These should be cleaned every couple of hours. That should be enough to prevent spamming. */ { struct Item *ip; int then = 0; if (list == NULL) { return; } Debug("Purging Old Connections...\n"); if (!ThreadLock(cft_count)) { return; } for (ip = *list; ip != NULL; ip=ip->next) { sscanf(ip->classes,"%d",&then); if (now > then + 7200) { DeleteItem(list,ip); CfOut(cf_verbose,"","Purging IP address %s from connection list\n",ip->name); } } if (!ThreadUnlock(cft_count)) { return; } Debug("Done purging\n"); } /*********************************************************************/ void SpawnConnection(int sd_reply,char *ipaddr) { struct cfd_connection *conn; #ifdef HAVE_PTHREAD_H pthread_t tid; #endif conn = NewConn(sd_reply); strncpy(conn->ipaddr,ipaddr,CF_MAX_IP_LEN-1); CfOut(cf_verbose,"","New connection...(from %s:sd %d)\n",conn->ipaddr,sd_reply); #if defined HAVE_LIBPTHREAD || defined BUILTIN_GCC_THREAD CfOut(cf_verbose,"","Spawning new thread...\n"); pthread_attr_init(&PTHREADDEFAULTS); pthread_attr_setdetachstate(&PTHREADDEFAULTS,PTHREAD_CREATE_DETACHED); #ifdef HAVE_PTHREAD_ATTR_SETSTACKSIZE pthread_attr_setstacksize(&PTHREADDEFAULTS,(size_t)1024*1024); #endif if (pthread_create(&tid,&PTHREADDEFAULTS,(void *)HandleConnection,(void *)conn) != 0) { CfOut(cf_error,"create","pthread_create failed"); HandleConnection(conn); } pthread_attr_destroy(&PTHREADDEFAULTS); #else /* Can't fork here without getting a zombie unless we do some complex waiting? */ CfOut(cf_verbose,"","Single threaded...\n"); HandleConnection(conn); #endif } /**************************************************************/ void CheckFileChanges(int argc,char **argv,int sd) { struct stat newstat; char filename[CF_BUFSIZE]; int ok; memset(&newstat,0,sizeof(struct stat)); memset(filename,0,CF_BUFSIZE); if (!IsFileOutsideDefaultRepository(VINPUTFILE)) /* Don't prepend to absolute names */ { snprintf(filename,CF_BUFSIZE,"%s/inputs/",CFWORKDIR); } strncat(filename,VINPUTFILE,CF_BUFSIZE-1-strlen(filename)); MapName(filename); Debug("Checking file updates on %s (%x/%x)\n",filename, newstat.st_mtime, CFDSTARTTIME); if (NewPromiseProposals()) { CfOut(cf_verbose,""," -> New promises detected...\n"); ok = CheckPromises(cf_server); if (ok) { CfOut(cf_inform,"","Rereading config files %s..\n",filename); /* Free & reload -- lock this to avoid access errors during reload */ DeleteAlphaList(&VHEAP); InitAlphaList(&VHEAP); DeleteAlphaList(&VADDCLASSES); InitAlphaList(&VADDCLASSES); DeleteItemList(VNEGHEAP); DeleteItemList(TRUSTKEYLIST); DeleteItemList(SKIPVERIFY); DeleteItemList(DHCPLIST); DeleteItemList(ATTACKERLIST); DeleteItemList(NONATTACKERLIST); DeleteItemList(MULTICONNLIST); DeleteAuthList(VADMIT); DeleteAuthList(VDENY); //DeleteRlist(VINPUTLIST); This is just a pointer, cannot free it VSYSTEMHARDCLASS = unused1; DeleteAllScope(); strcpy(VDOMAIN,"undefined.domain"); POLICY_SERVER[0] = '\0'; VADMIT = VADMITTOP = NULL; VDENY = VDENYTOP = NULL; VNEGHEAP = NULL; TRUSTKEYLIST = NULL; SKIPVERIFY = NULL; DHCPLIST = NULL; ATTACKERLIST = NULL; NONATTACKERLIST = NULL; MULTICONNLIST = NULL; VINPUTLIST = NULL; DeleteBundles(BUNDLES); DeleteBodies(BODIES); BUNDLES = NULL; BODIES = NULL; ERRORCOUNT = 0; NewScope("sys"); SetPolicyServer(POLICY_SERVER); NewScalar("sys","policy_hub",POLICY_SERVER,cf_str); if (EnterpriseExpiry()) { CfOut(cf_error,"","Cfengine - autonomous configuration engine. This enterprise license is invalid.\n"); } NewScope("const"); NewScope("this"); NewScope("control_server"); NewScope("control_common"); NewScope("mon"); NewScope("remote_access"); GetNameInfo3(); CfGetInterfaceInfo(cf_server); Get3Environment(); BuiltinClasses(); OSClasses(); NewClass(THIS_AGENT); SetReferenceTime(true); ReadPromises(cf_server,CF_SERVERC); KeepPromises(); Summarize(); } else { CfOut(cf_inform,""," !! File changes contain errors -- ignoring"); PROMISETIME = time(NULL); } } else { Debug(" -> No new promises found\n"); } } /*********************************************************************/ /* Level 4 */ /*********************************************************************/ void *HandleConnection(struct cfd_connection *conn) { char output[CF_BUFSIZE]; #if defined HAVE_PTHREAD_H && (defined HAVE_LIBPTHREAD || defined BUILDTIN_GCC_THREAD) #ifdef HAVE_PTHREAD_SIGMASK sigset_t sigmask; sigemptyset(&sigmask); pthread_sigmask(SIG_BLOCK,&sigmask,NULL); #endif #endif if (conn == NULL) { Debug("Null connection\n"); return NULL; } if (!ThreadLock(cft_server_children)) { DeleteConn(conn); return NULL; } ACTIVE_THREADS++; if (ACTIVE_THREADS >= CFD_MAXPROCESSES) { ACTIVE_THREADS--; if (TRIES++ > MAXTRIES) /* When to say we're hung / apoptosis threshold */ { CfOut(cf_error,"","Server seems to be paralyzed. DOS attack? Committing apoptosis..."); HandleSignals(SIGTERM); } if (!ThreadUnlock(cft_server_children)) { } CfOut(cf_error,"","Too many threads (>=%d) -- increase server maxconnections?",CFD_MAXPROCESSES); snprintf(output,CF_BUFSIZE,"BAD: Server is currently too busy -- increase maxconnections or splaytime?"); SendTransaction(conn->sd_reply,output,0,CF_DONE); DeleteConn(conn); return NULL; } else { ThreadUnlock(cft_server_children); } TRIES = 0; /* As long as there is activity, we're not stuck */ while (BusyWithConnection(conn)) { } Debug("Terminating thread...\n"); if (!ThreadLock(cft_server_children)) { DeleteConn(conn); return NULL; } ACTIVE_THREADS--; if (!ThreadUnlock(cft_server_children)) { } DeleteConn(conn); return NULL; } /*********************************************************************/ int BusyWithConnection(struct cfd_connection *conn) /* This is the protocol section. Here we must */ /* check that the incoming data are sensible */ /* and extract the information from the message */ { time_t tloc, trem = 0; char recvbuffer[CF_BUFSIZE+CF_BUFEXT], sendbuffer[CF_BUFSIZE],check[CF_BUFSIZE]; char filename[CF_BUFSIZE],buffer[CF_BUFSIZE],args[CF_BUFSIZE],out[CF_BUFSIZE]; long time_no_see = 0; unsigned int len=0; int drift, plainlen, received, encrypted = 0; struct cfd_get_arg get_args; struct Item *classes; memset(recvbuffer,0,CF_BUFSIZE+CF_BUFEXT); memset(&get_args,0,sizeof(get_args)); if ((received = ReceiveTransaction(conn->sd_reply,recvbuffer,NULL)) == -1) { return false; } if (strlen(recvbuffer) == 0) { Debug("cf-serverd terminating NULL transmission!\n"); return false; } Debug("Received: [%s] on socket %d\n",recvbuffer,conn->sd_reply); switch (GetCommand(recvbuffer)) { case cfd_exec: memset(args,0,CF_BUFSIZE); sscanf(recvbuffer,"EXEC %255[^\n]",args); if (!conn->id_verified) { CfOut(cf_inform,"","Server refusal due to incorrect identity\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } if (!AllowedUser(conn->username)) { CfOut(cf_inform,"","Server refusal due to non-allowed user\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } if (!conn->rsa_auth) { CfOut(cf_inform,"","Server refusal due to no RSA authentication\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } if (!AccessControl(GetArg0(CFRUNCOMMAND),conn,false,VADMIT,VDENY)) { CfOut(cf_inform,"","Server refusal due to denied access to requested object\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } if (!MatchClasses(conn)) { CfOut(cf_inform,"","Server refusal due to failed class/context match\n"); Terminate(conn->sd_reply); return false; } DoExec(conn,sendbuffer,args); Terminate(conn->sd_reply); return false; case cfd_version: if (! conn->id_verified) { CfOut(cf_inform,"","ID not verified\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); } snprintf(conn->output,CF_BUFSIZE,"OK: %s",Version()); SendTransaction(conn->sd_reply,conn->output,0,CF_DONE); return conn->id_verified; case cfd_cauth: conn->id_verified = VerifyConnection(conn,(char *)(recvbuffer+strlen("CAUTH "))); if (! conn->id_verified) { CfOut(cf_inform,"","ID not verified\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); } return conn->id_verified; /* are we finished yet ? */ case cfd_sauth: /* This is where key agreement takes place */ if (! conn->id_verified) { CfOut(cf_inform,"","ID not verified\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } if (!AuthenticationDialogue(conn,recvbuffer,received)) { CfOut(cf_inform,"","Auth dialogue error\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } return true; case cfd_get: memset(filename,0,CF_BUFSIZE); sscanf(recvbuffer,"GET %d %[^\n]",&(get_args.buf_size),filename); if (get_args.buf_size < 0 || get_args.buf_size > CF_BUFSIZE) { CfOut(cf_inform,"","GET buffer out of bounds\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } if (! conn->id_verified) { CfOut(cf_inform,"","ID not verified\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } if (!AccessControl(filename,conn,false,VADMIT,VDENY)) { CfOut(cf_inform,"","Access denied to get object\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return true; } memset(sendbuffer,0,CF_BUFSIZE); if (get_args.buf_size >= CF_BUFSIZE) { get_args.buf_size = 2048; } get_args.connect = conn; get_args.encrypt = false; get_args.replybuff = sendbuffer; get_args.replyfile = filename; CfGetFile(&get_args); return true; case cfd_sget: memset(buffer,0,CF_BUFSIZE); sscanf(recvbuffer,"SGET %u %d",&len,&(get_args.buf_size)); if (received != len+CF_PROTO_OFFSET) { CfOut(cf_verbose,"","Protocol error SGET\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } plainlen = DecryptString(conn->encryption_type,recvbuffer+CF_PROTO_OFFSET,buffer,conn->session_key,len); cfscanf(buffer,strlen("GET"),strlen("dummykey"),check,sendbuffer,filename); if (strcmp(check,"GET") != 0) { CfOut(cf_inform,"","SGET/GET problem\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return true; } if (get_args.buf_size < 0 || get_args.buf_size > 8192) { CfOut(cf_inform,"","SGET bounding error\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } if (get_args.buf_size >= CF_BUFSIZE) { get_args.buf_size = 2048; } Debug("Confirm decryption, and thus validity of caller\n"); Debug("SGET %s with blocksize %d\n",filename,get_args.buf_size); if (! conn->id_verified) { CfOut(cf_inform,"","ID not verified\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } if (!AccessControl(filename,conn,true,VADMIT,VDENY)) { CfOut(cf_inform,"","Access control error\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } memset(sendbuffer,0,CF_BUFSIZE); get_args.connect = conn; get_args.encrypt = true; get_args.replybuff = sendbuffer; get_args.replyfile = filename; CfEncryptGetFile(&get_args); return true; case cfd_sopendir: memset(buffer,0,CF_BUFSIZE); sscanf(recvbuffer,"SOPENDIR %u",&len); if (len >= sizeof(out) || received != len+CF_PROTO_OFFSET) { CfOut(cf_verbose,"","Protocol error OPENDIR: %d\n",len); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } if (conn->session_key == NULL) { CfOut(cf_inform,"","No session key\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } memcpy(out,recvbuffer+CF_PROTO_OFFSET,len); plainlen = DecryptString(conn->encryption_type,out,recvbuffer,conn->session_key,len); if (strncmp(recvbuffer,"OPENDIR",7) !=0) { CfOut(cf_inform,"","Opendir failed to decrypt\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return true; } memset(filename,0,CF_BUFSIZE); sscanf(recvbuffer,"OPENDIR %[^\n]",filename); if (! conn->id_verified) { CfOut(cf_inform,"","ID not verified\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } if (!AccessControl(filename,conn,true,VADMIT,VDENY)) /* opendir don't care about privacy */ { CfOut(cf_inform,"","Access error\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } CfSecOpenDirectory(conn,sendbuffer,filename); return true; case cfd_opendir: memset(filename,0,CF_BUFSIZE); sscanf(recvbuffer,"OPENDIR %[^\n]",filename); if (! conn->id_verified) { CfOut(cf_inform,"","ID not verified\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } if (!AccessControl(filename,conn,true,VADMIT,VDENY)) /* opendir don't care about privacy */ { CfOut(cf_inform,"","DIR access error\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } CfOpenDirectory(conn,sendbuffer,filename); return true; case cfd_ssynch: memset(buffer,0,CF_BUFSIZE); sscanf(recvbuffer,"SSYNCH %u",&len); if (len >= sizeof(out) || received != len+CF_PROTO_OFFSET) { CfOut(cf_verbose,"","Protocol error SSYNCH: %d\n",len); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } if (conn->session_key == NULL) { CfOut(cf_inform,"","Bad session key\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } memcpy(out,recvbuffer+CF_PROTO_OFFSET,len); plainlen = DecryptString(conn->encryption_type,out,recvbuffer,conn->session_key,len); if (plainlen < 0) { DebugBinOut((char *)conn->session_key,32,"Session key"); CfOut(cf_error, "", "!! Bad decrypt (%d)",len); } if (strncmp(recvbuffer,"SYNCH",5) != 0) { CfOut(cf_inform,"","No synch\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return true; } /* roll through, no break */ case cfd_synch: if (! conn->id_verified) { CfOut(cf_inform,"","ID not verified\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } memset(filename,0,CF_BUFSIZE); sscanf(recvbuffer,"SYNCH %ld STAT %[^\n]",&time_no_see,filename); trem = (time_t) time_no_see; if (time_no_see == 0 || filename[0] == '\0') { break; } if ((tloc = time((time_t *)NULL)) == -1) { sprintf(conn->output,"Couldn't read system clock\n"); CfOut(cf_inform,"time",conn->output); SendTransaction(conn->sd_reply,"BAD: clocks out of synch",0,CF_DONE); return true; } drift = (int)(tloc-trem); if (!AccessControl(filename,conn,true,VADMIT,VDENY)) { CfOut(cf_inform,"","Access control in sync\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return true; } if (DENYBADCLOCKS && (drift*drift > CLOCK_DRIFT*CLOCK_DRIFT)) { snprintf(conn->output,CF_BUFSIZE-1,"BAD: Clocks are too far unsynchronized %ld/%ld\n",(long)tloc,(long)trem); SendTransaction(conn->sd_reply,conn->output,0,CF_DONE); return true; } else { Debug("Clocks were off by %ld\n",(long)tloc-(long)trem); StatFile(conn,sendbuffer,filename); } return true; case cfd_smd5: sscanf(recvbuffer,"SMD5 %u",&len); if (len >= sizeof(out) || received != len+CF_PROTO_OFFSET) { CfOut(cf_inform,"","Decryption error\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return true; } memcpy(out,recvbuffer+CF_PROTO_OFFSET,len); plainlen = DecryptString(conn->encryption_type,out,recvbuffer,conn->session_key,len); if (strncmp(recvbuffer,"MD5",3) !=0) { CfOut(cf_inform,"","MD5 protocol error\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } /* roll through, no break */ case cfd_md5: if (! conn->id_verified) { CfOut(cf_inform,"","ID not verified\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return true; } CompareLocalHash(conn,sendbuffer,recvbuffer); return true; case cfd_svar: sscanf(recvbuffer,"SVAR %u",&len); if (len >= sizeof(out) || received != len+CF_PROTO_OFFSET) { CfOut(cf_inform,"","Decrypt error SVAR\n"); RefuseAccess(conn,sendbuffer,0,"decrypt error SVAR"); return true; } memcpy(out,recvbuffer+CF_PROTO_OFFSET,len); plainlen = DecryptString(conn->encryption_type,out,recvbuffer,conn->session_key,len); encrypted = true; if (strncmp(recvbuffer,"VAR",3) !=0) { CfOut(cf_inform,"","VAR protocol defect\n"); RefuseAccess(conn,sendbuffer,0,"decryption failure"); return false; } /* roll through, no break */ case cfd_var: if (! conn->id_verified) { CfOut(cf_inform,"","ID not verified\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return true; } if (!LiteralAccessControl(recvbuffer,conn,encrypted,VARADMIT,VARDENY)) { CfOut(cf_inform,"","Literal access failure\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } GetServerLiteral(conn,sendbuffer,recvbuffer,encrypted); return true; case cfd_scontext: sscanf(recvbuffer,"SCONTEXT %u",&len); if (len >= sizeof(out) || received != len+CF_PROTO_OFFSET) { CfOut(cf_inform,"","Decrypt error SCONTEXT, len,received = %d,%d\n",len,received); RefuseAccess(conn,sendbuffer,0,"decrypt error SCONTEXT"); return true; } memcpy(out,recvbuffer+CF_PROTO_OFFSET,len); plainlen = DecryptString(conn->encryption_type,out,recvbuffer,conn->session_key,len); encrypted = true; if (strncmp(recvbuffer,"CONTEXT",7) !=0) { CfOut(cf_inform,"","CONTEXT protocol defect...\n"); RefuseAccess(conn,sendbuffer,0,"Decryption failed?"); return false; } /* roll through, no break */ case cfd_context: if (! conn->id_verified) { CfOut(cf_inform,"","ID not verified\n"); RefuseAccess(conn,sendbuffer,0,"Context probe"); return true; } if ((classes = ContextAccessControl(recvbuffer,conn,encrypted,VARADMIT,VARDENY)) == NULL) { CfOut(cf_inform,"","Context access failure on %s\n",recvbuffer); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } ReplyServerContext(conn,sendbuffer,recvbuffer,encrypted,classes); return true; case cfd_squery: sscanf(recvbuffer,"SQUERY %u",&len); if (len >= sizeof(out) || received != len+CF_PROTO_OFFSET) { CfOut(cf_inform,"","Decrypt error SQUERY\n"); RefuseAccess(conn,sendbuffer,0,"decrypt error SVAR"); return true; } memcpy(out,recvbuffer+CF_PROTO_OFFSET,len); plainlen = DecryptString(conn->encryption_type,out,recvbuffer,conn->session_key,len); if (strncmp(recvbuffer,"QUERY",5) !=0) { CfOut(cf_inform,"","QUERY protocol defect\n"); RefuseAccess(conn,sendbuffer,0,"decryption failure"); return false; } if (! conn->id_verified) { CfOut(cf_inform,"","ID not verified\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return true; } if (!LiteralAccessControl(recvbuffer,conn,true,VARADMIT,VARDENY)) { CfOut(cf_inform,"","Query access failure\n"); RefuseAccess(conn,sendbuffer,0,recvbuffer); return false; } if (GetServerQuery(conn,sendbuffer,recvbuffer)) { return true; } } sprintf (sendbuffer,"BAD: Request denied\n"); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); CfOut(cf_inform,"","Closing connection, due to request: \"%s\"\n",recvbuffer); return false; } /**************************************************************/ /* Level 4 */ /**************************************************************/ int MatchClasses(struct cfd_connection *conn) { char recvbuffer[CF_BUFSIZE]; struct Item *classlist = NULL, *ip; int count = 0; Debug("Match classes\n"); while (true && (count < 10)) /* arbitrary check to avoid infinite loop, DoS attack*/ { count++; if (ReceiveTransaction(conn->sd_reply,recvbuffer,NULL) == -1) { CfOut(cf_verbose, "ReceiveTransaction", "Unable to read data from network"); return false; } Debug("Got class buffer %s\n",recvbuffer); if (strncmp(recvbuffer,CFD_TERMINATOR,strlen(CFD_TERMINATOR)) == 0) { if (count == 1) { Debug("No classes were sent, assuming no restrictions...\n"); return true; } break; } classlist = SplitStringAsItemList(recvbuffer,' '); for (ip = classlist; ip != NULL; ip=ip->next) { CfOut(cf_verbose,"","Checking whether class %s can be identified as me...\n",ip->name); if (IsDefinedClass(ip->name)) { Debug("Class %s matched, accepting...\n",ip->name); DeleteItemList(classlist); return true; } if (MatchInAlphaList(VHEAP,ip->name)) { Debug("Class matched regular expression %s, accepting...\n",ip->name); DeleteItemList(classlist); return true; } if (strncmp(ip->name,CFD_TERMINATOR,strlen(CFD_TERMINATOR)) == 0) { CfOut(cf_verbose,"","No classes matched, rejecting....\n"); ReplyNothing(conn); DeleteItemList(classlist); return false; } } } ReplyNothing(conn); CfOut(cf_verbose,"","No classes matched, rejecting....\n"); DeleteItemList(classlist); return false; } /******************************************************************/ void DoExec(struct cfd_connection *conn,char *sendbuffer,char *args) { char ebuff[CF_EXPANDSIZE], line[CF_BUFSIZE], *sp; int print = false,i; FILE *pp; if ((CFSTARTTIME = time((time_t *)NULL)) == -1) { CfOut(cf_error,"time","Couldn't read system clock\n"); } if (strlen(CFRUNCOMMAND) == 0) { CfOut(cf_verbose,"","cf-serverd exec request: no cfruncommand defined\n"); sprintf(sendbuffer,"Exec request: no cfruncommand defined\n"); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); return; } CfOut(cf_verbose,"","Examining command string: %s\n",args); for (sp = args; *sp != '\0'; sp++) /* Blank out -K -f */ { if (*sp == ';' || *sp == '&' || *sp == '|') { sprintf(sendbuffer,"You are not authorized to activate these classes/roles on host %s\n",VFQNAME); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); return; } if (OptionFound(args,sp,"-K")||OptionFound(args,sp,"-f")) { *sp = ' '; *(sp+1) = ' '; } else if (OptionFound(args,sp,"--no-lock")) { for (i = 0; i < strlen("--no-lock"); i++) { *(sp+i) = ' '; } } else if (OptionFound(args,sp,"--file")) { for (i = 0; i < strlen("--file"); i++) { *(sp+i) = ' '; } } else if (OptionFound(args,sp,"--define")||OptionFound(args,sp,"-D")) { CfOut(cf_verbose,"","Attempt to activate a predefined role..\n"); if (!AuthorizeRoles(conn,sp)) { sprintf(sendbuffer,"You are not authorized to activate these classes/roles on host %s\n",VFQNAME); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); return; } } } snprintf(ebuff,CF_BUFSIZE,"%s --inform",CFRUNCOMMAND); if (strlen(ebuff)+strlen(args)+6 > CF_BUFSIZE) { snprintf(sendbuffer,CF_BUFSIZE,"Command line too long with args: %s\n",ebuff); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); return; } else { if ((args != NULL) && (strlen(args) > 0)) { strcat(ebuff," "); strncat(ebuff,args,CF_BUFSIZE-strlen(ebuff)); snprintf(sendbuffer,CF_BUFSIZE,"cf-serverd Executing %s\n",ebuff); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); } } CfOut(cf_inform,"","Executing command %s\n",ebuff); if ((pp = cf_popen_sh(ebuff,"r")) == NULL) { CfOut(cf_error,"pipe","Couldn't open pipe to command %s\n",ebuff); snprintf(sendbuffer,CF_BUFSIZE,"Unable to run %s\n",ebuff); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); return; } while (!feof(pp)) { if (ferror(pp)) { fflush(pp); break; } CfReadLine(line,CF_BUFSIZE,pp); if (ferror(pp)) { fflush(pp); break; } print = false; for (sp = line; *sp != '\0'; sp++) { if (! isspace((int)*sp)) { print = true; break; } } if (print) { snprintf(sendbuffer,CF_BUFSIZE,"%s\n",line); if (SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE) == -1) { CfOut(cf_error,"send","Sending failed, aborting"); break; } } } cf_pclose(pp); } /**************************************************************/ int GetCommand (char *str) { int i; char op[CF_BUFSIZE]; sscanf(str,"%4095s",op); for (i = 0; PROTOCOL[i] != NULL; i++) { if (strcmp(op,PROTOCOL[i])==0) { return i; } } return -1; } /*********************************************************************/ int VerifyConnection(struct cfd_connection *conn,char buf[CF_BUFSIZE]) /* Try reverse DNS lookup and RFC931 username lookup to check the authenticity. */ { char ipstring[CF_MAXVARSIZE], fqname[CF_MAXVARSIZE], username[CF_MAXVARSIZE]; char dns_assert[CF_MAXVARSIZE],ip_assert[CF_MAXVARSIZE]; int matched = false; struct passwd *pw; #if defined(HAVE_GETADDRINFO) struct addrinfo query, *response=NULL, *ap; int err; #else struct sockaddr_in raddr; int i,j,len = sizeof(struct sockaddr_in); struct hostent *hp = NULL; struct Item *ip_aliases = NULL, *ip_addresses = NULL; #endif Debug("Connecting host identifies itself as %s\n",buf); memset(ipstring,0,CF_MAXVARSIZE); memset(fqname,0,CF_MAXVARSIZE); memset(username,0,CF_MAXVARSIZE); sscanf(buf,"%255s %255s %255s",ipstring,fqname,username); Debug("(ipstring=[%s],fqname=[%s],username=[%s],socket=[%s])\n",ipstring,fqname,username,conn->ipaddr); ThreadLock(cft_system); strncpy(dns_assert,ToLowerStr(fqname),CF_MAXVARSIZE-1); strncpy(ip_assert,ipstring,CF_MAXVARSIZE-1); ThreadUnlock(cft_system); /* It only makes sense to check DNS by reverse lookup if the key had to be accepted on trust. Once we have a positive key ID, the IP address is irrelevant fr authentication... We can save a lot of time by not looking this up ... */ if ((conn->trust == false) || IsMatchItemIn(SKIPVERIFY,MapAddress(conn->ipaddr))) { CfOut(cf_verbose,"","Allowing %s to connect without (re)checking ID\n",ip_assert); CfOut(cf_verbose,"","Non-verified Host ID is %s (Using skipverify)\n",dns_assert); strncpy(conn->hostname,dns_assert,CF_MAXVARSIZE); CfOut(cf_verbose,"","Non-verified User ID seems to be %s (Using skipverify)\n",username); strncpy(conn->username,username,CF_MAXVARSIZE); #ifdef MINGW /* NT uses security identifier instead of uid */ if (!NovaWin_UserNameToSid(username, (SID *)conn->sid, CF_MAXSIDSIZE, false)) { memset(conn->sid, 0, CF_MAXSIDSIZE); /* is invalid sid - discarded */ } #else /* NOT MINGW */ if ((pw=getpwnam(username)) == NULL) /* Keep this inside mutex */ { conn->uid = -2; } else { conn->uid = pw->pw_uid; } #endif /* NOT MINGW */ return true; } if (strcmp(ip_assert,MapAddress(conn->ipaddr)) != 0) { CfOut(cf_verbose,"","IP address mismatch between client's assertion (%s) and socket (%s) - untrustworthy connection\n",ip_assert,conn->ipaddr); return false; } if (strlen(dns_assert) == 0) { CfOut(cf_verbose,"","DNS asserted name was empty - untrustworthy connection\n"); return false; } if (strcmp(dns_assert,"skipident") == 0) { CfOut(cf_verbose,"","DNS asserted name was withheld before key exchange - untrustworthy connection\n"); return false; } CfOut(cf_verbose,"","Socket caller address appears honest (%s matches %s)\n",ip_assert,MapAddress(conn->ipaddr)); CfOut(cf_verbose,"","Socket originates from %s=%s\n",ip_assert,dns_assert); Debug("Attempting to verify honesty by looking up hostname (%s)\n",dns_assert); /* Do a reverse DNS lookup, like tcp wrappers to see if hostname matches IP */ #if defined(HAVE_GETADDRINFO) Debug("Using v6 compatible lookup...\n"); memset(&query,0,sizeof(struct addrinfo)); query.ai_family = AF_UNSPEC; query.ai_socktype = SOCK_STREAM; query.ai_flags = AI_PASSIVE; if ((err=getaddrinfo(dns_assert,NULL,&query,&response)) != 0) { CfOut(cf_error,"","Unable to lookup %s (%s)",dns_assert,gai_strerror(err)); } for (ap = response; ap != NULL; ap = ap->ai_next) { ThreadLock(cft_getaddr); if (strcmp(MapAddress(conn->ipaddr),sockaddr_ntop(ap->ai_addr)) == 0) { Debug("Found match\n"); matched = true; } ThreadUnlock(cft_getaddr); } if (response != NULL) { freeaddrinfo(response); } #else Debug("IPV4 hostnname lookup on %s\n",dns_assert); ThreadLock(cft_getaddr); if ((hp = gethostbyname(dns_assert)) == NULL) { CfOut(cf_verbose,"","cf-serverd Couldn't look up name %s\n",fqname); CfOut(cf_log,"gethostbyname","DNS lookup of %s failed",dns_assert); matched = false; } else { matched = true; Debug("Looking for the peername of our socket...\n"); if (getpeername(conn->sd_reply,(struct sockaddr *)&raddr,&len) == -1) { CfOut(cf_error,"getpeername","Couldn't get socket address\n"); matched = false; } CfOut(cf_verbose,"","Looking through hostnames on socket with IPv4 %s\n",sockaddr_ntop((struct sockaddr *)&raddr)); for (i = 0; hp->h_addr_list[i]; i++) { CfOut(cf_verbose,"","Reverse lookup address found: %d\n",i); if (memcmp(hp->h_addr_list[i],(char *)&(raddr.sin_addr),sizeof(raddr.sin_addr)) == 0) { CfOut(cf_verbose,"","Canonical name matched host's assertion - id confirmed as %s\n",dns_assert); break; } } if (hp->h_addr_list[0] != NULL) { CfOut(cf_verbose,"","Checking address number %d for non-canonical names (aliases)\n",i); for (j = 0; hp->h_aliases[j] != NULL; j++) { CfOut(cf_verbose,"","Comparing [%s][%s]\n",hp->h_aliases[j],ip_assert); if (strcmp(hp->h_aliases[j],ip_assert) == 0) { CfOut(cf_verbose,"","Non-canonical name (alias) matched host's assertion - id confirmed as %s\n",dns_assert); break; } } if ((hp->h_addr_list[i] != NULL) && (hp->h_aliases[j] != NULL)) { CfOut(cf_log,"","Reverse hostname lookup failed, host claiming to be %s was %s\n",buf,sockaddr_ntop((struct sockaddr *)&raddr)); matched = false; } else { CfOut(cf_verbose,"","Reverse lookup succeeded\n"); } } else { CfOut(cf_log,"","No name was registered in DNS for %s - reverse lookup failed\n",dns_assert); matched = false; } } ThreadUnlock(cft_getaddr); #ifdef MINGW /* NT uses security identifier instead of uid */ if (!NovaWin_UserNameToSid(username, (SID *)conn->sid, CF_MAXSIDSIZE, false)) { memset(conn->sid, 0, CF_MAXSIDSIZE); /* is invalid sid - discarded */ } #else /* NOT MINGW */ if ((pw=getpwnam(username)) == NULL) /* Keep this inside mutex */ { conn->uid = -2; } else { conn->uid = pw->pw_uid; } #endif /* NOT MINGW */ #endif if (!matched) { CfOut(cf_log,"gethostbyname","Failed on DNS reverse lookup of %s\n",dns_assert); CfOut(cf_log,"","Client sent: %s",buf); return false; } CfOut(cf_verbose,"","Host ID is %s\n",dns_assert); strncpy(conn->hostname,dns_assert,CF_MAXVARSIZE-1); CfOut(cf_verbose,"","User ID seems to be %s\n",username); strncpy(conn->username,username,CF_MAXVARSIZE-1); return true; } /**************************************************************/ int AllowedUser(char *user) { if (IsItemIn(ALLOWUSERLIST,user)) { CfOut(cf_verbose,"","User %s granted connection privileges\n",user); return true; } CfOut(cf_verbose,"","User %s is not allowed on this server\n",user); return false; } /**************************************************************/ /* 'resolved' argument needs to be at least CF_BUFSIZE long */ static bool ResolveFilename(const char *req_path, char *res_path) { char req_dir[CF_BUFSIZE]; char req_filename[CF_BUFSIZE]; /* * Eliminate symlinks from path, but do not resolve the file itself if it is a * symlink. */ strlcpy(req_dir, req_path, CF_BUFSIZE); ChopLastNode(req_dir); strlcpy(req_filename, ReadLastNode(req_path), CF_BUFSIZE); #if defined HAVE_REALPATH && !defined NT if (realpath(req_dir,res_path) == NULL) { return false; } #else memset(res_path,0,CF_BUFSIZE); CompressPath(res_path,req_dir); #endif AddSlash(res_path); strlcat(res_path, req_filename, CF_BUFSIZE); /* Adjust for forward slashes */ MapName(res_path); /* NT has case-insensitive path names */ #ifdef MINGW int i; for (i = 0; i < strlen(res_path); i++) { res_path[i] = ToLower(res_path[i]); } #endif /* MINGW */ return true; } /**************************************************************/ int AccessControl(const char *req_path,struct cfd_connection *conn,int encrypt,struct Auth *vadmit, struct Auth *vdeny) { struct Auth *ap; int access = false; char transrequest[CF_BUFSIZE]; struct stat statbuf; char translated_req_path[CF_BUFSIZE]; char transpath[CF_BUFSIZE]; Debug("AccessControl(%s)\n",req_path); /* * /var/cfengine -> $workdir translation. */ TranslatePath(translated_req_path,req_path); if (ResolveFilename(translated_req_path, transrequest)) { CfOut(cf_verbose, "", "Filename %s is resolved to %s", translated_req_path, transrequest); } else { CfOut(cf_verbose,"lstat","Couldn't resolve filename %s from host %s\n",translated_req_path,conn->hostname); } if (lstat(transrequest,&statbuf) == -1) { CfOut(cf_verbose,"lstat","Couldn't stat filename %s requested by host %s\n",transrequest,conn->hostname); return false; } Debug("AccessControl, match(%s,%s) encrypt request=%d\n",transrequest,conn->hostname,encrypt); if (vadmit == NULL) { CfOut(cf_verbose,"","cf-serverd access list is empty, no files are visible\n"); return false; } conn->maproot = false; for (ap = vadmit; ap != NULL; ap=ap->next) { int res = false; Debug("Examining rule in access list (%s,%s)?\n",transrequest,ap->path); strncpy(transpath,ap->path,CF_BUFSIZE-1); MapName(transpath); if ((strlen(transrequest) > strlen(transpath)) && strncmp(transpath,transrequest,strlen(transpath)) == 0 && transrequest[strlen(transpath)] == FILE_SEPARATOR) { res = true; /* Substring means must be a / to link, else just a substring og filename */ } /* Exact match means single file to admit */ if (strcmp(transpath,transrequest) == 0) { res = true; } if (strcmp(transpath,"/") == 0) { res = true; } if (res) { CfOut(cf_verbose,"","Found a matching rule in access list (%s in %s)\n",transrequest,transpath); if (cfstat(transpath,&statbuf) == -1) { CfOut(cf_log,"","Warning cannot stat file object %s in admit/grant, or access list refers to dangling link\n",transpath); continue; } if (!encrypt && (ap->encrypt == true)) { CfOut(cf_error,"","File %s requires encrypt connection...will not serve\n",transpath); access = false; } else { Debug("Checking whether to map root privileges..\n"); if (IsMatchItemIn(ap->maproot,MapAddress(conn->ipaddr)) || IsRegexItemIn(ap->maproot,conn->hostname)) { conn->maproot = true; CfOut(cf_verbose,"","Mapping root privileges to access non-root files\n"); } if (IsMatchItemIn(ap->accesslist,MapAddress(conn->ipaddr)) || IsRegexItemIn(ap->accesslist,conn->hostname)) { access = true; Debug("Access privileges - match found\n"); } } break; } } if (strncmp(transpath,transrequest,strlen(transpath)) == 0) { for (ap = vdeny; ap != NULL; ap=ap->next) { if (IsRegexItemIn(ap->accesslist,conn->hostname)) { access = false; CfOut(cf_verbose,"","Host %s explicitly denied access to %s\n",conn->hostname,transrequest); break; } } } if (access) { CfOut(cf_verbose,"","Host %s granted access to %s\n",conn->hostname,req_path); if (encrypt && LOGENCRYPT) { /* Log files that were marked as requiring encryption */ CfOut(cf_log,"","Host %s granted access to %s\n",conn->hostname,req_path); } } else { CfOut(cf_verbose,"","Host %s denied access to %s\n",conn->hostname,req_path); } if (!conn->rsa_auth) { CfOut(cf_verbose,"","Cannot map root access without RSA authentication"); conn->maproot = false; /* only public files accessible */ /* return false; */ } return access; } /**************************************************************/ int LiteralAccessControl(char *in,struct cfd_connection *conn,int encrypt,struct Auth *vadmit, struct Auth *vdeny) { struct Auth *ap; int access = false; char name[CF_BUFSIZE]; name[0] = '\0'; if (strncmp(in,"VAR",3) == 0) { sscanf(in,"VAR %255[^\n]",name); } else { sscanf(in,"QUERY %128s",name); } Debug("\n\nLiteralAccessControl(%s)\n",name); conn->maproot = false; for (ap = vadmit; ap != NULL; ap=ap->next) { int res = false; CfOut(cf_verbose,"","Examining rule in access list (%s,%s)?\n",name,ap->path); if (strcmp(ap->path,name) == 0) { res = true; /* Exact match means single file to admit */ } if (res) { CfOut(cf_verbose,"","Found a matching rule in access list (%s in %s)\n",name,ap->path); if (ap->literal == false) { CfOut(cf_error,"","Variable/query \"%s\" requires a literal server item...cannot set variable directly by path\n",ap->path); access = false; break; } if (!encrypt && (ap->encrypt == true)) { CfOut(cf_error,"","Variable %s requires encrypt connection...will not serve\n",name); access = false; break; } else { Debug("Checking whether to map root privileges..\n"); if (IsMatchItemIn(ap->maproot,MapAddress(conn->ipaddr)) || IsRegexItemIn(ap->maproot,conn->hostname)) { conn->maproot = true; CfOut(cf_verbose,"","Mapping root privileges\n"); } else { CfOut(cf_verbose,"","No root privileges granted\n"); } if (IsMatchItemIn(ap->accesslist,MapAddress(conn->ipaddr)) || IsRegexItemIn(ap->accesslist,conn->hostname)) { access = true; Debug("Access privileges - match found\n"); } } } } for (ap = vdeny; ap != NULL; ap=ap->next) { if (strcmp(ap->path,name) == 0) { if (IsMatchItemIn(ap->accesslist,MapAddress(conn->ipaddr)) || IsRegexItemIn(ap->accesslist,conn->hostname)) { access = false; CfOut(cf_verbose,"","Host %s explicitly denied access to %s\n",conn->hostname,name); break; } } } if (access) { CfOut(cf_verbose,"","Host %s granted access to literal \"%s\"\n",conn->hostname,name); if (encrypt && LOGENCRYPT) { /* Log files that were marked as requiring encryption */ CfOut(cf_log,"","Host %s granted access to literal \"%s\"\n",conn->hostname,name); } } else { CfOut(cf_verbose,"","Host %s denied access to literal \"%s\"\n",conn->hostname,name); } if (!conn->rsa_auth) { CfOut(cf_verbose,"","Cannot map root access without RSA authentication"); conn->maproot = false; /* only public files accessible */ /* return false; */ } return access; } /**************************************************************/ struct Item *ContextAccessControl(char *in,struct cfd_connection *conn,int encrypt,struct Auth *vadmit, struct Auth *vdeny) { struct Auth *ap; int access = false; char client_regex[CF_BUFSIZE]; CF_DB *dbp; CF_DBC *dbcp; int ksize,vsize; char *key; void *value; time_t now = time(NULL); struct CfState q; struct Item *ip,*matches = NULL, *candidates = NULL; char filename[CF_BUFSIZE]; sscanf(in,"CONTEXT %255[^\n]",client_regex); Debug("\n\nContextAccessControl(%s)\n",client_regex); snprintf(filename,CF_BUFSIZE,"%s%cstate%c%s",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR,CF_STATEDB_FILE); if (!OpenDB(filename,&dbp)) { return NULL; } /* Acquire a cursor for the database. */ if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan persistence cache"); return NULL; } while(NextDB(dbp,dbcp,&key,&ksize,&value,&vsize)) { memcpy((void *)&q,value,sizeof(struct CfState)); if (now > q.expires) { CfOut(cf_verbose,""," Persistent class %s expired\n",key); DeleteDB(dbp,key); } else { if (FullTextMatch(client_regex,key)) { CfOut(cf_verbose,""," - Found key %s...\n",key); AppendItem(&candidates,key,NULL); } } } DeleteDBCursor(dbp,dbcp); CloseDB(dbp); for (ip = candidates; ip != NULL; ip=ip->next) { for (ap = vadmit; ap != NULL; ap=ap->next) { int res = false; if (FullTextMatch(ap->path,ip->name) == 0) { res = true; } if (res) { CfOut(cf_verbose,"","Found a matching rule in access list (%s in %s)\n",ip->name,ap->path); if (ap->classpattern == false) { CfOut(cf_error,"","Context %s requires a literal server item...cannot set variable directly by path\n",ap->path); access = false; continue; } if (!encrypt && (ap->encrypt == true)) { CfOut(cf_error,"","Context %s requires encrypt connection...will not serve\n",ip->name); access = false; break; } else { Debug("Checking whether to map root privileges..\n"); if (IsMatchItemIn(ap->maproot,MapAddress(conn->ipaddr)) || IsRegexItemIn(ap->maproot,conn->hostname)) { conn->maproot = true; CfOut(cf_verbose,"","Mapping root privileges\n"); } else { CfOut(cf_verbose,"","No root privileges granted\n"); } if (IsMatchItemIn(ap->accesslist,MapAddress(conn->ipaddr)) || IsRegexItemIn(ap->accesslist,conn->hostname)) { access = true; Debug("Access privileges - match found\n"); } } } } for (ap = vdeny; ap != NULL; ap=ap->next) { if (strcmp(ap->path,ip->name) == 0) { if (IsMatchItemIn(ap->accesslist,MapAddress(conn->ipaddr)) || IsRegexItemIn(ap->accesslist,conn->hostname)) { access = false; CfOut(cf_verbose,"","Host %s explicitly denied access to context %s\n",conn->hostname,ip->name); break; } } } if (access) { CfOut(cf_verbose,"","Host %s granted access to context \"%s\"\n",conn->hostname,ip->name); AppendItem(&matches,ip->name,NULL); if (encrypt && LOGENCRYPT) { /* Log files that were marked as requiring encryption */ CfOut(cf_log,"","Host %s granted access to context \"%s\"\n",conn->hostname,ip->name); } } else { CfOut(cf_verbose,"","Host %s denied access to context \"%s\"\n",conn->hostname,ip->name); } } DeleteItemList(candidates); return matches; } /**************************************************************/ int AuthorizeRoles(struct cfd_connection *conn,char *args) { char *sp; struct Auth *ap; char userid1[CF_MAXVARSIZE],userid2[CF_MAXVARSIZE]; struct Rlist *rp,*defines = NULL; int permitted = false; snprintf(userid1,CF_MAXVARSIZE,"%s@%s",conn->username,conn->hostname); snprintf(userid2,CF_MAXVARSIZE,"%s@%s",conn->username,conn->ipaddr); CfOut(cf_verbose,"","Checking authorized roles in %s\n",args); if (strncmp(args,"--define",strlen("--define")) == 0) { sp = args + strlen("--define"); } else { sp = args + strlen("-D"); } while (*sp == ' ') { sp++; } defines = SplitRegexAsRList(sp,"[,:;]",99,false); /* For each user-defined class attempt, check RBAC */ for (rp = defines; rp != NULL; rp = rp->next) { CfOut(cf_verbose,""," -> Verifying %s\n",rp->item); for (ap = ROLES; ap != NULL; ap=ap->next) { if (FullTextMatch(ap->path,rp->item)) { /* We have a pattern covering this class - so are we allowed to activate it? */ if (IsMatchItemIn(ap->accesslist,MapAddress(conn->ipaddr)) || IsRegexItemIn(ap->accesslist,conn->hostname) || IsRegexItemIn(ap->accesslist,userid1) || IsRegexItemIn(ap->accesslist,userid2) || IsRegexItemIn(ap->accesslist,conn->username) ) { CfOut(cf_verbose,"","Attempt to define role/class %s is permitted\n",rp->item); permitted = true; } else { CfOut(cf_verbose,"","Attempt to define role/class %s is denied\n",rp->item); DeleteRlist(defines); return false; } } } } if (permitted) { CfOut(cf_verbose,"","Role activation allowed\n"); } else { CfOut(cf_verbose,"","Role activation disallowed - abort execution\n"); } DeleteRlist(defines); return permitted; } /**************************************************************/ int AuthenticationDialogue(struct cfd_connection *conn,char *recvbuffer, int recvlen) { char in[CF_BUFSIZE],*out, *decrypted_nonce; BIGNUM *counter_challenge = NULL; unsigned char digest[EVP_MAX_MD_SIZE+1] = {0}; unsigned int crypt_len, nonce_len = 0,encrypted_len = 0; char sauth[10], iscrypt ='n',enterprise_field = 'c'; int len_n = 0,len_e = 0,keylen, session_size; unsigned long err; RSA *newkey; int digestLen = 0; enum cfhashes digestType; if (PRIVKEY == NULL || PUBKEY == NULL) { CfOut(cf_error,"","No public/private key pair exists, create one with cf-key\n"); return false; } if(FIPS_MODE) { digestType = CF_DEFAULT_DIGEST; digestLen = CF_DEFAULT_DIGEST_LEN; } else { digestType = cf_md5; digestLen = CF_MD5_LEN; } /* proposition C1 */ /* Opening string is a challenge from the client (some agent) */ sauth[0] = '\0'; sscanf(recvbuffer,"%s %c %u %u %c",sauth,&iscrypt,&crypt_len,&nonce_len,&enterprise_field); if (crypt_len == 0 || nonce_len == 0 || strlen(sauth) == 0) { CfOut(cf_inform,"","Protocol format error in authentation from IP %s\n",conn->hostname); return false; } if (nonce_len > CF_NONCELEN*2) { CfOut(cf_inform,"","Protocol deviant authentication nonce from %s\n",conn->hostname); return false; } if (crypt_len > 2*CF_NONCELEN) { CfOut(cf_inform,"","Protocol abuse in unlikely cipher from %s\n",conn->hostname); return false; } /* Check there is no attempt to read past the end of the received input */ if (recvbuffer+CF_RSA_PROTO_OFFSET+nonce_len > recvbuffer+recvlen) { CfOut(cf_inform,"","Protocol consistency error in authentication from %s\n",conn->hostname); return false; } if ((strcmp(sauth,"SAUTH") != 0) || (nonce_len == 0) || (crypt_len == 0)) { CfOut(cf_inform,"","Protocol error in RSA authentication from IP %s\n",conn->hostname); return false; } Debug("Challenge encryption = %c, nonce = %d, buf = %d\n",iscrypt,nonce_len,crypt_len); ThreadLock(cft_system); if ((decrypted_nonce = malloc(crypt_len)) == NULL) { FatalError("memory failure"); } if (iscrypt == 'y') { if (RSA_private_decrypt(crypt_len,recvbuffer+CF_RSA_PROTO_OFFSET,decrypted_nonce,PRIVKEY,RSA_PKCS1_PADDING) <= 0) { err = ERR_get_error(); ThreadUnlock(cft_system); CfOut(cf_error,"","Private decrypt failed = %s\n",ERR_reason_error_string(err)); free(decrypted_nonce); return false; } } else { if (nonce_len > crypt_len) { ThreadUnlock(cft_system); CfOut(cf_error,"","Illegal challenge\n"); free(decrypted_nonce); return false; } memcpy(decrypted_nonce,recvbuffer+CF_RSA_PROTO_OFFSET,nonce_len); } ThreadUnlock(cft_system); /* Client's ID is now established by key or trusted, reply with digest */ HashString(decrypted_nonce,nonce_len,digest,digestType); free(decrypted_nonce); /* Get the public key from the client */ ThreadLock(cft_system); newkey = RSA_new(); ThreadUnlock(cft_system); /* proposition C2 */ if ((len_n = ReceiveTransaction(conn->sd_reply,recvbuffer,NULL)) == -1) { CfOut(cf_inform,"","Protocol error 1 in RSA authentation from IP %s\n",conn->hostname); RSA_free(newkey); return false; } if (len_n == 0) { CfOut(cf_inform,"","Protocol error 2 in RSA authentation from IP %s\n",conn->hostname); RSA_free(newkey); return false; } if ((newkey->n = BN_mpi2bn(recvbuffer,len_n,NULL)) == NULL) { err = ERR_get_error(); CfOut(cf_error,"","Private decrypt failed = %s\n",ERR_reason_error_string(err)); RSA_free(newkey); return false; } /* proposition C3 */ if ((len_e = ReceiveTransaction(conn->sd_reply,recvbuffer,NULL)) == -1) { CfOut(cf_inform,"","Protocol error 3 in RSA authentation from IP %s\n",conn->hostname); RSA_free(newkey); return false; } if (len_e == 0) { CfOut(cf_inform,"","Protocol error 4 in RSA authentation from IP %s\n",conn->hostname); RSA_free(newkey); return false; } if ((newkey->e = BN_mpi2bn(recvbuffer,len_e,NULL)) == NULL) { err = ERR_get_error(); CfOut(cf_error,"","Private decrypt failed = %s\n",ERR_reason_error_string(err)); RSA_free(newkey); return false; } if (DEBUG||D2) { RSA_print_fp(stdout,newkey,0); } HashPubKey(newkey,conn->digest,CF_DEFAULT_DIGEST); if (VERBOSE) { ThreadLock(cft_output); CfOut(cf_verbose,""," -> Public key identity of host \"%s\" is \"%s\"",conn->ipaddr,HashPrint(CF_DEFAULT_DIGEST,conn->digest)); ThreadUnlock(cft_output); } LastSaw(conn->username,conn->ipaddr,conn->digest,cf_accept); if (!CheckStoreKey(conn,newkey)) /* conceals proposition S1 */ { if (!conn->trust) { RSA_free(newkey); return false; } } /* Reply with digest of original challenge */ /* proposition S2 */ SendTransaction(conn->sd_reply,digest,digestLen,CF_DONE); /* Send counter challenge to be sure this is a live session */ ThreadLock(cft_system); counter_challenge = BN_new(); BN_rand(counter_challenge,CF_NONCELEN,0,0); nonce_len = BN_bn2mpi(counter_challenge,in); // hash the challenge from the client HashString(in,nonce_len,digest,digestType); encrypted_len = RSA_size(newkey); /* encryption buffer is always the same size as n */ if ((out = malloc(encrypted_len+1)) == NULL) { FatalError("memory failure"); } if (RSA_public_encrypt(nonce_len,in,out,newkey,RSA_PKCS1_PADDING) <= 0) { err = ERR_get_error(); CfOut(cf_error,"","Public encryption failed = %s\n",ERR_reason_error_string(err)); RSA_free(newkey); free(out); return false; } ThreadUnlock(cft_system); /* proposition S3 */ SendTransaction(conn->sd_reply,out,encrypted_len,CF_DONE); /* if the client doesn't have our public key, send it */ if (iscrypt != 'y') { /* proposition S4 - conditional */ memset(in,0,CF_BUFSIZE); len_n = BN_bn2mpi(PUBKEY->n,in); SendTransaction(conn->sd_reply,in,len_n,CF_DONE); /* proposition S5 - conditional */ memset(in,0,CF_BUFSIZE); len_e = BN_bn2mpi(PUBKEY->e,in); SendTransaction(conn->sd_reply,in,len_e,CF_DONE); } /* Receive reply to counter_challenge */ /* proposition C4 */ memset(in,0,CF_BUFSIZE); if (ReceiveTransaction(conn->sd_reply,in,NULL) == -1) { BN_free(counter_challenge); free(out); RSA_free(newkey); return false; } if (HashesMatch(digest,in,digestType)) /* replay / piggy in the middle attack ? */ { if (!conn->trust) { CfOut(cf_verbose,""," -> Strong authentication of client %s/%s achieved",conn->hostname,conn->ipaddr); } else { CfOut(cf_verbose,""," -> Weak authentication of trusted client %s/%s (key accepted on trust).\n",conn->hostname,conn->ipaddr); } } else { BN_free(counter_challenge); free(out); RSA_free(newkey); CfOut(cf_inform,"","Challenge response from client %s was incorrect - ID false?",conn->ipaddr); return false; } /* Receive random session key,... */ /* proposition C5 */ memset(in,0,CF_BUFSIZE); if ((keylen = ReceiveTransaction(conn->sd_reply,in,NULL)) == -1) { BN_free(counter_challenge); free(out); RSA_free(newkey); return false; } if (keylen > CF_BUFSIZE/2) { BN_free(counter_challenge); free(out); RSA_free(newkey); CfOut(cf_inform,"","Session key length received from %s is too long",conn->ipaddr); return false; } ThreadLock(cft_system); session_size = CfSessionKeySize(enterprise_field); conn->session_key = malloc(session_size); conn->encryption_type = enterprise_field; if (conn->session_key == NULL) { BN_free(counter_challenge); free(out); RSA_free(newkey); return false; } CfOut(cf_verbose,""," -> Receiving session key from client (size=%d)...", keylen); Debug("keylen=%d, session_size=%d\n", keylen, session_size); if (keylen == CF_BLOWFISHSIZE) /* Support the old non-ecnrypted for upgrade */ { memcpy(conn->session_key,in,session_size); } else { /* New protocol encrypted */ if (RSA_private_decrypt(keylen,in,out,PRIVKEY,RSA_PKCS1_PADDING) <= 0) { ThreadUnlock(cft_system); err = ERR_get_error(); CfOut(cf_error,"","Private decrypt failed = %s\n",ERR_reason_error_string(err)); return false; } memcpy(conn->session_key,out,session_size); } ThreadUnlock(cft_system); //DebugBinOut(conn->session_key,session_size,"Session key received"); BN_free(counter_challenge); free(out); RSA_free(newkey); conn->rsa_auth = true; return true; } /**************************************************************/ int StatFile(struct cfd_connection *conn,char *sendbuffer,char *ofilename) /* Because we do not know the size or structure of remote datatypes,*/ /* the simplest way to transfer the data is to convert them into */ /* plain text and interpret them on the other side. */ { struct cfstat cfst; struct stat statbuf,statlinkbuf; char linkbuf[CF_BUFSIZE],filename[CF_BUFSIZE]; int islink = false; Debug("\nStatFile(%s)\n",filename); TranslatePath(filename,ofilename); memset(&cfst,0,sizeof(struct cfstat)); if (strlen(ReadLastNode(filename)) > CF_MAXLINKSIZE) { snprintf(sendbuffer,CF_BUFSIZE*2,"BAD: Filename suspiciously long [%s]\n",filename); CfOut(cf_error,"",sendbuffer); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); return -1; } if (lstat(filename,&statbuf) == -1) { snprintf(sendbuffer,CF_BUFSIZE,"BAD: unable to stat file %s",filename); CfOut(cf_verbose,"lstat",sendbuffer); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); return -1; } cfst.cf_readlink = NULL; cfst.cf_lmode = 0; cfst.cf_nlink = CF_NOSIZE; memset(linkbuf,0,CF_BUFSIZE); #ifndef MINGW // windows doesn't support symbolic links if (S_ISLNK(statbuf.st_mode)) { islink = true; cfst.cf_type = cf_link; /* pointless - overwritten */ cfst.cf_lmode = statbuf.st_mode & 07777; cfst.cf_nlink = statbuf.st_nlink; if (readlink(filename,linkbuf,CF_BUFSIZE-1) == -1) { sprintf(sendbuffer,"BAD: unable to read link\n"); CfOut(cf_error,"readlink",sendbuffer); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); return -1; } Debug("readlink: %s\n",linkbuf); cfst.cf_readlink = linkbuf; } #endif /* NOT MINGW */ if (!islink && (cfstat(filename,&statbuf) == -1)) { CfOut(cf_verbose,"stat","BAD: unable to stat file %s\n",filename); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); return -1; } Debug("Getting size of link deref %s\n",linkbuf); if (islink && (cfstat(filename,&statlinkbuf) != -1)) /* linktype=copy used by agent */ { statbuf.st_size = statlinkbuf.st_size; statbuf.st_mode = statlinkbuf.st_mode; statbuf.st_uid = statlinkbuf.st_uid; statbuf.st_gid = statlinkbuf.st_gid; statbuf.st_mtime = statlinkbuf.st_mtime; statbuf.st_ctime = statlinkbuf.st_ctime; } if (S_ISDIR(statbuf.st_mode)) { cfst.cf_type = cf_dir; } if (S_ISREG(statbuf.st_mode)) { cfst.cf_type = cf_reg; } if (S_ISSOCK(statbuf.st_mode)) { cfst.cf_type = cf_sock; } if (S_ISCHR(statbuf.st_mode)) { cfst.cf_type = cf_char; } if (S_ISBLK(statbuf.st_mode)) { cfst.cf_type = cf_block; } if (S_ISFIFO(statbuf.st_mode)) { cfst.cf_type = cf_fifo; } cfst.cf_mode = statbuf.st_mode & 07777; cfst.cf_uid = statbuf.st_uid & 0xFFFFFFFF; cfst.cf_gid = statbuf.st_gid & 0xFFFFFFFF; cfst.cf_size = statbuf.st_size; cfst.cf_atime = statbuf.st_atime; cfst.cf_mtime = statbuf.st_mtime; cfst.cf_ctime = statbuf.st_ctime; cfst.cf_ino = statbuf.st_ino; cfst.cf_dev = statbuf.st_dev; cfst.cf_readlink = linkbuf; if (cfst.cf_nlink == CF_NOSIZE) { cfst.cf_nlink = statbuf.st_nlink; } #if !defined(IRIX) && !defined(MINGW) if (statbuf.st_size > statbuf.st_blocks * DEV_BSIZE) #else # ifdef HAVE_ST_BLOCKS if (statbuf.st_size > statbuf.st_blocks * DEV_BSIZE) # else if (statbuf.st_size > ST_NBLOCKS(statbuf) * DEV_BSIZE) # endif #endif { cfst.cf_makeholes = 1; /* must have a hole to get checksum right */ } else { cfst.cf_makeholes = 0; } memset(sendbuffer,0,CF_BUFSIZE); /* send as plain text */ Debug("OK: type=%d\n mode=%o\n lmode=%o\n uid=%d\n gid=%d\n size=%ld\n atime=%d\n mtime=%d\n", cfst.cf_type,cfst.cf_mode,cfst.cf_lmode,cfst.cf_uid,cfst.cf_gid,(long)cfst.cf_size, cfst.cf_atime,cfst.cf_mtime); snprintf(sendbuffer,CF_BUFSIZE,"OK: %d %d %d %d %d %ld %d %d %d %d %d %d %d", cfst.cf_type,cfst.cf_mode,cfst.cf_lmode,cfst.cf_uid,cfst.cf_gid,(long)cfst.cf_size, cfst.cf_atime,cfst.cf_mtime,cfst.cf_ctime,cfst.cf_makeholes,cfst.cf_ino, cfst.cf_nlink,cfst.cf_dev); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); memset(sendbuffer,0,CF_BUFSIZE); if (cfst.cf_readlink != NULL) { strcpy(sendbuffer,"OK:"); strcat(sendbuffer,cfst.cf_readlink); } else { sprintf(sendbuffer,"OK:"); } SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); return 0; } /***************************************************************/ void CfGetFile(struct cfd_get_arg *args) { int sd,fd,n_read,total=0,sendlen=0,count = 0; char sendbuffer[CF_BUFSIZE+256],filename[CF_BUFSIZE]; struct stat sb; int blocksize = 2048; char *key; sd = (args->connect)->sd_reply; key = (args->connect)->session_key; TranslatePath(filename,args->replyfile); cfstat(filename,&sb); Debug("CfGetFile(%s on sd=%d), size=%d\n",filename,sd,sb.st_size); /* Now check to see if we have remote permission */ if (!TransferRights(filename,sd,args,sendbuffer,&sb)) { RefuseAccess(args->connect,sendbuffer,args->buf_size,""); snprintf(sendbuffer,CF_BUFSIZE,"%s",CF_FAILEDSTR); SendSocketStream(sd,sendbuffer,args->buf_size,0); } /* File transfer */ if ((fd = SafeOpen(filename)) == -1) { CfOut(cf_error,"open","Open error of file [%s]\n",filename); snprintf(sendbuffer,CF_BUFSIZE,"%s",CF_FAILEDSTR); SendSocketStream(sd,sendbuffer,args->buf_size,0); } else { while(true) { memset(sendbuffer,0,CF_BUFSIZE); Debug("Now reading from disk...\n"); if ((n_read = read(fd,sendbuffer,blocksize)) == -1) { CfOut(cf_error,"read","read failed in GetFile"); break; } if (n_read == 0) { break; } else { int savedlen = sb.st_size; /* check the file is not changing at source */ if (count++ % 3 == 0) /* Don't do this too often */ { stat(filename,&sb); } if (sb.st_size != savedlen) { snprintf(sendbuffer,CF_BUFSIZE,"%s%s: %s",CF_CHANGEDSTR1,CF_CHANGEDSTR2,filename); if (SendSocketStream(sd,sendbuffer,blocksize,0) == -1) { CfOut(cf_verbose,"send","Send failed in GetFile"); } Debug("Aborting transfer after %d: file is changing rapidly at source.\n",total); break; } if ((savedlen - total)/blocksize > 0) { sendlen = blocksize; } else if (savedlen != 0) { sendlen = (savedlen - total); } } total += n_read; if (SendSocketStream(sd,sendbuffer,sendlen,0) == -1) { CfOut(cf_verbose,"send","Send failed in GetFile"); break; } } close(fd); } Debug("Done with GetFile()\n"); } /***************************************************************/ void CfEncryptGetFile(struct cfd_get_arg *args) /* Because the stream doesn't end for each file, we need to know the exact number of bytes transmitted, which might change during encryption, hence we need to handle this with transactions */ { int sd,fd,n_read,total=0,cipherlen,count = 0,finlen,cnt = 0; char sendbuffer[CF_BUFSIZE+256],out[CF_BUFSIZE],filename[CF_BUFSIZE]; unsigned char iv[32] = {1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8}; int blocksize = CF_BUFSIZE - 4*CF_INBAND_OFFSET; EVP_CIPHER_CTX ctx; char *key,enctype; struct stat sb; int savedlen; sd = (args->connect)->sd_reply; key = (args->connect)->session_key; enctype = (args->connect)->encryption_type; TranslatePath(filename,args->replyfile); cfstat(filename,&sb); Debug("CfEncryptGetFile(%s on sd=%d), size=%d\n",filename,sd,sb.st_size); /* Now check to see if we have remote permission */ if (!TransferRights(filename,sd,args,sendbuffer,&sb)) { RefuseAccess(args->connect,sendbuffer,args->buf_size,""); FailedTransfer(sd,sendbuffer,filename); } EVP_CIPHER_CTX_init(&ctx); if ((fd = SafeOpen(filename)) == -1) { CfOut(cf_error,"open","Open error of file [%s]\n",filename); FailedTransfer(sd,sendbuffer,filename); } else { while(true) { memset(sendbuffer,0,CF_BUFSIZE); if ((n_read = read(fd,sendbuffer,blocksize)) == -1) { CfOut(cf_error,"read","read failed in EncryptGetFile"); break; } savedlen = sb.st_size; if (count++ % 3 == 0) /* Don't do this too often */ { Debug("Restatting %s - size %d\n",filename,n_read); stat(filename,&sb); } if (sb.st_size != savedlen) { AbortTransfer(sd,sendbuffer,filename); break; } total += n_read; if (n_read > 0) { EVP_EncryptInit_ex(&ctx,CfengineCipher(enctype),NULL,key,iv); if (!EVP_EncryptUpdate(&ctx,out,&cipherlen,sendbuffer,n_read)) { FailedTransfer(sd,sendbuffer,filename); EVP_CIPHER_CTX_cleanup(&ctx); close(fd); return; } if (!EVP_EncryptFinal_ex(&ctx,out+cipherlen,&finlen)) { FailedTransfer(sd,sendbuffer,filename); EVP_CIPHER_CTX_cleanup(&ctx); close(fd); return; } } cnt++; //if (n_read < blocksize) // Last transaction if (total >= savedlen) { if (SendTransaction(sd,out,cipherlen+finlen,CF_DONE) == -1) { CfOut(cf_verbose,"send","Send failed in GetFile"); EVP_CIPHER_CTX_cleanup(&ctx); close(fd); return; } break; } else { if (SendTransaction(sd,out,cipherlen+finlen,CF_MORE) == -1) { CfOut(cf_verbose,"send","Send failed in GetFile"); close(fd); EVP_CIPHER_CTX_cleanup(&ctx); return; } } } } EVP_CIPHER_CTX_cleanup(&ctx); close(fd); } /**************************************************************/ void CompareLocalHash(struct cfd_connection *conn,char *sendbuffer,char *recvbuffer) { unsigned char digest1[EVP_MAX_MD_SIZE+1],digest2[EVP_MAX_MD_SIZE+1]; char filename[CF_BUFSIZE],rfilename[CF_BUFSIZE]; char *sp; int i; /* TODO - when safe change this proto string to sha2 */ sscanf(recvbuffer,"MD5 %255[^\n]",rfilename); sp = recvbuffer + strlen(recvbuffer) + CF_SMALL_OFFSET; for (i = 0; i < CF_DEFAULT_DIGEST_LEN; i++) { digest1[i] = *sp++; } memset(sendbuffer,0,CF_BUFSIZE); TranslatePath(filename,rfilename); HashFile(filename,digest2,CF_DEFAULT_DIGEST); if (HashesMatch(digest1,digest2,CF_DEFAULT_DIGEST) || HashesMatch(digest1,digest2,cf_md5)) { sprintf(sendbuffer,"%s",CFD_FALSE); Debug("Hashes matched ok\n"); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); } else { sprintf(sendbuffer,"%s",CFD_TRUE); Debug("Hashes didn't match\n"); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); } } /**************************************************************/ void GetServerLiteral(struct cfd_connection *conn,char *sendbuffer,char *recvbuffer,int encrypted) { char handle[CF_BUFSIZE],out[CF_BUFSIZE]; int cipherlen; sscanf(recvbuffer,"VAR %255[^\n]",handle); if (ReturnLiteralData(handle,out)) { memset(sendbuffer,0,CF_BUFSIZE); snprintf(sendbuffer,CF_BUFSIZE-1,"%s",out); } else { memset(sendbuffer,0,CF_BUFSIZE); snprintf(sendbuffer,CF_BUFSIZE-1,"BAD: Not found"); } if (encrypted) { cipherlen = EncryptString(conn->encryption_type,sendbuffer,out,conn->session_key,strlen(sendbuffer)+1); SendTransaction(conn->sd_reply,out,cipherlen,CF_DONE); } else { SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); } } /********************************************************************/ int GetServerQuery(struct cfd_connection *conn,char *sendbuffer,char *recvbuffer) { char query[CF_BUFSIZE]; query[0] = '\0'; sscanf(recvbuffer,"QUERY %255[^\n]",query); if (strlen(query) == 0) { return false; } #ifdef HAVE_CONSTELLATION if (cf_strncmp(query,"relay",5) == 0) { return Constellation_ReturnRelayQueryData(conn,query,sendbuffer); } #endif #ifdef HAVE_NOVA return Nova_ReturnQueryData(conn,query); #else return false; #endif } /**************************************************************/ void ReplyServerContext(struct cfd_connection *conn,char *sendbuffer,char *recvbuffer,int encrypted,struct Item *classes) { char out[CF_BUFSIZE]; int cipherlen; struct Item *ip; memset(sendbuffer,0,CF_BUFSIZE); for (ip = classes; ip != NULL; ip=ip->next) { if (strlen(sendbuffer) + strlen(ip->name) < CF_BUFSIZE-3) { strcat(sendbuffer,ip->name); strcat(sendbuffer,","); } else { CfOut(cf_error,""," !! Overflow in context grab"); break; } } DeleteItemList(classes); if (encrypted) { cipherlen = EncryptString(conn->encryption_type,sendbuffer,out,conn->session_key,strlen(sendbuffer)+1); SendTransaction(conn->sd_reply,out,cipherlen,CF_DONE); } else { SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); } } /**************************************************************/ int CfOpenDirectory(struct cfd_connection *conn,char *sendbuffer,char *oldDirname) { CFDIR *dirh; const struct dirent *dirp; int offset; char dirname[CF_BUFSIZE]; TranslatePath(dirname, oldDirname); Debug("CfOpenDirectory(%s)\n",dirname); if (!IsAbsoluteFileName(dirname)) { sprintf(sendbuffer,"BAD: request to access a non-absolute filename\n"); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); return -1; } if ((dirh = OpenDirLocal(dirname)) == NULL) { Debug("cfengine, couldn't open dir %s\n",dirname); snprintf(sendbuffer,CF_BUFSIZE,"BAD: cfengine, couldn't open dir %s\n",dirname); SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE); return -1; } /* Pack names for transmission */ memset(sendbuffer,0,CF_BUFSIZE); offset = 0; for (dirp = ReadDir(dirh); dirp != NULL; dirp = ReadDir(dirh)) { if (strlen(dirp->d_name)+1+offset >= CF_BUFSIZE - CF_MAXLINKSIZE) { SendTransaction(conn->sd_reply,sendbuffer,offset+1,CF_MORE); offset = 0; memset(sendbuffer,0,CF_BUFSIZE); } strncpy(sendbuffer+offset,dirp->d_name,CF_MAXLINKSIZE); offset += strlen(dirp->d_name) + 1; /* + zero byte separator */ } strcpy(sendbuffer+offset,CFD_TERMINATOR); SendTransaction(conn->sd_reply,sendbuffer,offset+2+strlen(CFD_TERMINATOR),CF_DONE); Debug("END CfOpenDirectory(%s)\n",dirname); CloseDir(dirh); return 0; } /**************************************************************/ int CfSecOpenDirectory(struct cfd_connection *conn,char *sendbuffer,char *dirname) { CFDIR *dirh; const struct dirent *dirp; int offset,cipherlen; char out[CF_BUFSIZE]; Debug("CfSecOpenDirectory(%s)\n",dirname); if (!IsAbsoluteFileName(dirname)) { sprintf(sendbuffer,"BAD: request to access a non-absolute filename\n"); cipherlen = EncryptString(conn->encryption_type,sendbuffer,out,conn->session_key,strlen(sendbuffer)+1); SendTransaction(conn->sd_reply,out,0,CF_DONE); return -1; } if ((dirh = OpenDirLocal(dirname)) == NULL) { CfOut(cf_verbose,"","Couldn't open dir %s\n",dirname); snprintf(sendbuffer,CF_BUFSIZE,"BAD: cfengine, couldn't open dir %s\n",dirname); cipherlen = EncryptString(conn->encryption_type,sendbuffer,out,conn->session_key,strlen(sendbuffer)+1); SendTransaction(conn->sd_reply,out,0,CF_DONE); return -1; } /* Pack names for transmission */ memset(sendbuffer,0,CF_BUFSIZE); offset = 0; for (dirp = ReadDir(dirh); dirp != NULL; dirp = ReadDir(dirh)) { if (strlen(dirp->d_name)+1+offset >= CF_BUFSIZE - CF_MAXLINKSIZE) { cipherlen = EncryptString(conn->encryption_type,sendbuffer,out,conn->session_key,offset+1); SendTransaction(conn->sd_reply,out,cipherlen,CF_MORE); offset = 0; memset(sendbuffer,0,CF_BUFSIZE); memset(out,0,CF_BUFSIZE); } strncpy(sendbuffer+offset,dirp->d_name,CF_MAXLINKSIZE); /* + zero byte separator */ offset += strlen(dirp->d_name) + 1; } strcpy(sendbuffer+offset,CFD_TERMINATOR); cipherlen = EncryptString(conn->encryption_type,sendbuffer,out,conn->session_key,offset+2+strlen(CFD_TERMINATOR)); SendTransaction(conn->sd_reply,out,cipherlen,CF_DONE); Debug("END CfSecOpenDirectory(%s)\n",dirname); CloseDir(dirh); return 0; } /***************************************************************/ void Terminate(int sd) { char buffer[CF_BUFSIZE]; memset(buffer,0,CF_BUFSIZE); strcpy(buffer,CFD_TERMINATOR); if (SendTransaction(sd,buffer,strlen(buffer)+1,CF_DONE) == -1) { CfOut(cf_verbose,"send","Unable to reply with terminator"); CfOut(cf_verbose,"","Unable to reply with terminator...\n"); } } /***************************************************************/ void DeleteAuthList(struct Auth *ap) { if (ap != NULL) { DeleteAuthList(ap->next); ap->next = NULL; DeleteItemList(ap->accesslist); DeleteItemList(ap->maproot); free(ap->path); free((char *)ap); } } /***************************************************************/ /* Level 5 */ /***************************************************************/ int OptionFound(char *args, char *pos, char *word) /* * Returns true if the current position 'pos' in buffer * 'args' corresponds to the word 'word'. Words are * separated by spaces. */ { size_t len; if (pos < args) { return false; } /* Single options do not have to have spaces between */ if (strlen(word) == 2 && strncmp(pos,word,2) == 0) { return true; } len = strlen(word); if (strncmp(pos, word, len) != 0) { return false; } if (pos == args) { return true; } else if (*(pos-1) == ' ' && (pos[len] == ' ' || pos[len] == '\0')) { return true; } else { return false; } } /**************************************************************/ void RefuseAccess(struct cfd_connection *conn,char *sendbuffer,int size,char *errmesg) { char *hostname, *username, *ipaddr; static char *def = "?"; if (strlen(conn->hostname) == 0) { hostname = def; } else { hostname = conn->hostname; } if (strlen(conn->username) == 0) { username = def; } else { username = conn->username; } if (strlen(conn->ipaddr) == 0) { ipaddr = def; } else { ipaddr = conn->ipaddr; } snprintf(sendbuffer,CF_BUFSIZE,"%s",CF_FAILEDSTR); SendTransaction(conn->sd_reply,sendbuffer,size,CF_DONE); CfOut(cf_inform,"","From (host=%s,user=%s,ip=%s)",hostname,username,ipaddr); if (strlen(errmesg) > 0) { if (LOGCONNS) { CfOut(cf_log,"","REFUSAL of request from connecting host: (%s)",errmesg); } else { CfOut(cf_verbose,"","REFUSAL of request from connecting host: (%s)",errmesg); } } } /***************************************************************/ int TransferRights(char *filename,int sd,struct cfd_get_arg *args,char *sendbuffer, struct stat *sb) { #ifdef MINGW SECURITY_DESCRIPTOR *secDesc; SID *ownerSid; if (GetNamedSecurityInfo(filename, SE_FILE_OBJECT, OWNER_SECURITY_INFORMATION,(PSID*)&ownerSid,NULL,NULL,NULL,&secDesc) == ERROR_SUCCESS) { if (IsValidSid((args->connect)->sid) && EqualSid(ownerSid, (args->connect)->sid)) { Debug("Caller %s is the owner of the file\n",(args->connect)->username); } else { // If the process doesn't own the file, we can access if we are // root AND granted root map LocalFree(secDesc); if (args->connect->maproot) { CfOut(cf_verbose,"","Caller %s not owner of \"%s\", but mapping privilege\n", (args->connect)->username, filename); return true; } else { CfOut(cf_verbose, "", "!! Remote user denied right to file \"%s\" (consider maproot?)", filename); return false; } } LocalFree(secDesc); } else { CfOut(cf_error,"GetNamedSecurityInfo","!! Could not retreive existing owner of \"%s\"", filename); return false; } #else uid_t uid = (args->connect)->uid; if (uid != 0 && !args->connect->maproot) /* should remote root be local root */ { if (sb->st_uid == uid) { Debug("Caller %s is the owner of the file\n",(args->connect)->username); } else { if (sb->st_mode & S_IROTH) { Debug("Caller %s not owner of the file but permission granted\n",(args->connect)->username); } else { Debug("Caller %s is not the owner of the file\n",(args->connect)->username); CfOut(cf_verbose, "", "!! Remote user denied right to file \"%s\" (consider maproot?)", filename); return false; } } } #endif return true; } /***************************************************************/ void AbortTransfer(int sd,char *sendbuffer,char *filename) { CfOut(cf_verbose,"","Aborting transfer of file due to source changes\n"); snprintf(sendbuffer,CF_BUFSIZE,"%s%s: %s",CF_CHANGEDSTR1,CF_CHANGEDSTR2,filename); if (SendTransaction(sd,sendbuffer,0,CF_DONE) == -1) { CfOut(cf_verbose,"send","Send failed in GetFile"); } } /***************************************************************/ void FailedTransfer(int sd,char *sendbuffer,char *filename) { CfOut(cf_verbose,"","Transfer failure\n"); snprintf(sendbuffer,CF_BUFSIZE,"%s",CF_FAILEDSTR); if (SendTransaction(sd,sendbuffer,0,CF_DONE) == -1) { CfOut(cf_verbose,"send","Send failed in GetFile"); } } /***************************************************************/ void ReplyNothing(struct cfd_connection *conn) { char buffer[CF_BUFSIZE]; snprintf(buffer,CF_BUFSIZE,"Hello %s (%s), nothing relevant to do here...\n\n",conn->hostname,conn->ipaddr); if (SendTransaction(conn->sd_reply,buffer,0,CF_DONE) == -1) { CfOut(cf_error,"send",""); } } /***************************************************************/ int CheckStoreKey(struct cfd_connection *conn,RSA *key) { RSA *savedkey; char udigest[CF_MAXVARSIZE]; ThreadLock(cft_output); snprintf(udigest,CF_MAXVARSIZE-1,"%s",HashPrint(CF_DEFAULT_DIGEST,conn->digest)); ThreadUnlock(cft_output); if ((savedkey = HavePublicKey(conn->username,MapAddress(conn->ipaddr),udigest))) { CfOut(cf_verbose,"","A public key was already known from %s/%s - no trust required\n",conn->hostname,conn->ipaddr); CfOut(cf_verbose,"","Adding IP %s to SkipVerify - no need to check this if we have a key\n",conn->ipaddr); IdempPrependItem(&SKIPVERIFY,MapAddress(conn->ipaddr),NULL); if ((BN_cmp(savedkey->e,key->e) == 0) && (BN_cmp(savedkey->n,key->n) == 0)) { CfOut(cf_verbose,"","The public key identity was confirmed as %s@%s\n",conn->username,conn->hostname); SendTransaction(conn->sd_reply,"OK: key accepted",0,CF_DONE); RSA_free(savedkey); return true; } } /* Finally, if we're still here, we should consider trusting a new key ... */ if ((TRUSTKEYLIST != NULL) && IsMatchItemIn(TRUSTKEYLIST,MapAddress(conn->ipaddr))) { CfOut(cf_verbose,"","Host %s/%s was found in the list of hosts to trust\n",conn->hostname,conn->ipaddr); conn->trust = true; /* conn->maproot = false; ?? */ SendTransaction(conn->sd_reply,"OK: unknown key was accepted on trust",0,CF_DONE); SavePublicKey(conn->username,MapAddress(conn->ipaddr),udigest,key); return true; } else { CfOut(cf_verbose,"","No previous key found, and unable to accept this one on trust\n"); SendTransaction(conn->sd_reply,"BAD: key could not be accepted on trust",0,CF_DONE); return false; } } /***************************************************************/ /* Toolkit/Class: conn */ /***************************************************************/ struct cfd_connection *NewConn(int sd) /* construct */ { struct cfd_connection *conn; ThreadLock(cft_system); conn = (struct cfd_connection *) malloc(sizeof(struct cfd_connection)); ThreadUnlock(cft_system); if (conn == NULL) { CfOut(cf_error,"malloc","Unable to allocate conn"); HandleSignals(SIGTERM); } conn->sd_reply = sd; conn->id_verified = false; conn->rsa_auth = false; conn->trust = false; conn->hostname[0] = '\0'; conn->ipaddr[0] = '\0'; conn->username[0] = '\0'; conn->session_key = NULL; conn->encryption_type = 'c'; Debug("*** New socket [%d]\n",sd); return conn; } /***************************************************************/ void DeleteConn(struct cfd_connection *conn) /* destruct */ { Debug("***Closing socket %d from %s\n",conn->sd_reply,conn->ipaddr); cf_closesocket(conn->sd_reply); if (conn->session_key != NULL) { free(conn->session_key); } if (conn->ipaddr != NULL) { if (!ThreadLock(cft_count)) { return; } DeleteItemMatching(&CONNECTIONLIST,MapAddress(conn->ipaddr)); if (!ThreadUnlock(cft_count)) { return; } } free((char *)conn); } /***************************************************************/ /* ERS */ /***************************************************************/ int SafeOpen(char *filename) { int fd; ThreadLock(cft_system); fd = open(filename,O_RDONLY); ThreadUnlock(cft_system); return fd; } /***************************************************************/ void SafeClose(int fd) { ThreadLock(cft_system); close(fd); ThreadUnlock(cft_system); } /***************************************************************/ int cfscanf(char *in,int len1,int len2,char *out1,char *out2,char *out3) { int len3=0; char *sp; sp = in; memcpy(out1,sp,len1); out1[len1]='\0'; sp += len1 + 1; memcpy(out2,sp,len2); sp += len2 + 1; len3=strlen(sp); memcpy(out3,sp,len3); out3[len3]='\0'; return (len1 + len2 + len3 + 2); } /* EOF */ cfengine-3.2.4/src/env_monitor.c0000644000175000017500000006276011715232734013531 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: env_monitor.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #include "monitoring.h" #include /*****************************************************************************/ /* Globals */ /*****************************************************************************/ static double HISTOGRAM[CF_OBSERVABLES][7][CF_GRAINS]; /* persistent observations */ static double CF_THIS[CF_OBSERVABLES]; /* New from 2.1.21 replacing above - current observation */ /* Work */ static long ITER; /* Iteration since start */ static double AGE,WAGE; /* Age and weekly age of database */ static struct Averages LOCALAV; /* Leap Detection vars */ static double LDT_BUF[CF_OBSERVABLES][LDT_BUFSIZE]; static double LDT_SUM[CF_OBSERVABLES]; static double LDT_AVG[CF_OBSERVABLES]; static double CHI_LIMIT[CF_OBSERVABLES]; static double CHI[CF_OBSERVABLES]; static double LDT_MAX[CF_OBSERVABLES]; static int LDT_POS = 0; static int LDT_FULL = false; int NO_FORK = false; /*******************************************************************/ /* Prototypes */ /*******************************************************************/ static void GetDatabaseAge(void); static void LoadHistogram(void); static void GetQ(void); static struct Averages EvalAvQ(char *timekey); static void ArmClasses(struct Averages newvals,char *timekey); static void GatherPromisedMeasures(void); static void LeapDetection(void); static struct Averages *GetCurrentAverages(char *timekey); static void UpdateAverages(char *timekey, struct Averages newvals); static void UpdateDistributions(char *timekey, struct Averages *av); static double WAverage(double newvals,double oldvals, double age); static double SetClasses(char *name,double variable,double av_expect,double av_var,double localav_expect,double localav_var,struct Item **classlist,char *timekey); static void SetVariable(char *name,double now, double average, double stddev, struct Item **list); static double RejectAnomaly(double new,double av,double var,double av2,double var2); static void ZeroArrivals (void); static void KeepMonitorPromise(struct Promise *pp); /****************************************************************/ void MonInitialize(void) { int i,j,k; char vbuff[CF_BUFSIZE]; for (i = 0; i < ATTR; i++) { sprintf(vbuff,"%s/state/cf_incoming.%s",CFWORKDIR,ECGSOCKS[i].name); MapName(vbuff); CreateEmptyFile(vbuff); sprintf(vbuff,"%s/state/cf_outgoing.%s",CFWORKDIR,ECGSOCKS[i].name); MapName(vbuff); CreateEmptyFile(vbuff); } sprintf(vbuff,"%s/state/cf_users",CFWORKDIR); MapName(vbuff); CreateEmptyFile(vbuff); snprintf(AVDB,CF_MAXVARSIZE,"%s/state/%s",CFWORKDIR,CF_AVDB_FILE); MapName(AVDB); MonEntropyClassesInit(); GetDatabaseAge(); for (i = 0; i < CF_OBSERVABLES; i++) { LOCALAV.Q[i].expect = 0.0; LOCALAV.Q[i].var = 0.0; LOCALAV.Q[i].q = 0.0; } for (i = 0; i < 7; i++) { for (j = 0; j < CF_OBSERVABLES; j++) { for (k = 0; k < CF_GRAINS; k++) { HISTOGRAM[i][j][k] = 0; } } } for (i = 0; i < CF_OBSERVABLES; i++) { CHI[i] = 0; CHI_LIMIT[i] = 0.1; LDT_AVG[i] = 0; LDT_SUM[i] = 0; } srand((unsigned int)time(NULL)); LoadHistogram(); /* Look for local sensors - this is unfortunately linux-centric */ MonTempInit(); MonOtherInit(); Debug("Finished with initialization.\n"); } /*********************************************************************/ /* Level 2 */ /*********************************************************************/ static void GetDatabaseAge() { CF_DB *dbp; if (!OpenDB(AVDB,&dbp)) { return; } cf_chmod(AVDB,0644); if (ReadDB(dbp,"DATABASE_AGE",&AGE,sizeof(double))) { WAGE = AGE / CF_WEEK * CF_MEASURE_INTERVAL; Debug("\n\nPrevious DATABASE_AGE %f\n\n",AGE); } else { Debug("No previous AGE\n"); AGE = 0.0; } CloseDB(dbp); } /*********************************************************************/ static void LoadHistogram(void) { FILE *fp; int i,day,position; double maxval[CF_OBSERVABLES]; char filename[CF_BUFSIZE]; snprintf(filename,CF_BUFSIZE,"%s/state/histograms",CFWORKDIR); if ((fp = fopen(filename,"r")) == NULL) { CfOut(cf_verbose,"fopen","Unable to load histogram data"); return; } for (i = 0; i < CF_OBSERVABLES; i++) { maxval[i] = 1.0; } for (position = 0; position < CF_GRAINS; position++) { fscanf(fp,"%d ",&position); for (i = 0; i < CF_OBSERVABLES; i++) { for (day = 0; day < 7; day++) { fscanf(fp,"%lf ",&(HISTOGRAM[i][day][position])); if (HISTOGRAM[i][day][position] < 0) { HISTOGRAM[i][day][position] = 0; } if (HISTOGRAM[i][day][position] > maxval[i]) { maxval[i] = HISTOGRAM[i][day][position]; } HISTOGRAM[i][day][position] *= 1000.0/maxval[i]; } } } fclose(fp); } /*********************************************************************/ void StartServer(int argc,char **argv) { char timekey[CF_SMALLBUF]; struct Averages averages; struct Promise *pp = NewPromise("monitor_cfengine","the monitor daemon"); struct Attributes dummyattr; struct CfLock thislock; #ifdef MINGW if(!NO_FORK) { CfOut(cf_verbose, "", "Windows does not support starting processes in the background - starting in foreground"); } #else /* NOT MINGW */ if ((!NO_FORK) && (fork() != 0)) { CfOut(cf_inform,"","cf-monitord: starting\n"); exit(0); } if (!NO_FORK) { ActAsDaemon(0); } #endif /* NOT MINGW */ memset(&dummyattr,0,sizeof(dummyattr)); dummyattr.transaction.ifelapsed = 0; dummyattr.transaction.expireafter = 0; thislock = AcquireLock(pp->promiser,VUQNAME,CFSTARTTIME,dummyattr,pp,false); if (thislock.lock == NULL) { return; } WritePID("cf-monitord.pid"); MonNetworkSnifferOpen(); while (true) { GetQ(); snprintf(timekey, sizeof(timekey), "%s", GenTimeKey(time(NULL))); averages = EvalAvQ(timekey); LeapDetection(); ArmClasses(averages,timekey); ZeroArrivals(); MonNetworkSnifferSniff(ITER, CF_THIS); ITER++; } } /*********************************************************************/ static void GetQ(void) { Debug("========================= GET Q ==============================\n"); MonEntropyClassesReset(); ZeroArrivals(); MonProcessesGatherData(CF_THIS); #ifndef MINGW MonCPUGatherData(CF_THIS); MonLoadGatherData(CF_THIS); MonDiskGatherData(CF_THIS); MonNetworkGatherData(CF_THIS); MonNetworkSnifferGatherData(CF_THIS); MonTempGatherData(CF_THIS); #endif /* NOT MINGW */ MonOtherGatherData(CF_THIS); GatherPromisedMeasures(); } /*********************************************************************/ static struct Averages EvalAvQ(char *t) { struct Averages *currentvals,newvals; double This[CF_OBSERVABLES]; char name[CF_MAXVARSIZE]; int i; Banner("Evaluating and storing new weekly averages"); if ((currentvals = GetCurrentAverages(t)) == NULL) { CfOut(cf_error,"","Error reading average database"); exit(1); } /* Discard any apparently anomalous behaviour before renormalizing database */ for (i = 0; i < CF_OBSERVABLES; i++) { double delta2; name[0] = '\0'; CfGetClassName(i,name); /* Overflow protection */ if (currentvals->Q[i].expect < 0) { currentvals->Q[i].expect = 0; } if (currentvals->Q[i].q < 0) { currentvals->Q[i].q = 0; } if (currentvals->Q[i].var < 0) { currentvals->Q[i].var = 0; } This[i] = RejectAnomaly(CF_THIS[i],currentvals->Q[i].expect,currentvals->Q[i].var,LOCALAV.Q[i].expect,LOCALAV.Q[i].var); newvals.Q[i].q = This[i]; LOCALAV.Q[i].q = This[i]; Debug("Current %s.q %lf\n",name,currentvals->Q[i].q); Debug("Current %s.var %lf\n",name,currentvals->Q[i].var); Debug("Current %s.ex %lf\n",name,currentvals->Q[i].expect); Debug("CF_THIS[%s] = %lf\n",name,CF_THIS[i]); Debug("This[%s] = %lf\n",name,This[i]); newvals.Q[i].expect = WAverage(This[i],currentvals->Q[i].expect,WAGE); LOCALAV.Q[i].expect = WAverage(newvals.Q[i].expect,LOCALAV.Q[i].expect,ITER); delta2 = (This[i] - currentvals->Q[i].expect)*(This[i] - currentvals->Q[i].expect); if (currentvals->Q[i].var > delta2*2.0) { /* Clean up past anomalies */ newvals.Q[i].var = delta2; LOCALAV.Q[i].var = WAverage(newvals.Q[i].var,LOCALAV.Q[i].var,ITER); } else { newvals.Q[i].var = WAverage(delta2,currentvals->Q[i].var,WAGE); LOCALAV.Q[i].var = WAverage(newvals.Q[i].var,LOCALAV.Q[i].var,ITER); } CfOut(cf_verbose, "", "[%d] %s q=%lf, var=%lf, ex=%lf", i, name, newvals.Q[i].q, newvals.Q[i].var, newvals.Q[i].expect); CfOut(cf_verbose,"","[%d] = %lf -> (%lf#%lf) local [%lf#%lf]\n", i, This[i],newvals.Q[i].expect,sqrt(newvals.Q[i].var),LOCALAV.Q[i].expect,sqrt(LOCALAV.Q[i].var)); if (This[i] > 0) { CfOut(cf_verbose,"","Storing %.2lf in %s\n",This[i],name); } } UpdateAverages(t,newvals); UpdateDistributions(t,currentvals); /* Distribution about mean */ return newvals; } /*********************************************************************/ static void LeapDetection(void) { int i,last_pos = LDT_POS; double n1,n2,d; double padding = 0.2; if (++LDT_POS >= LDT_BUFSIZE) { LDT_POS = 0; if (!LDT_FULL) { Debug("LDT Buffer full at %d\n",LDT_BUFSIZE); LDT_FULL = true; } } for (i = 0; i < CF_OBSERVABLES; i++) { /* First do some anomaly rejection. Sudden jumps must be numerical errors. */ if (LDT_BUF[i][last_pos] > 0 && CF_THIS[i]/LDT_BUF[i][last_pos] > 1000) { CF_THIS[i] = LDT_BUF[i][last_pos]; } /* Note AVG should contain n+1 but not SUM, hence funny increments */ LDT_AVG[i] = LDT_AVG[i] + CF_THIS[i]/((double)LDT_BUFSIZE + 1.0); d = (double)(LDT_BUFSIZE * (LDT_BUFSIZE + 1)) * LDT_AVG[i]; if (LDT_FULL && (LDT_POS == 0)) { n2 = (LDT_SUM[i] - (double)LDT_BUFSIZE * LDT_MAX[i]); if (d < 0.001) { CHI_LIMIT[i] = 0.5; } else { CHI_LIMIT[i] = padding + sqrt(n2*n2/d); } LDT_MAX[i] = 0.0; } if (CF_THIS[i] > LDT_MAX[i]) { LDT_MAX[i] = CF_THIS[i]; } n1 = (LDT_SUM[i] - (double)LDT_BUFSIZE * CF_THIS[i]); if (d < 0.001) { CHI[i] = 0.0; } else { CHI[i] = sqrt(n1*n1/d); } LDT_AVG[i] = LDT_AVG[i] - LDT_BUF[i][LDT_POS]/((double)LDT_BUFSIZE + 1.0); LDT_BUF[i][LDT_POS] = CF_THIS[i]; LDT_SUM[i] = LDT_SUM[i] - LDT_BUF[i][LDT_POS] + CF_THIS[i]; } } /*********************************************************************/ static void ArmClasses(struct Averages av,char *timekey) { double sigma; struct Item *classlist = NULL; int i,j,k; char buff[CF_BUFSIZE],ldt_buff[CF_BUFSIZE],name[CF_MAXVARSIZE]; static int anomaly[CF_OBSERVABLES][LDT_BUFSIZE]; static double anomaly_chi[CF_OBSERVABLES]; static double anomaly_chi_limit[CF_OBSERVABLES]; Debug("Arm classes for %s\n",timekey); for (i = 0; i < CF_OBSERVABLES; i++) { CfGetClassName(i,name); sigma = SetClasses(name,CF_THIS[i],av.Q[i].expect,av.Q[i].var,LOCALAV.Q[i].expect,LOCALAV.Q[i].var,&classlist,timekey); SetVariable(name,CF_THIS[i],av.Q[i].expect,sigma,&classlist); /* LDT */ ldt_buff[0] = '\0'; anomaly[i][LDT_POS] = false; if (!LDT_FULL) { anomaly[i][LDT_POS] = false; anomaly_chi[i] = 0.0; anomaly_chi_limit[i] = 0.0; } if (LDT_FULL && (CHI[i] > CHI_LIMIT[i])) { anomaly[i][LDT_POS] = true; /* Remember the last anomaly value */ anomaly_chi[i] = CHI[i]; anomaly_chi_limit[i] = CHI_LIMIT[i]; CfOut(cf_verbose,"","LDT(%d) in %s chi = %.2f thresh %.2f \n",LDT_POS,name,CHI[i],CHI_LIMIT[i]); /* Last printed element is now */ for (j = LDT_POS+1, k = 0; k < LDT_BUFSIZE; j++,k++) { if (j == LDT_BUFSIZE) /* Wrap */ { j = 0; } if (anomaly[i][j]) { snprintf(buff,CF_BUFSIZE," *%.2f*",LDT_BUF[i][j]); } else { snprintf(buff,CF_BUFSIZE," %.2f",LDT_BUF[i][j]); } strcat(ldt_buff,buff); } if (CF_THIS[i] > av.Q[i].expect) { snprintf(buff,CF_BUFSIZE,"%s_high_ldt",name); } else { snprintf(buff,CF_BUFSIZE,"%s_high_ldt",name); } AppendItem(&classlist,buff,"2"); NewPersistentContext(buff,CF_PERSISTENCE,cfpreserve); } else { for (j = LDT_POS+1, k = 0; k < LDT_BUFSIZE; j++,k++) { if (j == LDT_BUFSIZE) /* Wrap */ { j = 0; } if (anomaly[i][j]) { snprintf(buff,CF_BUFSIZE," *%.2f*",LDT_BUF[i][j]); } else { snprintf(buff,CF_BUFSIZE," %.2f",LDT_BUF[i][j]); } strcat(ldt_buff,buff); } } /* Not using these for now snprintf(buff,CF_MAXVARSIZE,"ldtbuf_%s=%s",name,ldt_buff); AppendItem(&classlist,buff,""); snprintf(buff,CF_MAXVARSIZE,"ldtchi_%s=%.2f",name,anomaly_chi[i]); AppendItem(&classlist,buff,""); snprintf(buff,CF_MAXVARSIZE,"ldtlimit_%s=%.2f",name,anomaly_chi_limit[i]); AppendItem(&classlist,buff,""); */ } SetMeasurementPromises(&classlist); /* Publish class list */ MonEntropyClassesPublish(classlist); } /*****************************************************************************/ static struct Averages *GetCurrentAverages(char *timekey) { CF_DB *dbp; static struct Averages entry; if (!OpenDB(AVDB,&dbp)) { return NULL; } memset(&entry,0,sizeof(entry)); AGE++; WAGE = AGE / CF_WEEK * CF_MEASURE_INTERVAL; if (ReadDB(dbp,timekey,&entry,sizeof(struct Averages))) { int i; for (i = 0; i < CF_OBSERVABLES; i++) { Debug("Previous values (%lf,..) for time index %s\n\n",entry.Q[i].expect,timekey); } } else { Debug("No previous value for time index %s\n",timekey); } CloseDB(dbp); return &entry; } /*****************************************************************************/ static void UpdateAverages(char *timekey,struct Averages newvals) { CF_DB *dbp; if (!OpenDB(AVDB,&dbp)) { return; } CfOut(cf_inform,"","Updated averages at %s\n",timekey); WriteDB(dbp,timekey,&newvals,sizeof(struct Averages)); WriteDB(dbp,"DATABASE_AGE",&AGE,sizeof(double)); CloseDB(dbp); HistoryUpdate(newvals); } /*****************************************************************************/ static void UpdateDistributions(char *timekey,struct Averages *av) { int position,day,i; char filename[CF_BUFSIZE]; FILE *fp; /* Take an interval of 4 standard deviations from -2 to +2, divided into CF_GRAINS parts. Centre each measurement on CF_GRAINS/2 and scale each measurement by the std-deviation for the current time. */ if (IsDefinedClass("Min40_45")) { day = Day2Number(timekey); for (i = 0; i < CF_OBSERVABLES; i++) { position = CF_GRAINS/2 + (int)(0.5+(CF_THIS[i] - av->Q[i].expect)*CF_GRAINS/(4*sqrt((av->Q[i].var)))); if (0 <= position && position < CF_GRAINS) { HISTOGRAM[i][day][position]++; } } snprintf(filename,CF_BUFSIZE,"%s/state/histograms",CFWORKDIR); if ((fp = fopen(filename,"w")) == NULL) { CfOut(cf_error,"fopen","Unable to save histograms"); return; } for (position = 0; position < CF_GRAINS; position++) { fprintf(fp,"%d ",position); for (i = 0; i < CF_OBSERVABLES; i++) { for (day = 0; day < 7; day++) { fprintf(fp,"%.0lf ",HISTOGRAM[i][day][position]); } } fprintf(fp,"\n"); } fclose(fp); } } /*****************************************************************************/ /* For a couple of weeks, learn eagerly. Otherwise variances will be way too large. Then downplay newer data somewhat, and rely on experience of a couple of months of data ... */ static double WAverage(double anew,double aold,double age) { double av,cf_sane_monitor_limit = 9999999.0; double wnew,wold; /* First do some database corruption self-healing */ if (aold > cf_sane_monitor_limit && anew > cf_sane_monitor_limit) { return 0; } if (aold > cf_sane_monitor_limit) { return anew; } if (aold > cf_sane_monitor_limit) { return aold; } /* Now look at the self-learning */ if (FORGETRATE > 0.9 || FORGETRATE < 0.1) { FORGETRATE = 0.6; } if (age < 2.0) /* More aggressive learning for young database */ { wnew = FORGETRATE; wold = (1.0-FORGETRATE); } else { wnew = (1.0-FORGETRATE); wold = FORGETRATE; } if (aold == 0 && anew == 0) { return 0; } /* * AV = (Wnew*Anew + Wold*Aold) / (Wnew + Wold). * * Wnew + Wold always equals to 1, so we omit it for better precision and * performance. */ av = (wnew*anew + wold*aold); if (av < 0) { /* Accuracy lost - something wrong */ return 0.0; } return av; } /*****************************************************************************/ static double SetClasses(char * name,double variable,double av_expect,double av_var,double localav_expect,double localav_var,struct Item **classlist,char *timekey) { char buffer[CF_BUFSIZE],buffer2[CF_BUFSIZE]; double dev,delta,sigma,ldelta,lsigma,sig; Debug("\n SetClasses(%s,X=%lf,avX=%lf,varX=%lf,lavX=%lf,lvarX=%lf,%s)\n",name,variable,av_expect,av_var,localav_expect,localav_var,timekey); delta = variable - av_expect; sigma = sqrt(av_var); ldelta = variable - localav_expect; lsigma = sqrt(localav_var); sig = sqrt(sigma*sigma+lsigma*lsigma); Debug(" delta = %lf,sigma = %lf, lsigma = %lf, sig = %lf\n",delta,sigma,lsigma,sig); if (sigma == 0.0 || lsigma == 0.0) { Debug(" No sigma variation .. can't measure class\n"); return sig; } Debug("Setting classes for %s...\n",name); if (fabs(delta) < cf_noise_threshold) /* Arbitrary limits on sensitivity */ { Debug(" Sensitivity too high ..\n"); buffer[0] = '\0'; strcpy(buffer,name); if ((delta > 0) && (ldelta > 0)) { strcat(buffer,"_high"); } else if ((delta < 0) && (ldelta < 0)) { strcat(buffer,"_low"); } else { strcat(buffer,"_normal"); } dev = sqrt(delta*delta/(1.0+sigma*sigma)+ldelta*ldelta/(1.0+lsigma*lsigma)); if (dev > 2.0*sqrt(2.0)) { strcpy(buffer2,buffer); strcat(buffer2,"_microanomaly"); AppendItem(classlist,buffer2,"2"); NewPersistentContext(buffer2,CF_PERSISTENCE,cfpreserve); } return sig; /* Granularity makes this silly */ } else { buffer[0] = '\0'; strcpy(buffer,name); if ((delta > 0) && (ldelta > 0)) { strcat(buffer,"_high"); } else if ((delta < 0) && (ldelta < 0)) { strcat(buffer,"_low"); } else { strcat(buffer,"_normal"); } dev = sqrt(delta*delta/(1.0+sigma*sigma)+ldelta*ldelta/(1.0+lsigma*lsigma)); if (dev <= sqrt(2.0)) { strcpy(buffer2,buffer); strcat(buffer2,"_normal"); AppendItem(classlist,buffer2,"0"); } else { strcpy(buffer2,buffer); strcat(buffer2,"_dev1"); AppendItem(classlist,buffer2,"0"); } /* Now use persistent classes so that serious anomalies last for about 2 autocorrelation lengths, so that they can be cross correlated and seen by normally scheduled cfagent processes ... */ if (dev > 2.0*sqrt(2.0)) { strcpy(buffer2,buffer); strcat(buffer2,"_dev2"); AppendItem(classlist,buffer2,"2"); NewPersistentContext(buffer2,CF_PERSISTENCE,cfpreserve); } if (dev > 3.0*sqrt(2.0)) { strcpy(buffer2,buffer); strcat(buffer2,"_anomaly"); AppendItem(classlist,buffer2,"3"); NewPersistentContext(buffer2,CF_PERSISTENCE,cfpreserve); } return sig; } } /*****************************************************************************/ static void SetVariable(char *name,double value,double average,double stddev,struct Item **classlist) { char var[CF_BUFSIZE]; snprintf(var,CF_MAXVARSIZE,"value_%s=%.0lf",name,value); AppendItem(classlist,var,""); snprintf(var,CF_MAXVARSIZE,"av_%s=%.2lf",name,average); AppendItem(classlist,var,""); snprintf(var,CF_MAXVARSIZE,"dev_%s=%.2lf",name,stddev); AppendItem(classlist,var,""); } /*****************************************************************************/ static void ZeroArrivals() { memset(CF_THIS, 0, sizeof(CF_THIS)); } /*****************************************************************************/ static double RejectAnomaly(double new,double average,double variance,double localav,double localvar) { double dev = sqrt(variance+localvar); /* Geometrical average dev */ double delta; int bigger; if (average == 0) { return new; } if (new > MON_THRESHOLD_HIGH*4.0) { return 0.0; } if (new > MON_THRESHOLD_HIGH) { return average; } if ((new-average)*(new-average) < cf_noise_threshold*cf_noise_threshold) { return new; } if (new - average > 0) { bigger = true; } else { bigger = false; } /* This routine puts some inertia into the changes, so that the system doesn't respond to every little change ... IR and UV cutoff */ delta = sqrt((new-average)*(new-average)+(new-localav)*(new-localav)); if (delta > 4.0*dev) /* IR */ { srand48((unsigned int)time(NULL)); if (drand48() < 0.7) /* 70% chance of using full value - as in learning policy */ { return new; } else { if (bigger) { return average+2.0*dev; } else { return average-2.0*dev; } } } else { CfOut(cf_verbose,"","Value accepted\n"); return new; } } /***************************************************************/ /* Level 5 */ /***************************************************************/ static void GatherPromisedMeasures(void) { struct Bundle *bp; struct SubType *sp; struct Promise *pp; char *scope; for (bp = BUNDLES; bp != NULL; bp = bp->next) /* get schedule */ { scope = bp->name; SetNewScope(bp->name); if ((strcmp(bp->type,CF_AGENTTYPES[cf_monitor]) == 0) || (strcmp(bp->type,CF_AGENTTYPES[cf_common]) == 0)) { for (sp = bp->subtypes; sp != NULL; sp = sp->next) /* get schedule */ { for (pp = sp->promiselist; pp != NULL; pp=pp->next) { ExpandPromise(cf_monitor,scope,pp,KeepMonitorPromise); } } } } DeleteAllScope(); } /*********************************************************************/ /* Level */ /*********************************************************************/ static void KeepMonitorPromise(struct Promise *pp) { char *sp = NULL; if (!IsDefinedClass(pp->classes)) { CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,"",". . . . . . . . . . . . . . . . . . . . . . . . . . . . \n"); CfOut(cf_verbose,"","Skipping whole next promise (%s), as context %s is not relevant\n",pp->promiser,pp->classes); CfOut(cf_verbose,"",". . . . . . . . . . . . . . . . . . . . . . . . . . . . \n"); return; } if (VarClassExcluded(pp,&sp)) { CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,"",". . . . . . . . . . . . . . . . . . . . . . . . . . . . \n"); CfOut(cf_verbose,"","Skipping whole next promise (%s), as var-context %s is not relevant\n",pp->promiser,sp); CfOut(cf_verbose,"",". . . . . . . . . . . . . . . . . . . . . . . . . . . . \n"); return; } if (strcmp("classes",pp->agentsubtype) == 0) { KeepClassContextPromise(pp); return; } if (strcmp("measurements",pp->agentsubtype) == 0) { VerifyMeasurementPromise(CF_THIS,pp); *pp->donep = false; return; } } /*****************************************************************************/ void MonOtherInit(void) { #ifdef HAVE_NOVA Nova_MonOtherInit(); #endif } /*********************************************************************/ void MonOtherGatherData(double *cf_this) { #ifdef HAVE_NOVA Nova_MonOtherGatherData(cf_this); #endif } cfengine-3.2.4/src/ontology.c0000644000175000017500000004317611715232734013044 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: ontology.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static char *GetTopicContext(char *topic_name); static int ClassifiedTopicMatch(char *ttopic1,char *ttopic2); static void DeClassifyCanonicalTopic(char *typed_topic,char *topic,char *type); static char *ClassifiedTopic(char *topic,char *type); static char *URLHint(char *s); static char *NormalizeTopic(char *s); int GLOBAL_ID = 1; // Used as a primary key for convenience, 0 reserved extern struct Occurrences *OCCURRENCES; /*****************************************************************************/ struct Topic *IdempInsertTopic(char *classified_name) { char context[CF_MAXVARSIZE],topic[CF_MAXVARSIZE]; context[0] = '\0'; topic[0] = '\0'; DeClassifyTopic(classified_name,topic,context); return InsertTopic(topic,context); } /*****************************************************************************/ struct Topic *InsertTopic(char *name,char *context) { int slot = GetHash(ToLowerStr(name)); return AddTopic(&(TOPICHASH[slot]),name,context); } /*****************************************************************************/ struct Topic *FindTopic(char *name) { int slot = GetHash(ToLowerStr(name)); return GetTopic(TOPICHASH[slot],name); } /*****************************************************************************/ struct Topic *AddTopic(struct Topic **list,char *name,char *context) { struct Topic *tp; if ((tp = TopicExists(name,context))) { CfOut(cf_verbose,""," -> Topic %s already defined, ok\n",name); } else { if ((tp = (struct Topic *)malloc(sizeof(struct Topic))) == NULL) { CfOut(cf_error,"malloc"," !! Memory failure in AddTopic"); FatalError(""); } tp->topic_name = strdup(NormalizeTopic(name)); if (context && strlen(context) > 0) { tp->topic_context = strdup(NormalizeTopic(context)); } else { tp->topic_context = strdup("any"); } tp->id = GLOBAL_ID++; tp->associations = NULL; tp->next = *list; *list = tp; CF_TOPICS++; // This section must come last, as there is possible recursion and memory ref needs to be complete first if (strcmp(tp->topic_context,"any") != 0) { // Every topic in a special context is generalized by itself in context "any" char gen[CF_BUFSIZE]; struct Rlist *rlist = 0; snprintf(gen,CF_BUFSIZE-1,"any::%s",tp->topic_name); PrependRScalar(&rlist,gen,CF_SCALAR); AddTopicAssociation(tp,&(tp->associations),KM_GENERALIZES_B,KM_GENERALIZES_F,rlist,true,tp->topic_context,tp->topic_name); DeleteRlist(rlist); } } return tp; } /*****************************************************************************/ void AddTopicAssociation(struct Topic *this_tp,struct TopicAssociation **list,char *fwd_name,char *bwd_name,struct Rlist *passociates,int ok_to_add_inverse,char *from_context,char *from_topic) { struct TopicAssociation *ta = NULL,*texist; char fwd_context[CF_MAXVARSIZE]; struct Rlist *rp,*rpc; struct Topic *new_tp; char contexttopic[CF_BUFSIZE],ntopic[CF_BUFSIZE],ncontext[CF_BUFSIZE]; strncpy(ntopic,NormalizeTopic(from_topic),CF_BUFSIZE-1); strncpy(ncontext,NormalizeTopic(from_context),CF_BUFSIZE-1); snprintf(contexttopic,CF_MAXVARSIZE,"%s::%s",ncontext,ntopic); strncpy(fwd_context,CanonifyName(fwd_name),CF_MAXVARSIZE-1); if (passociates == NULL || passociates->item == NULL) { CfOut(cf_error," !! A topic must have at least one associate in association %s",fwd_name); return; } if ((texist = AssociationExists(*list,fwd_name,bwd_name)) == NULL) { if ((ta = (struct TopicAssociation *)malloc(sizeof(struct TopicAssociation))) == NULL) { CfOut(cf_error,"malloc","Memory failure in AddTopicAssociation"); FatalError(""); } if ((ta->fwd_name = strdup(fwd_name)) == NULL) { CfOut(cf_error,"malloc","Memory failure in AddTopicAssociation"); FatalError(""); } ta->bwd_name = NULL; if (bwd_name && ((ta->bwd_name = strdup(bwd_name)) == NULL)) { CfOut(cf_error,"malloc","Memory failure in AddTopicAssociation"); FatalError(""); } if ((ta->fwd_context = strdup(fwd_context)) == NULL) { CfOut(cf_error,"malloc","Memory failure in AddTopicAssociation"); FatalError(""); } ta->associates = NULL; ta->bwd_context = NULL; ta->next = *list; *list = ta; } else { ta = texist; } /* Association now exists, so add new members */ if (ok_to_add_inverse) { CfOut(cf_verbose,""," -> BEGIN add fwd associates for %s::%s",ncontext,ntopic); } else { CfOut(cf_verbose,""," ---> BEGIN reverse associations %s::%s",ncontext,ntopic); } // First make sure topics pointed to exist so that they can point to us also for (rp = passociates; rp != NULL; rp=rp->next) { char normalform[CF_BUFSIZE] = {0}; strncpy(normalform,NormalizeTopic(rp->item),CF_BUFSIZE-1); new_tp = IdempInsertTopic(normalform); if (strcmp(contexttopic,normalform) == 0) { CfOut(cf_verbose,""," ! Excluding self-reference to %s",rp->item); continue; } if (ok_to_add_inverse) { CfOut(cf_verbose,""," --> Adding '%s' with id %d as an associate of '%s::%s'",normalform,new_tp->id,this_tp->topic_context,this_tp->topic_name); } else { CfOut(cf_verbose,""," ---> Reverse '%s' with id %d as an associate of '%s::%s' (inverse)",normalform,new_tp->id,this_tp->topic_context,this_tp->topic_name); } if (!IsItemIn(ta->associates,normalform)) { PrependFullItem(&(ta->associates),normalform,NULL,new_tp->id,0); if (ok_to_add_inverse) { // inverse is from normalform to ncontext::ntopic char rev[CF_BUFSIZE],ndt[CF_BUFSIZE],ndc[CF_BUFSIZE]; struct Rlist *rlist = 0; snprintf(rev,CF_BUFSIZE-1,"%s::%s",ncontext,ntopic); PrependRScalar(&rlist,rev,CF_SCALAR); // Stupid to have to declassify + reclassify, but .. DeClassifyTopic(normalform,ndt,ndc); AddTopicAssociation(new_tp,&(new_tp->associations),bwd_name,fwd_name,rlist,false,ndc,ndt); DeleteRlist(rlist); } } else { CfOut(cf_verbose,""," -> Already in %s::%s's associate list",ncontext,ntopic); } CF_EDGES++; } if (ok_to_add_inverse) { CfOut(cf_verbose,""," -> END add fwd associates for %s::%s",ncontext,ntopic); } else { CfOut(cf_verbose,""," ---> END reverse associations %s::%s",ncontext,ntopic); } } /*****************************************************************************/ void AddOccurrence(struct Occurrence **list,char *reference,struct Rlist *represents,enum representations rtype,char *context) { struct Occurrence *op = NULL; struct Rlist *rp; if ((op = OccurrenceExists(*list,reference,rtype,context)) == NULL) { if ((op = (struct Occurrence *)malloc(sizeof(struct Occurrence))) == NULL) { CfOut(cf_error,"malloc","Memory failure in AddOccurrence"); FatalError(""); } op->represents = NULL; op->occurrence_context = strdup(ToLowerStr(context)); op->locator = strdup(reference); op->rep_type = rtype; op->next = *list; *list = op; CF_OCCUR++; CfOut(cf_verbose,""," -> Noted occurrence for %s::%s",context,reference); } /* Occurrence now exists, so add new subtype promises */ if (represents == NULL) { CfOut(cf_error,""," !! Topic occurrence \"%s\" claims to represent no aspect of its topic, discarding...",reference); return; } for (rp = represents; rp != NULL; rp=rp->next) { IdempPrependRScalar(&(op->represents),rp->item,rp->type); } } /*********************************************************************/ void AddInference(struct Inference **list,char *result,char *pre,char *qual) { struct Inference *ip; if ((ip = (struct Inference *)malloc(sizeof(struct Occurrence))) == NULL) { CfOut(cf_error,"malloc","Memory failure in AddOccurrence"); FatalError(""); } ip->inference = strdup(result); ip->precedent = strdup(pre); ip->qualifier = strdup(qual); ip->next = *list; *list = ip; } /*********************************************************************/ static char *ClassifiedTopic(char *topic,char *context) { static char name[CF_MAXVARSIZE]; Debug("CONTEXT(%s)/TOPIC(%s)",context,topic); if (context && strlen(context) > 0) { snprintf(name,CF_MAXVARSIZE,"%s::%s",context,topic); } else { snprintf(name,CF_MAXVARSIZE,"%s",topic); } return name; } /*********************************************************************/ void DeClassifyTopic(char *classified_topic,char *topic,char *context) { context[0] = '\0'; topic[0] = '\0'; if (classified_topic == NULL) { return; } if (*classified_topic == ':') { sscanf(classified_topic,"::%255[^\n]",topic); } else if (strstr(classified_topic,"::")) { sscanf(classified_topic,"%255[^:]::%255[^\n]",context,topic); if (strlen(topic) == 0) { sscanf(classified_topic,"::%255[^\n]",topic); } } else { strncpy(topic,classified_topic,CF_MAXVARSIZE-1); } if (strlen(context) == 0) { strcpy(context,"any"); } } /*********************************************************************/ static void DeClassifyCanonicalTopic(char *classified_topic,char *topic,char *context) { context[0] = '\0'; topic[0] = '\0'; if (*classified_topic == '.') { sscanf(classified_topic,".%255[^\n]",topic); } else if (strstr(classified_topic,".")) { sscanf(classified_topic,"%255[^.].%255[^\n]",context,topic); if (strlen(topic) == 0) { sscanf(classified_topic,".%255[^\n]",topic); } } else { strncpy(topic,classified_topic,CF_MAXVARSIZE-1); } if (strlen(context) == 0) { strcpy(context,"any"); } } /*********************************************************************/ static int ClassifiedTopicMatch(char *ttopic1,char *ttopic2) { char context1[CF_MAXVARSIZE],topic1[CF_MAXVARSIZE]; char context2[CF_MAXVARSIZE],topic2[CF_MAXVARSIZE]; if (strcmp(ttopic1,ttopic2) == 0) { return true; } context1[0] = '\0'; topic1[0] = '\0'; context2[0] = '\0'; topic2[0] = '\0'; DeClassifyTopic(ttopic1,topic1,context1); DeClassifyTopic(ttopic2,topic2,context2); if (strlen(context1) > 0 && strlen(context2) > 0) { if (strcmp(topic1,topic2) == 0 && strcmp(context1,context2) == 0) { return true; } } else { if (strcmp(topic1,topic2) == 0) { return true; } } return false; } /*****************************************************************************/ int GetTopicPid(char *classified_topic) { struct Topic *tp; int slot; char context[CF_MAXVARSIZE],name[CF_MAXVARSIZE]; name[0] = '\0'; DeClassifyTopic(classified_topic,name,context); slot = GetHash(ToLowerStr(name)); if ((tp = GetTopic(TOPICHASH[slot],classified_topic))) { return tp->id; } return 0; } /*****************************************************************************/ static char *URLHint(char *url) { char *sp; for (sp = url+strlen(url); *sp != '/'; sp--) { } return sp; } /*****************************************************************************/ /* Level */ /*****************************************************************************/ struct Topic *TopicExists(char *topic_name,char *topic_context) { struct Topic *tp; int slot; slot = GetHash(ToLowerStr(topic_name)); for (tp = TOPICHASH[slot]; tp != NULL; tp=tp->next) { if (strcmp(tp->topic_name,NormalizeTopic(topic_name)) == 0) { if (topic_context) { if (strlen(topic_context) > 0 && strcmp(tp->topic_context,NormalizeTopic(topic_context)) == 0) { return tp; } if (strlen(topic_context) == 0 && strcmp(tp->topic_context,"any") == 0) { return tp; } } } } return NULL; } /*****************************************************************************/ struct TopicAssociation *AssociationExists(struct TopicAssociation *list,char *fwd,char *bwd) { struct TopicAssociation *ta; int yfwd = false,ybwd = false; enum cfreport level; char l[CF_BUFSIZE],r[CF_BUFSIZE]; level = cf_verbose; if (fwd == NULL || (fwd && strlen(fwd) == 0)) { CfOut(cf_error,"","NULL forward association name\n"); return NULL; } if (bwd == NULL || (bwd && strlen(bwd) == 0)) { CfOut(cf_verbose,"","NULL backward association name\n"); } for (ta = list; ta != NULL; ta=ta->next) { if (fwd && (strcmp(fwd,ta->fwd_name) == 0)) { CfOut(cf_verbose,"","Association '%s' exists already\n",fwd); yfwd = true; } else if (fwd && ta->fwd_name) { strncpy(l,ToLowerStr(fwd),CF_MAXVARSIZE); strncpy(r,ToLowerStr(ta->fwd_name),CF_MAXVARSIZE); if (strcmp(l,r) == 0) { CfOut(cf_error,""," ! Association \"%s\" exists with different capitalization \"%s\"\n",fwd,ta->fwd_name); yfwd = true; } else { yfwd = false; } } else { yfwd = false; } if (bwd && (strcmp(bwd,ta->bwd_name) == 0)) { CfOut(cf_verbose,""," ! Association '%s' exists already\n",bwd); ybwd = true; } else if (bwd && ta->bwd_name) { strncpy(l,ToLowerStr(bwd),CF_MAXVARSIZE); strncpy(r,ToLowerStr(ta->bwd_name),CF_MAXVARSIZE); if (strcmp(l,r) == 0) { CfOut(cf_inform,""," ! Association \"%s\" exists with different capitalization \"%s\"\n",bwd,ta->bwd_name); } ybwd = true; } else { ybwd = false; } if (yfwd && ybwd) { return ta; } } return NULL; } /*****************************************************************************/ struct Occurrence *OccurrenceExists(struct Occurrence *list,char *locator,enum representations rep_type,char *context) { struct Occurrence *op; for (op = list; op != NULL; op=op->next) { if (strcmp(locator,op->locator) == 0 && strcmp(op->occurrence_context,context) == 0) { return op; } } return NULL; } /*****************************************************************************/ struct Topic *GetTopic(struct Topic *list,char *topic_name) { struct Topic *tp; char context[CF_MAXVARSIZE],name[CF_MAXVARSIZE]; strncpy(context,topic_name,CF_MAXVARSIZE-1); name[0] = '\0'; DeClassifyTopic(topic_name,name,context); for (tp = list; tp != NULL; tp=tp->next) { if (strlen(context) == 0) { if (strcmp(topic_name,tp->topic_name) == 0) { return tp; } } else { if ((strcmp(name,tp->topic_name)) == 0 && (strcmp(context,tp->topic_context) == 0)) { return tp; } } } return NULL; } /*****************************************************************************/ struct Topic *GetCanonizedTopic(struct Topic *list,char *topic_name) { struct Topic *tp; char context[CF_MAXVARSIZE],name[CF_MAXVARSIZE]; DeClassifyCanonicalTopic(topic_name,name,context); for (tp = list; tp != NULL; tp=tp->next) { if (strlen(context) == 0) { if (strcmp(name,CanonifyName(tp->topic_name)) == 0) { return tp; } } else { if ((strcmp(name,CanonifyName(tp->topic_name))) == 0 && (strcmp(context,CanonifyName(tp->topic_context)) == 0)) { return tp; } } } return NULL; } /*****************************************************************************/ static char *GetTopicContext(char *topic_name) { struct Topic *tp; static char context1[CF_MAXVARSIZE],topic1[CF_MAXVARSIZE]; int slot = GetHash(topic_name); context1[0] = '\0'; DeClassifyTopic(topic_name,topic1,context1); if (strlen(context1) > 0) { return context1; } for (tp = TOPICHASH[slot]; tp != NULL; tp=tp->next) { if (strcmp(topic1,tp->topic_name) == 0) { return tp->topic_context; } } return NULL; } /*****************************************************************************/ static char *NormalizeTopic(char *s) { char *sp; int special = false; for (sp = s; *sp != '\0'; sp++) { if (strchr("/\\&|=$@", *sp)) { special = true; break; } } if (special) { return s; } else { return ToLowerStr(s); } } cfengine-3.2.4/src/string_expressions.h0000644000175000017500000000570411715232734015142 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifndef CFENGINE_STRING_EXPRESSIONS_H #define CFENGINE_STRING_EXPRESSIONS_H /* String expressions grammar: ::= ::= ::= [a-zA-Z0-9_]+ ::= $( ) ${ } ::= . Subsequent s are concatenated during evaluation. */ typedef enum StringOp { CONCAT, LITERAL, VARREF } StringOp; typedef struct StringExpression { StringOp op; union StringExpressionValue { struct ConcatExpression { struct StringExpression *lhs; struct StringExpression *rhs; } concat; struct LiteralExpression { char *literal; } literal; struct VarRefExpression { struct StringExpression *name; } varref; } val; } StringExpression; /* Parsing and evaluation */ /* * Result of parsing. * * if succeeded, then result is the result of parsing and position is last * character consumed. * * if not succeded, then result is NULL and position is last character consumed * before the error. */ typedef struct StringParseResult { StringExpression *result; int position; } StringParseResult; StringParseResult ParseStringExpression(const char *expr, int start, int end); /* * Evaluator should return either heap-allocated string or NULL. In later case * evaluation will be aborted and NULL will be returned from * EvalStringExpression. */ typedef char * (*VarRefEvaluator)(const char *varname, void *param); /* * Result is heap-allocated. In case evalfn() returns NULL whole * EvalStringExpression returns NULL as well. */ char *EvalStringExpression(const StringExpression *expr, VarRefEvaluator evalfn, void *param); /* * Frees StringExpression produced by ParseStringExpression. NULL-safe. */ void FreeStringExpression(StringExpression *expr); #endif cfengine-3.2.4/src/cf3lex.l0000644000175000017500000001457411715233007012361 00000000000000%{ /* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*******************************************************************/ /* */ /* LEXER for cfengine 3 */ /* */ /*******************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #include "cf3parse.h" // Do not use lex - flex only %} %option noyywrap space [ \t]+ newline ([\n]|[\xd][\xa]) comment #[^\n]* promises bundle body body nakedvar [$@][(][a-zA-Z0-9_\200-\377.]+[)]|[$@][{][a-zA-Z0-9_\200-\377.]+[}] id [a-zA-Z0-9_\200-\377]+ assign => arrow -> /* * Three types of quoted strings: * * - string in double quotes, starts with double quote, runs until another * double quote, \" masks the double quote. * - string in single quotes, starts with single quote, runs until another * single quote, \' masks the single quote. * - string in backquotes, starts with backquote, runs until another backquote. * * The same rule formatted for the better readability: * * := \" \" | \' \' | ` ` * = * * = \\ | [^"\\] * = * * = \\ | [^'\\] * = * * = [^`] * = . | \n * */ qstring \"((\\(.|\n))|[^"\\])*\"|\'((\\(.|\n))|[^'\\])*\'|`[^`]*` class [.|&!()a-zA-Z0-9_\200-\377]+:: category [a-zA-Z_]+: %% {newline} { P.line_no++; P.line_pos = 0; } {promises} { /* Note this has to come before "id" since it is a subset of id */ if (P.currentclasses != NULL) { free(P.currentclasses); P.currentclasses = NULL; } P.line_pos += strlen(yytext); return BUNDLE; } {body} { /* Note this has to come before "id" since it is a subset of id */ if (P.currentclasses != NULL) { free(P.currentclasses); P.currentclasses = NULL; } P.line_pos += strlen(yytext); return BODY; } {id} { P.line_pos += strlen(yytext); if (strlen(yytext) > CF_MAXVARSIZE-1) { yyerror("identifier too long"); } strncpy(P.currentid,yytext,CF_MAXVARSIZE); return ID; } {assign} { P.line_pos += strlen(yytext); return ASSIGN; } {arrow} { P.line_pos += strlen(yytext); return ARROW; } {class} { P.line_pos += strlen(yytext); if (P.currentclasses != NULL) { free(P.currentclasses); } yytext[strlen(yytext)-2] = '\0'; ValidateClassSyntax(yytext); P.currentclasses = strdup(yytext); return CLASS; } {category} { P.line_pos += strlen(yytext); yytext[strlen(yytext)-1] = '\0'; strncpy(P.currenttype,yytext,CF_MAXVARSIZE); if (P.currentclasses != NULL) { free(P.currentclasses); P.currentclasses = NULL; } return CATEGORY; } {qstring} { char *tmp = NULL; int less = 0; P.line_pos += strlen(yytext); if ((tmp = malloc(strlen(yytext)+1)) == NULL) { FatalError("Malloc failure in parsing"); } if ((less = DeEscapeQuotedString(yytext,tmp)) > 0) { yyless(less); } if (P.currentstring) { free(P.currentstring); } P.currentstring = strdup(tmp); if (THIS_AGENT_TYPE == cf_common) { IsCf3VarString(tmp); } free(tmp); return QSTRING; } {nakedvar} { P.line_pos += strlen(yytext); P.currentstring = strdup(yytext); return NAKEDVAR; } {space}+ { P.line_pos += strlen(yytext); } {comment} { } . { P.line_pos++; return yytext[0]; } %% /* EOF */ cfengine-3.2.4/src/cfkey.c0000644000175000017500000001533511715232734012267 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: exec.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" int SHOWHOSTS = false; bool REMOVEKEYS = false; const char *remove_keys_host; void ShowLastSeenHosts(void); static int RemoveKeys(const char *host); int main (int argc,char *argv[]); /*******************************************************************/ /* Command line options */ /*******************************************************************/ const char *ID = "The cfengine's generator makes key pairs for remote authentication.\n"; const struct option OPTIONS[17] = { { "help",no_argument,0,'h' }, { "debug",optional_argument,0,'d' }, { "verbose",no_argument,0,'v' }, { "version",no_argument,0,'V' }, { "output-file",required_argument,0,'f'}, { "show-hosts",no_argument,0,'s'}, { "remove-keys",required_argument,0,'r'}, { NULL,0,0,'\0' } }; const char *HINTS[17] = { "Print the help message", "Set debugging level 0,1,2,3", "Output verbose information about the behaviour of the agent", "Output the version of the software", "Specify an alternative output file than the default (localhost)", "Show lastseen hostnames and IP addresses", "Remove keys for specified hostname/IP", NULL }; /*****************************************************************************/ int main(int argc,char *argv[]) { CheckOpts(argc,argv); THIS_AGENT_TYPE = cf_keygen; GenericInitialize(argc,argv,"keygenerator"); if (SHOWHOSTS) { ShowLastSeenHosts(); return 0; } if (REMOVEKEYS) { return RemoveKeys(remove_keys_host); } KeepKeyPromises(); return 0; } /*****************************************************************************/ /* Level */ /*****************************************************************************/ void CheckOpts(int argc,char **argv) { extern char *optarg; int optindex = 0; int c; while ((c=getopt_long(argc,argv,"d:vf:VMsr:",OPTIONS,&optindex)) != EOF) { switch ((char) c) { case 'f': snprintf(CFPRIVKEYFILE,CF_BUFSIZE,"%s.priv",optarg); snprintf(CFPUBKEYFILE,CF_BUFSIZE,"%s.pub",optarg); break; case 'd': switch ((optarg==NULL) ? '3' : *optarg) { case '1': D1 = true; DEBUG = true; break; case '2': D2 = true; DEBUG = true; break; default: DEBUG = true; break; } break; case 'V': PrintVersionBanner("cf-key"); exit(0); case 'v': VERBOSE = true; break; case 's': SHOWHOSTS = true; break; case 'r': REMOVEKEYS = true; remove_keys_host = optarg; break; case 'h': Syntax("cf-key - cfengine's key generator",OPTIONS,HINTS,ID); exit(0); case 'M': ManPage("cf-key - cfengine's key generator",OPTIONS,HINTS,ID); exit(0); default: Syntax("cf-key - cfengine's key generator",OPTIONS,HINTS,ID); exit(1); } } } /*****************************************************************************/ void ShowLastSeenHosts() { CF_DB *dbp; CF_DBC *dbcp; char *key; void *value; char name[CF_BUFSIZE],hostname[CF_BUFSIZE],address[CF_MAXVARSIZE]; struct CfKeyHostSeen entry; int ksize,vsize; int count = 0; snprintf(name,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,CF_LASTDB_FILE); MapName(name); if (!OpenDB(name,&dbp)) { return; } /* Acquire a cursor for the database. */ if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan last-seen database"); CloseDB(dbp); return; } /* Initialize the key/data return pair. */ printf("%9.9s %17.17s %-25.25s %15.15s\n","Direction","IP","Name","Key"); /* Walk through the database and print out the key/data pairs. */ while(NextDB(dbp,dbcp,&key,&ksize,&value,&vsize)) { if (value != NULL) { memset(&entry, 0, sizeof(entry)); memset(hostname, 0, sizeof(hostname)); memset(address, 0, sizeof(address)); memcpy(&entry,value,sizeof(entry)); strncpy(hostname,(char *)key,sizeof(hostname)-1); strncpy(address,(char *)entry.address,sizeof(address)-1); ++count; } else { continue; } CfOut(cf_verbose,""," -> Reporting on %s",hostname); printf("%-9.9s %17.17s %-25.25s %s\n", hostname[0] == '+' ? "Outgoing" : "Incoming", address, IPString2Hostname(address), hostname+1 ); } printf("Total Entries: %d\n",count); DeleteDBCursor(dbp,dbcp); CloseDB(dbp); } /*****************************************************************************/ static int RemoveKeys(const char *host) { RemoveHostFromLastSeen(host,NULL); int removed_keys = RemovePublicKeys(remove_keys_host); if (removed_keys < 0) { CfOut(cf_error, "", "Unable to remove keys for the host %s", remove_keys_host); return 255; } else if (removed_keys == 0) { CfOut(cf_error, "", "No keys for host %s were found", remove_keys_host); return 1; } else { CfOut(cf_inform, "", "Removed %d key(s) for host %s", removed_keys, remove_keys_host); return 0; } } cfengine-3.2.4/src/cf3globals.c0000644000175000017500000004667711715232734013222 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: cf3globals.c */ /* */ /* Created: Thu Aug 2 11:08:10 2007 */ /* */ /*****************************************************************************/ #include "cf3.defs.h" /*****************************************************************************/ /* flags */ /*****************************************************************************/ int SHOWREPORTS = false; /*****************************************************************************/ /* operational state */ /*****************************************************************************/ int VERBOSE = false; int INFORM = false; int PARSING = false; int CFPARANOID = false; int REQUIRE_COMMENTS = CF_UNDEFINED; int LOOKUP = false; int IGNORE_MISSING_INPUTS = false; int IGNORE_MISSING_BUNDLES = false; int FIPS_MODE = false; int ALWAYS_VALIDATE = false; struct utsname VSYSNAME; FILE *FREPORT_HTML = NULL; FILE *FREPORT_TXT = NULL; FILE *FKNOW = NULL; int XML = false; struct FnCallStatus FNCALL_STATUS; int CFA_MAXTHREADS = 10; int CFA_BACKGROUND = 0; int CFA_BACKGROUND_LIMIT = 1; int AM_BACKGROUND_PROCESS = false; int CF_PERSISTENCE = 10; char *THIS_BUNDLE = NULL; char THIS_AGENT[CF_MAXVARSIZE] = {0}; enum cfagenttype THIS_AGENT_TYPE; char SYSLOGHOST[CF_MAXVARSIZE] = {0}; unsigned short SYSLOGPORT = 514; time_t PROMISETIME = 0; time_t CF_LOCKHORIZON = CF_MONTH; int LICENSES = 0; int AM_NOVA = false; int AM_CONSTELLATION = false; char EXPIRY[CF_SMALLBUF] = {0}; char LICENSE_COMPANY[CF_SMALLBUF] = {0}; int INSTALL_SKIP = false; int KEYTTL = 0; // These are used to measure graph complexity in know/agent int CSV=false; int CF_TOPICS = 0; // objects int CF_OCCUR = 0; // objects int CF_EDGES = 0; // links or promises between them struct Rlist *MOUNTEDFSLIST = NULL; struct Rlist *SERVERLIST = NULL; struct PromiseIdent *PROMISE_ID_LIST = NULL; struct Item *PROCESSTABLE = NULL; struct Item *PROCESSREFRESH = NULL; struct Item *ROTATED = NULL; struct Item *FSTABLIST = NULL; struct Item *ABORTBUNDLEHEAP = NULL; struct Item *DONELIST = NULL; struct Rlist *CBUNDLESEQUENCE = NULL; struct Rlist *SERVER_KEYSEEN = NULL; char *CBUNDLESEQUENCE_STR; int EDIT_MODEL = false; int CF_MOUNTALL = false; int FSTAB_EDITS; int ABORTBUNDLE = false; int BOOTSTRAP = false; char HASHDB[CF_BUFSIZE] = {0}; /*****************************************************************************/ /* Measurements */ /*****************************************************************************/ double METER_KEPT[meter_endmark]; double METER_REPAIRED[meter_endmark]; double Q_MEAN; double Q_SIGMA; /*****************************************************************************/ /* Internal data structures */ /*****************************************************************************/ struct PromiseParser P = {0}; struct Bundle *BUNDLES = NULL; struct Body *BODIES = NULL; struct Scope *VSCOPE = NULL; struct Rlist *VINPUTLIST = NULL; struct Rlist *BODYPARTS = NULL; struct Rlist *SUBBUNDLES = NULL; struct Rlist *ACCESSLIST = NULL; struct Rlist *SINGLE_COPY_LIST = NULL; struct Rlist *AUTO_DEFINE_LIST = NULL; struct Rlist *SINGLE_COPY_CACHE = NULL; struct Rlist *CF_STCK = NULL; struct Item *EDIT_ANCHORS = NULL; int CF_STCKFRAME = 0; int LASTSEENEXPIREAFTER = CF_WEEK; char POLICY_SERVER[CF_BUFSIZE] = {0}; char WEBDRIVER[CF_MAXVARSIZE] = {0}; char DOCROOT[CF_MAXVARSIZE] = {0}; char BANNER[2*CF_BUFSIZE] = {0}; char FOOTER[CF_BUFSIZE] = {0}; char STYLESHEET[CF_BUFSIZE] = {0}; struct Topic *TOPICHASH[CF_HASHTABLESIZE]; char SQL_DATABASE[CF_MAXVARSIZE] = {0}; char SQL_OWNER[CF_MAXVARSIZE] = {0}; char SQL_PASSWD[CF_MAXVARSIZE] = {0}; char SQL_SERVER[CF_MAXVARSIZE] = {0}; char SQL_CONNECT_NAME[CF_MAXVARSIZE] = {0}; enum cfdbtype SQL_TYPE = cfd_notype; /*****************************************************************************/ /* Windows version constants */ /*****************************************************************************/ unsigned int WINVER_MAJOR = 0; unsigned int WINVER_MINOR = 0; unsigned int WINVER_BUILD = 0; /*****************************************************************************/ /* Constants */ /*****************************************************************************/ struct SubTypeSyntax CF_NOSTYPE = {NULL,NULL,NULL}; /*********************************************************************/ /* Object variables */ /*********************************************************************/ char *DAY_TEXT[] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", NULL }; char *MONTH_TEXT[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", NULL }; char *SHIFT_TEXT[] = { "Night", "Morning", "Afternoon", "Evening", NULL }; /*****************************************************************************/ char *CF_DATATYPES[] = /* see enum cfdatatype */ { "string", "int", "real", "slist", "ilist", "rlist", "(menu option)", "(option list)", "(ext body)", "(ext bundle)", "class", "clist", "irange [int,int]", "rrange [real,real]", "counter", "", }; /*****************************************************************************/ char *CF_AGENTTYPES[] = /* see enum cfagenttype */ { CF_COMMONC, CF_AGENTC, CF_SERVERC, CF_MONITORC, CF_EXECC, CF_RUNC, CF_KNOWC, CF_REPORTC, CF_KEYGEN, CF_HUBC, "", }; /*****************************************************************************/ /* Compatability infrastructure */ /*****************************************************************************/ double FORGETRATE = 0.7; int IGNORELOCK = false; int DONTDO = false; int DEBUG = false; int D1 = false; int D2 = false; int AUDIT = false; int LOGGING = false; char VFQNAME[CF_MAXVARSIZE] = {0}; char VUQNAME[CF_MAXVARSIZE] = {0}; char VDOMAIN[CF_MAXVARSIZE] = {0}; char VYEAR[5] = {0}; char VDAY[3] = {0}; char VMONTH[4] = {0}; char VSHIFT[12] = {0}; char PADCHAR = ' '; char PURGE = 'n'; int ERRORCOUNT = 0; char VPREFIX[CF_MAXVARSIZE] = {0}; char VINPUTFILE[CF_BUFSIZE] = {0}; char CONTEXTID[32] = {0}; char CFPUBKEYFILE[CF_BUFSIZE] = {0}; char CFPRIVKEYFILE[CF_BUFSIZE] = {0}; char AVDB[CF_MAXVARSIZE] = {0}; char CFWORKDIR[CF_BUFSIZE] = {0}; char PIDFILE[CF_BUFSIZE] = {0}; char *DEFAULT_COPYTYPE = NULL; RSA *PRIVKEY = NULL, *PUBKEY = NULL; char PUBKEY_DIGEST[CF_MAXVARSIZE] = {0}; pthread_attr_t PTHREADDEFAULTS; #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP pthread_mutex_t MUTEX_SYSCALL = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; pthread_mutex_t MUTEX_LOCK = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; pthread_mutex_t MUTEX_COUNT = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; pthread_mutex_t MUTEX_OUTPUT = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; pthread_mutex_t MUTEX_DBHANDLE = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; pthread_mutex_t MUTEX_POLICY = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; pthread_mutex_t MUTEX_GETADDR = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; pthread_mutex_t MUTEX_DB_LASTSEEN = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; pthread_mutex_t MUTEX_DB_REPORT = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; pthread_mutex_t MUTEX_VSCOPE = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; pthread_mutex_t MUTEX_SERVER_KEYSEEN = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; pthread_mutex_t MUTEX_SERVER_CHILDREN = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; #else # if defined HAVE_PTHREAD_H && (defined HAVE_LIBPTHREAD || defined BUILDTIN_GCC_THREAD) pthread_mutex_t MUTEX_SYSCALL = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t MUTEX_LOCK = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t MUTEX_COUNT = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t MUTEX_OUTPUT = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t MUTEX_DBHANDLE = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t MUTEX_POLICY = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t MUTEX_GETADDR = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t MUTEX_DB_LASTSEEN = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t MUTEX_DB_REPORT = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t MUTEX_VSCOPE = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t MUTEX_SERVER_KEYSEEN = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t MUTEX_SERVER_CHILDREN = PTHREAD_MUTEX_INITIALIZER; # endif #endif char VIPADDRESS[18] = {0}; int CFSIGNATURE = 0; char *PROTOCOL[] = { "EXEC", "AUTH", /* old protocol */ "GET", "OPENDIR", "SYNCH", "CLASSES", "MD5", "SMD5", "CAUTH", "SAUTH", "SSYNCH", "SGET", "VERSION", "SOPENDIR", "VAR", "SVAR", "CONTEXT", "SCONTEXT", "SQUERY", NULL }; struct Item *IPADDRESSES = NULL; int PR_KEPT = 0; int PR_REPAIRED = 0; int PR_NOTKEPT = 0; double VAL_KEPT = 0; double VAL_REPAIRED = 0; double VAL_NOTKEPT = 0; /*******************************************************************/ /* Context Management */ /*******************************************************************/ struct AlphaList VHEAP; struct AlphaList VADDCLASSES; struct Item *VNEGHEAP = NULL; struct Item *VDELCLASSES = NULL; struct Rlist *PRIVCLASSHEAP = NULL; struct Rlist *GOALS = NULL; struct Rlist *GOALCATEGORIES = NULL; /*******************************************************************/ /* */ /* Checksums */ /* */ /*******************************************************************/ /* These string lengths should not exceed CF_MAXDIGESTNAMELEN characters for packing */ char *CF_DIGEST_TYPES[10][2] = { {"md5","m"}, {"sha224","c"}, {"sha256","C"}, {"sha384","h"}, {"sha512","H"}, {"sha1","S"}, {"sha","s"}, /* Should come last, since substring */ {"best","b"}, {"crypt","o"}, {NULL,NULL} }; int CF_DIGEST_SIZES[10] = { CF_MD5_LEN, CF_SHA224_LEN, CF_SHA256_LEN, CF_SHA384_LEN, CF_SHA512_LEN, CF_SHA1_LEN, CF_SHA_LEN, CF_BEST_LEN, CF_CRYPT_LEN, 0 }; enum cfhashes CF_DEFAULT_DIGEST; int CF_DEFAULT_DIGEST_LEN; /***********************************************************/ struct Audit *AUDITPTR; struct Audit *VAUDIT = NULL; CF_DB *AUDITDBP = NULL; char GRAPHDIR[CF_BUFSIZE] = {0}; char CFLOCK[CF_BUFSIZE] = {0}; char CFLOG[CF_BUFSIZE] = {0}; char CFLAST[CF_BUFSIZE] = {0}; char LOCKDB[CF_BUFSIZE] = {0}; char LOGFILE[CF_MAXVARSIZE] = {0}; char *SIGNALS[highest_signal]; time_t CFSTARTTIME; time_t CFINITSTARTTIME; char STR_CFENGINEPORT[16] = {0}; unsigned short SHORT_CFENGINEPORT; time_t CONNTIMEOUT = 10; /* seconds */ time_t RECVTIMEOUT = 30; /* seconds */ int RPCTIMEOUT = 60; /* seconds */ pid_t ALARM_PID = -1; int SKIPIDENTIFY = false; int EDITFILESIZE = 10000; int EDITBINFILESIZE = 100000; int VIFELAPSED = 1; int VEXPIREAFTER = 120; int CHECKSUMUPDATES = false; char BINDINTERFACE[CF_BUFSIZE] = {0}; int MINUSF = false; int EXCLAIM = true; mode_t DEFAULTMODE = (mode_t) 0755; char *VREPOSITORY = NULL; char REPOSCHAR = '_'; struct Item *VDEFAULTROUTE=NULL; struct Item *VSETUIDLIST = NULL; struct Item *SUSPICIOUSLIST = NULL; enum classes VSYSTEMHARDCLASS = unused1; struct Item *NONATTACKERLIST = NULL; struct Item *MULTICONNLIST = NULL; struct Item *TRUSTKEYLIST = NULL; struct Item *DHCPLIST = NULL; struct Item *ALLOWUSERLIST = NULL; struct Item *SKIPVERIFY = NULL; struct Item *ATTACKERLIST = NULL; struct Item *ABORTHEAP = NULL; struct Item *VREPOSLIST=NULL; /*******************************************************************/ /* Anomaly */ /*******************************************************************/ struct sock ECGSOCKS[ATTR] = /* extended to map old to new using enum*/ { {"137","netbiosns",ob_netbiosns_in,ob_netbiosns_out}, {"138","netbiosdgm",ob_netbiosdgm_in,ob_netbiosdgm_out}, {"139","netbiosssn",ob_netbiosssn_in,ob_netbiosssn_out}, {"194","irc",ob_irc_in,ob_irc_out}, {"5308","cfengine",ob_cfengine_in,ob_cfengine_out}, {"2049","nfsd",ob_nfsd_in,ob_nfsd_out}, {"25","smtp",ob_smtp_in,ob_smtp_out}, {"80","www",ob_www_in,ob_www_out}, {"21","ftp",ob_ftp_in,ob_ftp_out}, {"22","ssh",ob_ssh_in,ob_ssh_out}, {"443","wwws",ob_wwws_in,ob_wwws_out} }; char *TCPNAMES[CF_NETATTR] = { "icmp", "udp", "dns", "tcpsyn", "tcpack", "tcpfin", "misc" }; char *OBS[CF_OBSERVABLES][2] = { {"users","Users with active processes"}, {"rootprocs","Sum privileged system processes"}, {"otherprocs","Sum non-privileged process"}, {"diskfree","Free disk on / partition"}, {"loadavg","Kernel load average utilization (sum over cores)"}, {"netbiosns_in","netbios name lookups (in)"}, {"netbiosns_out","netbios name lookups (out)"}, {"netbiosdgm_in","netbios name datagrams (in)"}, {"netbiosdgm_out","netbios name datagrams (out)"}, {"netbiosssn_in","netbios name sessions (in)"}, {"netbiosssn_out","netbios name sessions (out)"}, {"irc_in","IRC connections (in)"}, {"irc_out","IRC connections (out)"}, {"cfengine_in","cfengine connections (in)"}, {"cfengine_out","cfengine connections (out)"}, {"nfsd_in","nfs connections (in)"}, {"nfsd_out","nfs connections (out)"}, {"smtp_in","smtp connections (in)"}, {"smtp_out","smtp connections (out)"}, {"www_in","www connections (in)"}, {"www_out","www connections (out)"}, {"ftp_in","ftp connections (in)"}, {"ftp_out","ftp connections (out)"}, {"ssh_in","ssh connections (in)"}, {"ssh_out","ssh connections (out)"}, {"wwws_in","wwws connections (in)"}, {"wwws_out","wwws connections (out)"}, {"icmp_in","ICMP packets (in)"}, {"icmp_out","ICMP packets (out)"}, {"udp_in","UDP dgrams (in)"}, {"udp_out","UDP dgrams (out)"}, {"dns_in","DNS requests (in)"}, {"dns_out","DNS requests (out)"}, {"tcpsyn_in","TCP sessions (in)"}, {"tcpsyn_out","TCP sessions (out)"}, {"tcpack_in","TCP acks (in)"}, {"tcpack_out","TCP acks (out)"}, {"tcpfin_in","TCP finish (in)"}, {"tcpfin_out","TCP finish (out)"}, {"tcpmisc_in","TCP misc (in)"}, {"tcpmisc_out","TCP misc (out)"}, {"webaccess","Webserver hits"}, {"weberrors","Webserver errors"}, {"syslog","New log entries (Syslog)"}, {"messages","New log entries (messages)"}, {"temp0","CPU Temperature 0"}, {"temp1","CPU Temperature 1"}, {"temp2","CPU Temperature 2"}, {"temp3","CPU Temperature 3"}, {"cpu","%CPU utilization (all)"}, {"cpu0","%CPU utilization 0"}, {"cpu1","%CPU utilization 1"}, {"cpu2","%CPU utilization 2"}, {"cpu3","%CPU utilization 3"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, {"spare","unused"}, }; /**********************************************************************************/ /* Report names */ /**********************************************************************************/ // See enum in cf3.defs.h char *BASIC_REPORTS[cfrep_unknown+1][2] = { {"Bundle profile","Status of promise bundles and when they were last verified"}, {"Business value report","Accumulated value of promises kept"}, {"Class profile","User defined classes observed on the system"}, {"Compliance by promise","Compliance of each promise individually"}, {"Compliance summary","Total summary of host compliance"}, {"File change log","Log of all detected changes to files from changes promises"}, {"File change diffs","Delta/difference comparison showing file changes"}, {"Last saw hosts","Log of when neighbouring hosts were last observed online"}, {"Patches available","A list of patches currently claimed to be available by the local package manager"}, {"Patch status","A list of (un)applied patches according to the local package manager"}, {"Performance","Execution time used to verify selected promises"}, {"Promises repaired log","Log of actual repairs made to the system"}, {"Promises repaired summary","Cumulative (histogram) summary of promises repaired"}, {"Promises not kept log","Log of promises that could not or would not be kept"}, {"Promises not kept summary","Cumulative (histogram) summary of promises not kept"}, {"Setuid/gid root programs","Current list of observed setuid/setgid root programs"}, {"Software installed","List of software packages claimed to be installed according to the local package manager"}, {"Variables","Table of variable values last observed"}, {NULL,NULL} }; // See enum in cf3.defs.h char *CDP_REPORTS[cdp_unknown+1][2] = { {"ACLs","File access controls"}, {"Commands","Scheduled commands to execute"}, {"File Changes","File changes observed on the system"}, {"File Diffs","Delta/difference comparison showing file changes"}, {"Registry","Promised Windows registry setting status"}, {"Services","System services status"}, {NULL,NULL} }; cfengine-3.2.4/src/matching.c0000644000175000017500000006520711715232734012763 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: matching.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #ifdef HAVE_PCRE_H #include #endif #ifdef HAVE_PCRE_PCRE_H #include #endif struct CfRegEx { int failed; const char *regexp; pcre *rx; const char *err; int err_offset; }; static int FullTextCaseMatch (char *regexp,const char *teststring); static int BlockTextCaseMatch(char *regexp,char *teststring,int *start,int *end); /*********************************************************************/ /* Wrappers */ /*********************************************************************/ static struct CfRegEx CompileRegExp(const char *regexp) { struct CfRegEx this; pcre *rx; const char *errorstr; int erroffset; memset(&this,0,sizeof(struct CfRegEx)); rx = pcre_compile(regexp,PCRE_MULTILINE|PCRE_DOTALL,&errorstr,&erroffset,NULL); if (rx == NULL) { CfOut(cf_error,"","Regular expression error \"%s\" in expression \"%s\" at %d\n",errorstr,regexp,erroffset); this.failed = true; } else { this.failed = false; this.rx = rx; } this.regexp = regexp; return this; } /*********************************************************************/ static struct CfRegEx CaseCompileRegExp(const char *regexp) { struct CfRegEx this; pcre *rx; const char *errorstr; int erroffset; memset(&this,0,sizeof(struct CfRegEx)); rx = pcre_compile(regexp,PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL,&errorstr,&erroffset,NULL); if (rx == NULL) { CfOut(cf_error,"","Regular expression error %s in %s at %d: %s\n",errorstr,regexp,erroffset); this.failed = true; } else { this.failed = false; this.rx = rx; } this.regexp = regexp; return this; } /*********************************************************************/ static int RegExMatchSubString(struct CfRegEx rex,char *teststring,int *start,int *end) { pcre *rx; int ovector[OVECCOUNT],i,rc; rx = rex.rx; if ((rc = pcre_exec(rx,NULL,teststring,strlen(teststring),0,0,ovector,OVECCOUNT)) >= 0) { *start = ovector[0]; *end = ovector[1]; DeleteScope("match"); NewScope("match"); for (i = 0; i < rc; i++) /* make backref vars $(1),$(2) etc */ { char substring[CF_MAXVARSIZE]; char lval[4]; char *backref_start = teststring + ovector[i*2]; int backref_len = ovector[i*2+1] - ovector[i*2]; if (backref_len < CF_MAXVARSIZE) { memset(substring,0,CF_MAXVARSIZE); strncpy(substring,backref_start,backref_len); snprintf(lval,3,"%d",i); ForceScalar(lval,substring); } } pcre_free(rx); return true; } else { *start = 0; *end = 0; pcre_free(rx); return false; } } /*********************************************************************/ static int RegExMatchFullString(struct CfRegEx rex, const char *teststring) { pcre *rx; int ovector[OVECCOUNT],i,rc,match_len; const char *match_start; rx = rex.rx; if ((rc = pcre_exec(rx,NULL,teststring,strlen(teststring),0,0,ovector,OVECCOUNT)) >= 0) { match_start = teststring + ovector[0]; match_len = ovector[1] - ovector[0]; DeleteScope("match"); NewScope("match"); for (i = 0; i < rc; i++) /* make backref vars $(1),$(2) etc */ { char substring[CF_MAXVARSIZE]; char lval[4]; const char *backref_start = teststring + ovector[i*2]; int backref_len = ovector[i*2+1] - ovector[i*2]; memset(substring,0,CF_MAXVARSIZE); if (backref_len < CF_MAXVARSIZE) { strncpy(substring,backref_start,backref_len); snprintf(lval,3,"%d",i); ForceScalar(lval,substring); } } if (rx) { pcre_free(rx); } if ((match_start == teststring) && (match_len == strlen(teststring))) { return true; } else { return false; } } else { pcre_free(rx); return false; } } /*********************************************************************/ static char *FirstBackReference(struct CfRegEx rex,char *regex, const char *teststring) { static char backreference[CF_BUFSIZE]; pcre *rx; int ovector[OVECCOUNT],i,rc,match_len; const char *match_start; rx = rex.rx; memset(backreference,0,CF_BUFSIZE); if ((rc = pcre_exec(rx,NULL,teststring,strlen(teststring),0,0,ovector,OVECCOUNT)) >= 0) { match_start = teststring + ovector[0]; match_len = ovector[1] - ovector[0]; for (i = 1; i < rc; i++) /* make backref vars $(1),$(2) etc */ { const char *backref_start = teststring + ovector[i*2]; int backref_len = ovector[i*2+1] - ovector[i*2]; if (backref_len < CF_MAXVARSIZE) { strncpy(backreference,backref_start,backref_len); } break; } } pcre_free(rx); if (strlen(backreference) == 0) { Debug("The regular expression \"%s\" yielded no matching back-reference\n",regex); strncpy(backreference,"CF_NOMATCH",CF_MAXVARSIZE); } else { Debug("The regular expression \"%s\" yielded backreference \"%s\" on %s\n",regex,backreference,teststring); } return backreference; } bool ValidateRegEx(const char *regex) { struct CfRegEx rex = CompileRegExp(regex); return !rex.failed; } /*************************************************************************/ /* WILDCARD TOOLKIT : Level 0 */ /*************************************************************************/ int FullTextMatch(char *regexp,const char *teststring) { struct CfRegEx rex; if (strcmp(regexp,teststring) == 0) { return true; } rex = CompileRegExp(regexp); if (rex.failed) { CfOut(cf_error,"","!! Could not parse regular expression '%s'", regexp); return false; } if (RegExMatchFullString(rex,teststring)) { return true; } else { return false; } } /*************************************************************************/ char *ExtractFirstReference(char *regexp, const char *teststring) { struct CfRegEx rex; static char *nothing = ""; if (regexp == NULL || teststring == NULL) { return nothing; } rex = CompileRegExp(regexp); if (rex.failed) { return nothing; } return FirstBackReference(rex,regexp,teststring); } /*************************************************************************/ static int FullTextCaseMatch (char *regexp, const char *teststring) { struct CfRegEx rex; rex = CaseCompileRegExp(regexp); if (rex.failed) { return 0; } if (RegExMatchFullString(rex,teststring)) { return true; } else { return false; } } /*************************************************************************/ int BlockTextMatch(char *regexp,char *teststring,int *start,int *end) { struct CfRegEx rex; rex = CompileRegExp(regexp); if (rex.failed) { return 0; } if (RegExMatchSubString(rex,teststring,start,end)) { return true; } else { return false; } } /*************************************************************************/ static int BlockTextCaseMatch(char *regexp,char *teststring,int *start,int *end) { struct CfRegEx rex; rex = CaseCompileRegExp(regexp); if (rex.failed) { return 0; } if (RegExMatchSubString(rex,teststring,start,end)) { return true; } else { return false; } } /*********************************************************************/ int IsRegex(char *str) { char *sp; int ret = false; enum { r_norm, r_norepeat, r_literal } special = r_norepeat; int bracket = 0; int paren = 0; /* Try to see when something is intended as a regular expression */ for (sp = str; *sp != '\0'; sp++) { if (special == r_literal) { special = r_norm; continue; } else if (*sp == '\\') { special = r_literal; continue; } else if (bracket && *sp != ']') { if (*sp == '[') { return false; } continue; } switch (*sp) { case '^': special = (sp == str) ? r_norepeat : r_norm; break; case '*': case '+': if (special == r_norepeat) { return false; } special = r_norepeat; ret = true; break; case '[': special = r_norm; bracket++; ret = true; break; case ']': if (bracket == 0) { return false; } bracket = 0; special = r_norm; break; case '(': special = r_norepeat; paren++; break; case ')': special = r_norm; paren--; if (paren < 0) { return false; } break; case '|': special = r_norepeat; if (paren > 0) { ret = true; } break; default: special = r_norm; } } if (bracket != 0 || paren != 0 || special == r_literal) { return false; } else { return ret; } } /*********************************************************************/ int IsPathRegex(char *str) { char *sp; int result = false,s = 0,r = 0; if ((result = IsRegex(str))) { for (sp = str; *sp != '\0'; sp++) { switch(*sp) { case '[': s++; break; case ']': s--; if (s % 2 == 0) { result++; } break; case '(': r++; break; case')': r--; if (r % 2 == 0) { result++; } break; default: if (*sp == FILE_SEPARATOR && (r || s)) { CfOut(cf_error,"","Path regular expression %s seems to use expressions containing the directory symbol %c",str,FILE_SEPARATOR); CfOut(cf_error,"","Use a work-around to avoid pathological behaviour\n"); return false; } break; } } } return result; } /*********************************************************************/ int IsRegexItemIn(struct Item *list,char *regex) /* Checks whether item matches a list of wildcards */ { struct Item *ptr; for (ptr = list; ptr != NULL; ptr=ptr->next) { if (ptr->classes && IsExcluded(ptr->classes)) { continue; } /* Avoid using regex if possible, due to memory leak */ if (strcmp(regex,ptr->name) == 0) { return(true); } /* Make it commutative */ if (FullTextMatch(regex,ptr->name) || FullTextMatch(ptr->name,regex)) { Debug("IsRegexItem(%s,%s)\n",regex,ptr->name); return(true); } } return(false); } /*********************************************************************/ int MatchPolicy(char *camel,char *haystack,struct Attributes a,struct Promise *pp) { struct Rlist *rp; char *sp,*spto,*firstchar,*lastchar; enum insert_match opt; char work[CF_BUFSIZE],final[CF_BUFSIZE]; struct Item *list = SplitString(camel,'\n'),*ip; int direct_cmp = false, ok = false; //Split into separate lines first for (ip = list; ip != NULL; ip = ip->next) { ok = false; direct_cmp = (strcmp(camel,haystack) == 0); if (a.insert_match == NULL) { // No whitespace policy means exact_match ok = ok || direct_cmp; break; } memset(final,0,CF_BUFSIZE); strncpy(final,ip->name,CF_BUFSIZE-1); for (rp = a.insert_match; rp != NULL; rp=rp->next) { opt = String2InsertMatch(rp->item); /* Exact match can be done immediately */ if (opt == cf_exact_match) { if (rp->next != NULL || rp != a.insert_match) { CfOut(cf_error,""," !! Multiple policies conflict with \"exact_match\", using exact match"); PromiseRef(cf_error,pp); } ok = ok || direct_cmp; break; } if (opt == cf_ignore_embedded) { memset(work,0,CF_BUFSIZE); // Strip initial and final first for (firstchar = final; isspace(*firstchar); firstchar++) { } for (lastchar = final+strlen(final)-1; lastchar > firstchar && isspace(*lastchar); lastchar--) { } for (sp = final,spto = work; *sp != '\0'; sp++) { if (sp > firstchar && sp < lastchar) { if (isspace(*sp)) { while (isspace(*(sp+1))) { sp++; } strcat(spto,"\\s+"); spto += 3; } else { *spto++ = *sp; } } else { *spto++ = *sp; } } strcpy(final,work); } if (opt == cf_ignore_leading) { if (strncmp(final,"\\s*",3) != 0) { for (sp = final; isspace(*sp); sp++) { } strcpy(work,sp); snprintf(final,CF_BUFSIZE,"\\s*%s",work); } } if (opt == cf_ignore_trailing) { if (strncmp(final+strlen(final)-4,"\\s*",3) != 0) { strcpy(work,final); snprintf(final,CF_BUFSIZE,"%s\\s*",work); } } ok = ok || FullTextMatch(final,haystack); } if (!ok) // All lines in region need to match to avoid insertions { break; } strcmp(final,work); } DeleteItemList(list); return ok; } /*********************************************************************/ int MatchRlistItem(struct Rlist *listofregex, const char *teststring) /* Checks whether item matches a list of wildcards */ { struct Rlist *rp; for (rp = listofregex; rp != NULL; rp=rp->next) { /* Avoid using regex if possible, due to memory leak */ if (strcmp(teststring,rp->item) == 0) { return(true); } /* Make it commutative */ if (FullTextMatch(rp->item,teststring)) { Debug("MatchRlistItem(%s > %s)\n", (char *)rp->item, teststring); return true; } } return false; } /*********************************************************************/ /* Enumerated languages - fuzzy match model */ /*********************************************************************/ int FuzzyMatchParse(char *s) { char *sp; short isCIDR = false, isrange = false, isv6 = false, isv4 = false, isADDR = false; char address[CF_ADDRSIZE]; int mask,count = 0; Debug("Check ParsingIPRange(%s)\n",s); for (sp = s; *sp != '\0'; sp++) /* Is this an address or hostname */ { if (!isxdigit((int)*sp)) { isADDR = false; break; } if (*sp == ':') /* Catches any ipv6 address */ { isADDR = true; break; } if (isdigit((int)*sp)) /* catch non-ipv4 address - no more than 3 digits */ { count++; if (count > 3) { isADDR = false; break; } } else { count = 0; } } if (! isADDR) { return true; } if (strstr(s,"/") != 0) { isCIDR = true; } if (strstr(s,"-") != 0) { isrange = true; } if (strstr(s,".") != 0) { isv4 = true; } if (strstr(s,":") != 0) { isv6 = true; } if (isv4 && isv6) { CfOut(cf_error,"","Mixture of IPv6 and IPv4 addresses"); return false; } if (isCIDR && isrange) { CfOut(cf_error,"","Cannot mix CIDR notation with xx-yy range notation"); return false; } if (isv4 && isCIDR) { if (strlen(s) > 4+3*4+1+2) /* xxx.yyy.zzz.mmm/cc */ { CfOut(cf_error,"","IPv4 address looks too long"); return false; } address[0] = '\0'; mask = 0; sscanf(s,"%16[^/]/%d",address,&mask); if (mask < 8) { CfOut(cf_error,"","Mask value %d in %s is less than 8",mask,s); return false; } if (mask > 30) { CfOut(cf_error,"","Mask value %d in %s is silly (> 30)",mask,s); return false; } } if (isv4 && isrange) { long i, from = -1, to = -1; char *sp1,buffer1[CF_MAX_IP_LEN]; sp1 = s; for (i = 0; i < 4; i++) { buffer1[0] = '\0'; sscanf(sp1,"%[^.]",buffer1); sp1 += strlen(buffer1)+1; if (strstr(buffer1,"-")) { sscanf(buffer1,"%ld-%ld",&from,&to); if (from < 0 || to < 0) { CfOut(cf_error,"","Error in IP range - looks like address, or bad hostname"); return false; } if (to < from) { CfOut(cf_error,"","Bad IP range"); return false; } } } } if (isv6 && isCIDR) { char address[CF_ADDRSIZE]; int mask,blocks; if (strlen(s) < 20) { CfOut(cf_error,"","IPv6 address looks too short"); return false; } if (strlen(s) > 42) { CfOut(cf_error,"","IPv6 address looks too long"); return false; } address[0] = '\0'; mask = 0; sscanf(s,"%40[^/]/%d",address,&mask); blocks = mask/8; if (mask % 8 != 0) { CfOut(cf_error,"","Cannot handle ipv6 masks which are not 8 bit multiples (fix me)"); return false; } if (mask > 15) { CfOut(cf_error,"","IPv6 CIDR mask is too large"); return false; } } return true; } /*********************************************************************/ int FuzzySetMatch(char *s1,char *s2) /* Match two IP strings - with : or . in hex or decimal s1 is the test string, and s2 is the reference e.g. FuzzySetMatch("128.39.74.10/23","128.39.75.56") == 0 */ { short isCIDR = false, isrange = false, isv6 = false, isv4 = false; char address[CF_ADDRSIZE]; int mask; unsigned long a1,a2; if (strcmp(s1,s2) == 0) { return 0; } if (strstr(s1,"/") != 0) { isCIDR = true; } if (strstr(s1,"-") != 0) { isrange = true; } if (strstr(s1,".") != 0) { isv4 = true; } if (strstr(s1,":") != 0) { isv6 = true; } if (strstr(s2,".") != 0) { isv4 = true; } if (strstr(s2,":") != 0) { isv6 = true; } if (isv4 && isv6) { /* This is just wrong */ return -1; } if (isCIDR && isrange) { CfOut(cf_error,"","Cannot mix CIDR notation with xxx-yyy range notation: %s",s1); return -1; } if (!(isv6 || isv4)) { CfOut(cf_error,"","Not a valid address range - or not a fully qualified name: %s",s1); return -1; } if (!(isrange||isCIDR)) { if (strlen(s2) > strlen(s1)) { if (*(s2+strlen(s1)) != '.') { return -1; // Because xxx.1 should not match xxx.12 in the same octet } } return strncmp(s1,s2,strlen(s1)); /* do partial string match */ } if (isv4) { if (isCIDR) { struct sockaddr_in addr1,addr2; int shift; address[0] = '\0'; mask = 0; sscanf(s1,"%16[^/]/%d",address,&mask); shift = 32 - mask; sockaddr_pton(AF_INET, address, &addr1); sockaddr_pton(AF_INET, s2, &addr2); a1 = htonl(addr1.sin_addr.s_addr); a2 = htonl(addr2.sin_addr.s_addr); a1 = a1 >> shift; a2 = a2 >> shift; if (a1 == a2) { return 0; } else { return -1; } } else { long i, from = -1, to = -1, cmp = -1; char *sp1,*sp2,buffer1[CF_MAX_IP_LEN],buffer2[CF_MAX_IP_LEN]; sp1 = s1; sp2 = s2; for (i = 0; i < 4; i++) { buffer1[0] = '\0'; sscanf(sp1,"%[^.]",buffer1); if (strlen(buffer1) == 0) { break; } sp1 += strlen(buffer1)+1; sscanf(sp2,"%[^.]",buffer2); sp2 += strlen(buffer2)+1; if (strstr(buffer1,"-")) { sscanf(buffer1,"%ld-%ld",&from,&to); sscanf(buffer2,"%ld",&cmp); if (from < 0 || to < 0) { Debug("Couldn't read range\n"); return -1; } if ((from > cmp) || (cmp > to)) { Debug("Out of range %ld > %ld > %ld (range %s)\n",from,cmp,to,buffer2); return -1; } } else { sscanf(buffer1,"%ld",&from); sscanf(buffer2,"%ld",&cmp); if (from != cmp) { Debug("Unequal\n"); return -1; } } Debug("Matched octet %s with %s\n",buffer1,buffer2); } Debug("Matched IP range\n"); return 0; } } #if defined(HAVE_GETADDRINFO) if (isv6) { int i; if (isCIDR) { int blocks; struct sockaddr_in6 addr1,addr2; address[0] = '\0'; mask = 0; sscanf(s1,"%40[^/]/%d",address,&mask); blocks = mask/8; if (mask % 8 != 0) { CfOut(cf_error,"","Cannot handle ipv6 masks which are not 8 bit multiples (fix me)"); return -1; } sockaddr_pton(AF_INET6, address, &addr1); sockaddr_pton(AF_INET6, s2, &addr2); for (i = 0; i < blocks; i++) /* blocks < 16 */ { if (addr1.sin6_addr.s6_addr[i] != addr2.sin6_addr.s6_addr[i]) { return -1; } } return 0; } else { long i, from = -1, to = -1, cmp = -1; char *sp1,*sp2,buffer1[CF_MAX_IP_LEN],buffer2[CF_MAX_IP_LEN]; sp1 = s1; sp2 = s2; for (i = 0; i < 8; i++) { sscanf(sp1,"%[^:]",buffer1); sp1 += strlen(buffer1)+1; sscanf(sp2,"%[^:]",buffer2); sp2 += strlen(buffer2)+1; if (strstr(buffer1,"-")) { sscanf(buffer1,"%lx-%lx",&from,&to); sscanf(buffer2,"%lx",&cmp); if (from < 0 || to < 0) { return -1; } if ((from >= cmp) || (cmp > to)) { Debug("%lx < %lx < %lx\n",from,cmp,to); return -1; } } else { sscanf(buffer1,"%ld",&from); sscanf(buffer2,"%ld",&cmp); if (from != cmp) { return -1; } } } return 0; } } #endif return -1; } /*********************************************************************/ int FuzzyHostParse(char *arg1,char *arg2) { long start = -1, end = -1, where = -1; int n; n = sscanf(arg2,"%ld-%ld%n",&start,&end,&where); if (n != 2) { CfOut(cf_error,"","HostRange syntax error: second arg should have X-Y format where X and Y are decimal numbers"); return false; } return true; } /*********************************************************************/ int FuzzyHostMatch(char *arg0, char* arg1, char *refhost) { char *sp, refbase[CF_MAXVARSIZE]; long cmp = -1, start = -1, end = -1; char buf1[CF_BUFSIZE], buf2[CF_BUFSIZE]; strlcpy(refbase,refhost,CF_MAXVARSIZE); sp = refbase + strlen(refbase) - 1; while ( isdigit((int)*sp) ) { sp--; } sp++; sscanf(sp,"%ld",&cmp); *sp = '\0'; if (cmp < 0) { return 1; } if (strlen(refbase) == 0) { return 1; } sscanf(arg1,"%ld-%ld",&start,&end); if ( cmp < start || cmp > end ) { return 1; } strncpy(buf1,ToLowerStr(refbase),CF_BUFSIZE-1); strncpy(buf2,ToLowerStr(arg0),CF_BUFSIZE-1); if (strcmp(buf1,buf2) != 0) { return 1; } return 0; } /*********************************************************************/ void EscapeSpecialChars(char *str, char *strEsc, int strEscSz, char *noEsc) /* Escapes non-alphanumeric chars, except sequence given in noEsc */ { char *sp; int strEscPos = 0; if (noEsc == NULL) { noEsc = ""; } memset(strEsc, 0, strEscSz); for (sp = str; (*sp != '\0') && (strEscPos < strEscSz - 2); sp++) { if (strncmp(sp, noEsc, strlen(noEsc)) == 0) { if (strEscSz <= strEscPos + strlen(noEsc)) { break; } strcat(strEsc, noEsc); strEscPos += strlen(noEsc); sp += strlen(noEsc); } if (*sp != '\0' && !isalnum(*sp)) { strEsc[strEscPos++] = '\\'; } strEsc[strEscPos++] = *sp; } } /*********************************************************************/ char *EscapeChar(char *str, int strSz, char esc) /* Escapes characters esc in the string str of size strSz */ { char strDup[CF_BUFSIZE]; int strPos, strDupPos; if(sizeof(strDup) < strSz) { FatalError("Too large string passed to EscapeCharInplace()\n"); } snprintf(strDup, sizeof(strDup), "%s", str); memset(str, 0, strSz); for(strPos = 0, strDupPos = 0; strPos < strSz - 2; strPos++, strDupPos++) { if(strDup[strDupPos] == esc) { str[strPos] = '\\'; strPos++; } str[strPos] = strDup[strDupPos]; } return str; } /*********************************************************************/ void AnchorRegex(char *regex, char *out, int outSz) { if (EMPTY(regex)) { memset(out,0,outSz); } else { snprintf(out,outSz,"^(%s)$",regex); } } /* EOF */ cfengine-3.2.4/src/promises.c0000644000175000017500000005253711715232734013034 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: promises.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void DeleteDeRefPromise(char *scopeid,struct Promise *pp); static void DebugPromise(struct Promise *pp); static void DereferenceComment(struct Promise *pp); /*****************************************************************************/ char *BodyName(struct Promise *pp) { char *name,*sp; int i,size = 0; struct Constraint *cp; /* Return a type template for the promise body for lock-type identification */ if ((name = malloc(CF_MAXVARSIZE)) == NULL) { FatalError("BodyName"); } sp = pp->agentsubtype; if (size + strlen(sp) < CF_MAXVARSIZE-CF_BUFFERMARGIN) { strcpy(name,sp); strcat(name,"."); size += strlen(sp); } for (i = 0,cp = pp->conlist; (i < 5) && cp != NULL; i++,cp=cp->next) { if (strcmp(cp->lval,"args") == 0) /* Exception for args, by symmetry, for locking */ { continue; } if (size + strlen(cp->lval) < CF_MAXVARSIZE-CF_BUFFERMARGIN) { strcat(name,cp->lval); strcat(name,"."); size += strlen(cp->lval); } } return name; } /*****************************************************************************/ struct Promise *DeRefCopyPromise(char *scopeid,struct Promise *pp) { struct Promise *pcopy; struct Constraint *cp,*scp; struct Rval returnval; if (pp->promisee) { Debug("CopyPromise(%s->",pp->promiser); if (DEBUG) { ShowRval(stdout,pp->promisee,pp->petype); } Debug("\n"); } else { Debug("CopyPromise(%s->)\n",pp->promiser); } if ((pcopy = (struct Promise *)malloc(sizeof(struct Promise))) == NULL) { CfOut(cf_error,"malloc","Promise allocation failure"); FatalError("memory"); } if (pp->promiser) { pcopy->promiser = strdup(pp->promiser); } if (pp->promisee) { pcopy->promisee = CopyRvalItem(pp->promisee,pp->petype); pcopy->petype = pp->petype; } else { pcopy->promisee = NULL; } if (pp->classes) { pcopy->classes = strdup(pp->classes); } if (pcopy->promiser == NULL || (pp->promisee != NULL && pcopy->promisee == NULL) || pcopy->classes == NULL) { CfOut(cf_error,"malloc","Promise detail allocation failure"); FatalError("memory"); } pcopy->bundletype = strdup(pp->bundletype); pcopy->audit = pp->audit; pcopy->lineno = pp->lineno; pcopy->petype = pp->petype; /* rtype of promisee - list or scalar recipient? */ pcopy->bundle = strdup(pp->bundle); pcopy->ref = pp->ref; pcopy->ref_alloc = pp->ref_alloc; pcopy->agentsubtype = pp->agentsubtype; pcopy->done = pp->done; pcopy->conlist = NULL; pcopy->next = NULL; pcopy->cache = NULL; pcopy->inode_cache = pp->inode_cache; pcopy->this_server = pp->this_server; pcopy->donep = pp->donep; pcopy->conn = pp->conn; pcopy->edcontext = pp->edcontext; Debug("Copying promise constraints\n\n"); /* No further type checking should be necessary here, already done by CheckConstraintTypeMatch */ for (cp = pp->conlist; cp != NULL; cp=cp->next) { struct Body *bp = NULL; struct FnCall *fp = NULL; struct Rlist *rnew; char *bodyname = NULL; /* A body template reference could look like a scalar or fn to the parser w/w () */ switch (cp->type) { case CF_SCALAR: bodyname = (char *)cp->rval; if (cp->isbody) { bp = IsBody(BODIES,bodyname); } fp = NULL; break; case CF_FNCALL: fp = (struct FnCall *)cp->rval; bodyname = fp->name; bp = IsBody(BODIES,bodyname); break; default: bp = NULL; fp = NULL; bodyname = NULL; break; } /* First case is: we have a body template to expand lval = body(args), .. */ if (bp != NULL) { if (strcmp(bp->type,cp->lval) != 0) { CfOut(cf_error,"","Body type mismatch for body reference \"%s\" in promise at line %d of %s (%s != %s)\n",bodyname,pp->lineno,(pp->audit)->filename,bp->type,cp->lval); ERRORCOUNT++; } /* Keep the referent body type as a boolean for convenience when checking later */ AppendConstraint(&(pcopy->conlist),cp->lval,strdup("true"),CF_SCALAR,cp->classes,false); Debug("Handling body-lval \"%s\"\n",cp->lval); if (bp->args != NULL) { /* There are arguments to insert*/ if (fp == NULL || fp->args == NULL) { CfOut(cf_error,"","Argument mismatch for body reference \"%s\" in promise at line %d of %s\n",bodyname,pp->lineno,(pp->audit)->filename); } NewScope("body"); if (fp && bp && fp->args && bp->args && !MapBodyArgs("body",fp->args,bp->args)) { ERRORCOUNT++; CfOut(cf_error,"","Number of arguments does not match for body reference \"%s\" in promise at line %d of %s\n",bodyname,pp->lineno,(pp->audit)->filename); } for (scp = bp->conlist; scp != NULL; scp = scp->next) { Debug("Doing arg-mapped sublval = %s (promises.c)\n",scp->lval); returnval = ExpandPrivateRval("body",scp->rval,scp->type); AppendConstraint(&(pcopy->conlist),scp->lval,returnval.item,returnval.rtype,scp->classes,false); } DeleteScope("body"); } else { /* No arguments to deal with or body undeclared */ if (fp != NULL) { CfOut(cf_error,"","An apparent body \"%s()\" was undeclared or could have incorrect args, but used in a promise near line %d of %s (possible unquoted literal value)",bodyname,pp->lineno,(pp->audit)->filename); } else { for (scp = bp->conlist; scp != NULL; scp = scp->next) { Debug("Doing sublval = %s (promises.c)\n",scp->lval); rnew = CopyRvalItem(scp->rval,scp->type); AppendConstraint(&(pcopy->conlist),scp->lval,rnew,scp->type,scp->classes,false); } } } } else { if (cp->isbody && !IsBundle(BUNDLES,bodyname)) { CfOut(cf_error,"","Apparent body \"%s()\" was undeclared, but used in a promise near line %d of %s (possible unquoted literal value)",bodyname,pp->lineno,(pp->audit)->filename); } rnew = CopyRvalItem(cp->rval,cp->type); scp = AppendConstraint(&(pcopy->conlist),cp->lval,rnew,cp->type,cp->classes,false); } } return pcopy; } /*****************************************************************************/ struct Promise *ExpandDeRefPromise(char *scopeid,struct Promise *pp) { struct Promise *pcopy; struct Constraint *cp; struct Rval returnval,final; Debug("ExpandDerefPromise()\n"); if ((pcopy = (struct Promise *)malloc(sizeof(struct Promise))) == NULL) { CfOut(cf_error,"malloc","Promise allocation failure"); FatalError("memory"); } returnval = ExpandPrivateRval("this",pp->promiser,CF_SCALAR); pcopy->promiser = (char *)returnval.item; if (pp->promisee) { returnval = EvaluateFinalRval(scopeid,pp->promisee,pp->petype,true,pp); pcopy->promisee = (struct Rlist *)returnval.item; pcopy->petype = returnval.rtype; } else { pcopy->petype = CF_NOPROMISEE; pcopy->promisee = NULL; } if (pp->classes) { pcopy->classes = strdup(pp->classes); } else { pcopy->classes = strdup("any"); } if (pcopy->promiser == NULL || pcopy->classes == NULL) { CfOut(cf_error,"malloc","ExpandPromise detail allocation failure"); FatalError("memory"); } pcopy->bundletype = strdup(pp->bundletype); pcopy->done = pp->done; pcopy->donep = pp->donep; pcopy->audit = pp->audit; pcopy->lineno = pp->lineno; pcopy->bundle = strdup(pp->bundle); pcopy->ref = pp->ref; pcopy->ref_alloc = pp->ref_alloc; pcopy->agentsubtype = pp->agentsubtype; pcopy->conlist = NULL; pcopy->next = NULL; pcopy->cache = pp->cache; pcopy->inode_cache = pp->inode_cache; pcopy->this_server = pp->this_server; pcopy->conn = pp->conn; pcopy->edcontext = pp->edcontext; /* No further type checking should be necessary here, already done by CheckConstraintTypeMatch */ for (cp = pp->conlist; cp != NULL; cp=cp->next) { struct Rval returnval; if (ExpectedDataType(cp->lval) == cf_bundle) { final = ExpandBundleReference(scopeid,cp->rval,cp->type); } else { returnval = EvaluateFinalRval(scopeid,cp->rval,cp->type,false,pp); final = ExpandDanglers(scopeid,returnval,pp); DeleteRvalItem(returnval.item,returnval.rtype); } AppendConstraint(&(pcopy->conlist),cp->lval,final.item,final.rtype,cp->classes,false); if (strcmp(cp->lval,"comment") == 0) { if (final.rtype != CF_SCALAR) { char err[CF_BUFSIZE]; snprintf(err,CF_BUFSIZE,"Comments can only be scalar objects (not %c in \"%s\")",final.rtype,pp->promiser); yyerror(err); } else { pcopy->ref = final.item; /* No alloc reference to comment item */ if (pcopy->ref && (strstr(pcopy->ref,"$(this.promiser)") || strstr(pcopy->ref,"${this.promiser}"))) { DereferenceComment(pcopy); } } } } return pcopy; } /*****************************************************************************/ struct Promise *CopyPromise(char *scopeid,struct Promise *pp) { struct Promise *pcopy; struct Constraint *cp; struct Rval returnval,final; Debug("CopyPromise()\n"); if ((pcopy = (struct Promise *)malloc(sizeof(struct Promise))) == NULL) { CfOut(cf_error,"malloc","Promise allocation failure"); FatalError("memory"); } pcopy->promiser = strdup(pp->promiser); if (pp->promisee) { returnval = EvaluateFinalRval(scopeid,pp->promisee,pp->petype,true,pp); pcopy->promisee = (struct Rlist *)returnval.item; pcopy->petype = returnval.rtype; } else { pcopy->petype = CF_NOPROMISEE; pcopy->promisee = NULL; } if (pp->classes) { pcopy->classes = strdup(pp->classes); } else { pcopy->classes = strdup("any"); } if (pcopy->promiser == NULL || pcopy->classes == NULL) { CfOut(cf_error,"malloc","ExpandPromise detail allocation failure"); FatalError("memory"); } pcopy->bundletype = strdup(pp->bundletype); pcopy->done = pp->done; pcopy->donep = pp->donep; pcopy->audit = pp->audit; pcopy->lineno = pp->lineno; pcopy->bundle = strdup(pp->bundle); pcopy->ref = pp->ref; pcopy->ref_alloc = pp->ref_alloc; pcopy->agentsubtype = pp->agentsubtype; pcopy->conlist = NULL; pcopy->next = NULL; pcopy->cache = pp->cache; pcopy->inode_cache = pp->inode_cache; pcopy->this_server = pp->this_server; pcopy->conn = pp->conn; pcopy->edcontext = pp->edcontext; /* No further type checking should be necessary here, already done by CheckConstraintTypeMatch */ for (cp = pp->conlist; cp != NULL; cp=cp->next) { struct Rval returnval; if (ExpectedDataType(cp->lval) == cf_bundle) { /* sub-bundles do not expand here */ returnval = ExpandPrivateRval(scopeid,cp->rval,cp->type); } else { returnval = EvaluateFinalRval(scopeid,cp->rval,cp->type,false,pp); } final = ExpandDanglers(scopeid,returnval,pp); AppendConstraint(&(pcopy->conlist),cp->lval,final.item,final.rtype,cp->classes,false); if (strcmp(cp->lval,"comment") == 0) { if (final.rtype != CF_SCALAR) { yyerror("Comments can only be scalar objects"); } else { pcopy->ref = final.item; /* No alloc reference to comment item */ } } } return pcopy; } /*******************************************************************/ static void DebugPromise(struct Promise *pp) { struct Constraint *cp; struct Body *bp; struct FnCall *fp; struct Rlist *rp; char *v,rettype; void *retval; if (GetVariable("control_common","version",&retval,&rettype) != cf_notype) { v = (char *)retval; } else { v = "not specified"; } if (pp->promisee != NULL) { fprintf(stdout,"%s promise by \'%s\' -> ",pp->agentsubtype,pp->promiser); ShowRval(stdout,pp->promisee,pp->petype); fprintf(stdout," if context is %s\n",pp->classes); } else { fprintf(stdout,"%s promise by \'%s\' (implicit) if context is %s\n",pp->agentsubtype,pp->promiser,pp->classes); } fprintf(stdout,"in bundle %s of type %s\n",pp->bundle,pp->bundletype); for (cp = pp->conlist; cp != NULL; cp = cp->next) { fprintf(stdout,"%10s => ",cp->lval); switch (cp->type) { case CF_SCALAR: if ((bp = IsBody(BODIES,(char *)cp->rval))) { ShowBody(bp,15); } else { ShowRval(stdout,cp->rval,cp->type); /* literal */ } break; case CF_LIST: rp = (struct Rlist *)cp->rval; ShowRlist(stdout,rp); break; case CF_FNCALL: fp = (struct FnCall *)cp->rval; if ((bp = IsBody(BODIES,fp->name))) { ShowBody(bp,15); } else { ShowRval(stdout,cp->rval,cp->type); /* literal */ } break; default: printf("Unknown RHS type %c\n",cp->type); } if (cp->type != CF_FNCALL) { fprintf(stdout," if body context %s\n",cp->classes); } } } /*******************************************************************/ struct Body *IsBody(struct Body *list,char *key) { struct Body *bp; for (bp = list; bp != NULL; bp = bp->next) { if (strcmp(bp->name,key) == 0) { return bp; } } return NULL; } /*******************************************************************/ struct Bundle *IsBundle(struct Bundle *list,char *key) { struct Bundle *bp; for (bp = list; bp != NULL; bp = bp->next) { if (strcmp(bp->name,key) == 0) { return bp; } } return NULL; } /*****************************************************************************/ /* Cleanup */ /*****************************************************************************/ void DeletePromises(struct Promise *pp) { if (pp == NULL) { return; } if (pp->this_server != NULL) { ThreadLock(cft_policy); free(pp->this_server); ThreadUnlock(cft_policy); } if (pp->next != NULL) { DeletePromises(pp->next); } if (pp->ref_alloc == 'y') { ThreadLock(cft_policy); free(pp->ref); ThreadUnlock(cft_policy); } DeletePromise(pp); } /*****************************************************************************/ struct Promise *NewPromise(char *typename,char *promiser) { struct Promise *pp; ThreadLock(cft_policy); if ((pp = (struct Promise *)malloc(sizeof(struct Promise))) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Promise"); FatalError(""); } pp->audit = AUDITPTR; pp->lineno = 0; pp->bundle = strdup("internal_bundle"); pp->promiser = strdup(promiser); ThreadUnlock(cft_policy); pp->promisee = NULL; pp->petype = CF_NOPROMISEE; pp->classes = NULL; pp->done = false; pp->donep = &(pp->done); pp->this_server = NULL; pp->cache = NULL; pp->conn = NULL; pp->inode_cache = NULL; pp->cache = NULL; pp->bundletype = NULL; pp->agentsubtype = typename; /* cache this, not copy strdup(typename);*/ pp->ref = NULL; /* cache a reference if given*/ pp->ref_alloc = 'n'; pp->next = NULL; pp->conlist = NULL; // this fn is used for internal promises only AppendConstraint(&(pp->conlist), "handle", strdup("internal_promise"),CF_SCALAR,NULL,false); return pp; } /*****************************************************************************/ void DeletePromise(struct Promise *pp) { if (pp == NULL) { return; } Debug("DeletePromise(%s->[%c])\n",pp->promiser,pp->petype); ThreadLock(cft_policy); if (pp->promiser != NULL) { free(pp->promiser); } if (pp->promisee != NULL) { DeleteRvalItem(pp->promisee,pp->petype); } free(pp->bundle); free(pp->bundletype); free(pp->classes); // ref and agentsubtype are only references, do not free DeleteConstraintList(pp->conlist); free((char *)pp); ThreadUnlock(cft_policy); } /*****************************************************************************/ static void DeleteDeRefPromise(char *scopeid,struct Promise *pp) { struct Constraint *cp; Debug("DeleteDeRefPromise()\n"); free(pp->promiser); if (pp->promisee) { DeleteRvalItem(pp->promisee,pp->petype); } if (pp->classes) { free(pp->classes); } free(pp->bundle); for (cp = pp->conlist; cp != NULL; cp=cp->next) { free(cp->lval); DeleteRvalItem(cp->rval,cp->type); } free(pp); } /*****************************************************************************/ void PromiseRef(enum cfreport level,struct Promise *pp) { char *v,rettype; void *retval; if (pp == NULL) { return; } if (GetVariable("control_common","version",&retval,&rettype) != cf_notype) { v = (char *)retval; } else { v = "not specified"; } if (pp->audit) { CfOut(level,"","Promise (version %s) belongs to bundle \'%s\' in file \'%s\' near line %d\n",v,pp->bundle,pp->audit->filename,pp->lineno); } else { CfOut(level,"","Promise (version %s) belongs to bundle \'%s\' near line %d\n",v,pp->bundle,pp->lineno); } if (pp->ref) { CfOut(level,"","Comment: %s\n",pp->ref); } } /*******************************************************************/ void HashPromise(char *salt,struct Promise *pp,unsigned char digest[EVP_MAX_MD_SIZE+1],enum cfhashes type) { EVP_MD_CTX context; int md_len; const EVP_MD *md = NULL; struct Constraint *cp; struct Rlist *rp; struct FnCall *fp; char *noRvalHash[] = { "mtime", "atime", "ctime", NULL }; int doHash; int i; md = EVP_get_digestbyname(FileHashName(type)); EVP_DigestInit(&context,md); // multiple packages (promisers) may share same package_list_update_ifelapsed lock if (!(salt && (strncmp(salt, PACK_UPIFELAPSED_SALT, sizeof(PACK_UPIFELAPSED_SALT) - 1) == 0))) { EVP_DigestUpdate(&context,pp->promiser,strlen(pp->promiser)); } if (pp->ref) { EVP_DigestUpdate(&context,pp->ref,strlen(pp->ref)); } if (pp->this_server) { EVP_DigestUpdate(&context,pp->this_server,strlen(pp->this_server)); } if (salt) { EVP_DigestUpdate(&context,salt,strlen(salt)); } for (cp = pp->conlist; cp != NULL; cp=cp->next) { EVP_DigestUpdate(&context,cp->lval,strlen(cp->lval)); // don't hash rvals that change (e.g. times) doHash = true; for (i = 0; noRvalHash[i] != NULL; i++ ) { if (strcmp(cp->lval, noRvalHash[i]) == 0) { doHash = false; break; } } if (!doHash) { continue; } switch(cp->type) { case CF_SCALAR: EVP_DigestUpdate(&context,cp->rval,strlen(cp->rval)); break; case CF_LIST: for (rp = cp->rval; rp != NULL; rp=rp->next) { EVP_DigestUpdate(&context,rp->item,strlen(rp->item)); } break; case CF_FNCALL: /* Body or bundle */ fp = (struct FnCall *)cp->rval; EVP_DigestUpdate(&context,fp->name,strlen(fp->name)); for (rp = fp->args; rp != NULL; rp=rp->next) { EVP_DigestUpdate(&context,rp->item,strlen(rp->item)); } break; } } EVP_DigestFinal(&context,digest,&md_len); /* Digest length stored in md_len */ } /*******************************************************************/ static void DereferenceComment(struct Promise *pp) { char pre_buffer[CF_BUFSIZE],post_buffer[CF_BUFSIZE],buffer[CF_BUFSIZE],*sp; int offset = 0; strlcpy(pre_buffer,pp->ref,CF_BUFSIZE); if ((sp = strstr(pre_buffer,"$(this.promiser)")) || (sp = strstr(pre_buffer, "${this.promiser}"))) { *sp = '\0'; offset = sp - pre_buffer + strlen("$(this.promiser)"); strncpy(post_buffer,pp->ref+offset,CF_BUFSIZE); snprintf(buffer,CF_BUFSIZE,"%s%s%s",pre_buffer,pp->promiser,post_buffer); if (pp->ref_alloc == 'y') { free(pp->ref); } pp->ref = strdup(buffer); pp->ref_alloc = 'y'; } } cfengine-3.2.4/src/mod_common.c0000644000175000017500000005744511715232734013325 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_common.c */ /* */ /* This is a root node in the syntax tree */ /* */ /*****************************************************************************/ #define CF3_MOD_COMMON #include "cf3.defs.h" #include "cf3.extern.h" struct BodySyntax CF_TRANSACTION_BODY[] = { {"action_policy",cf_opts,"fix,warn,nop","Whether to repair or report about non-kept promises"}, {"ifelapsed",cf_int,CF_VALRANGE,"Number of minutes before next allowed assessment of promise"}, {"expireafter",cf_int,CF_VALRANGE,"Number of minutes before a repair action is interrupted and retried"}, {"log_string",cf_str,"","A message to be written to the log when a promise verification leads to a repair"}, {"log_level",cf_opts,"inform,verbose,error,log","The reporting level sent to syslog"}, {"log_kept",cf_str,CF_LOGRANGE,"This should be filename of a file to which log_string will be saved, if undefined it goes to the system logger"}, {"log_priority",cf_opts,"emergency,alert,critical,error,warning,notice,info,debug","The priority level of the log message, as interpreted by a syslog server"}, {"log_repaired",cf_str,CF_LOGRANGE,"This should be filename of a file to which log_string will be saved, if undefined it goes to the system logger"}, {"log_failed",cf_str,CF_LOGRANGE,"This should be filename of a file to which log_string will be saved, if undefined it goes to the system logger"}, {"value_kept",cf_real,CF_REALRANGE,"A real number value attributed to keeping this promise"}, {"value_repaired",cf_real,CF_REALRANGE,"A real number value attributed to reparing this promise"}, {"value_notkept",cf_real,CF_REALRANGE,"A real number value (possibly negative) attributed to not keeping this promise"}, {"audit",cf_opts,CF_BOOL,"true/false switch for detailed audit records of this promise"}, {"background",cf_opts,CF_BOOL,"true/false switch for parallelizing the promise repair"}, {"report_level",cf_opts,"inform,verbose,error,log","The reporting level for standard output for this promise"}, {"measurement_class",cf_str,"","If set performance will be measured and recorded under this identifier"}, {NULL,cf_notype,NULL,NULL} }; /*********************************************************/ struct BodySyntax CF_DEFINECLASS_BODY[] = { {"promise_repaired",cf_slist,CF_IDRANGE,"A list of classes to be defined globally"}, {"repair_failed",cf_slist,CF_IDRANGE,"A list of classes to be defined globally"}, {"repair_denied",cf_slist,CF_IDRANGE,"A list of classes to be defined globally"}, {"repair_timeout",cf_slist,CF_IDRANGE,"A list of classes to be defined globally"}, {"promise_kept",cf_slist,CF_IDRANGE,"A list of classes to be defined globally"}, {"cancel_kept",cf_slist,CF_IDRANGE,"A list of classes to be cancelled if the promise is kept"}, {"cancel_repaired",cf_slist,CF_IDRANGE,"A list of classes to be cancelled if the promise is repaired"}, {"cancel_notkept",cf_slist,CF_IDRANGE,"A list of classes to be cancelled if the promise is not kept for any reason"}, {"kept_returncodes",cf_slist,CF_INTLISTRANGE,"A list of return codes indicating a kept command-related promise"}, {"repaired_returncodes",cf_slist,CF_INTLISTRANGE,"A list of return codes indicating a repaired command-related promise"}, {"failed_returncodes",cf_slist,CF_INTLISTRANGE,"A list of return codes indicating a failed command-related promise"}, {"persist_time",cf_int,CF_VALRANGE,"A number of minutes the specified classes should remain active"}, {"timer_policy",cf_opts,"absolute,reset","Whether a persistent class restarts its counter when rediscovered"}, {NULL,cf_notype,NULL,NULL} }; /*********************************************************/ struct BodySyntax CF_VARBODY[] = { {"string",cf_str,"","A scalar string"}, {"int",cf_int,CF_INTRANGE,"A scalar integer"}, {"real",cf_real,CF_REALRANGE,"A scalar real number"}, {"slist",cf_slist,"","A list of scalar strings"}, {"ilist",cf_ilist,CF_INTRANGE,"A list of integers"}, {"rlist",cf_rlist,CF_REALRANGE,"A list of real numbers"}, {"policy",cf_opts,"free,overridable,constant,ifdefined","The policy for (dis)allowing (re)definition of variables"}, {NULL,cf_notype,NULL,NULL} }; /*********************************************************/ struct BodySyntax CF_CLASSBODY[] = { {"or",cf_clist,CF_CLASSRANGE,"Combine class sources with inclusive OR"}, {"and",cf_clist,CF_CLASSRANGE,"Combine class sources with AND"}, {"xor",cf_clist,CF_CLASSRANGE,"Combine class sources with XOR"}, {"dist",cf_rlist,CF_REALRANGE,"Generate a probabilistic class distribution (from strategies in cfengine 2)"}, {"expression",cf_class,CF_CLASSRANGE,"Evaluate string expression of classes in normal form"}, {"not",cf_class,CF_CLASSRANGE,"Evaluate the negation of string expression in normal form"}, {"select_class",cf_rlist,CF_CLASSRANGE,"Select one of the named list of classes to define based on host identity"}, {NULL,cf_notype,NULL,NULL} }; /*********************************************************/ /* Control bodies */ /*********************************************************/ struct BodySyntax CFG_CONTROLBODY[] = { {"bundlesequence",cf_slist,".*","List of promise bundles to verify in order"}, {"goal_categories",cf_slist,"","A list of context names that represent parent categories for goals (goal patterns)"}, {"goal_patterns",cf_slist,"","A list of regular expressions that match promisees/topics considered to be organizational goals"}, {"ignore_missing_bundles",cf_opts,CF_BOOL,"If any bundles in the bundlesequence do not exist, ignore and continue"}, {"ignore_missing_inputs",cf_opts,CF_BOOL,"If any input files do not exist, ignore and continue"}, {"inputs",cf_slist,".*","List of additional filenames to parse for promises"}, {"version",cf_str,"","Scalar version string for this configuration"}, {"lastseenexpireafter",cf_int,CF_VALRANGE,"Number of minutes after which last-seen entries are purged"}, {"output_prefix",cf_str,"","The string prefix for standard output"}, {"domain",cf_str,".*","Specify the domain name for this host"}, {"require_comments",cf_opts,CF_BOOL,"Warn about promises that do not have comment documentation"}, {"host_licenses_paid",cf_int,CF_VALRANGE,"The number of licenses that you promise to have paid for by setting this value (legally binding for commercial license)"}, {"site_classes",cf_clist,CF_CLASSRANGE,"A list of classes that will represent geographical site locations for hosts. These should be defined elsewhere in the configuration in a classes promise."}, {"syslog_host",cf_str,CF_IPRANGE,"The name or address of a host to which syslog messages should be sent directly by UDP"}, {"syslog_port",cf_int,CF_VALRANGE,"The port number of a UDP syslog service"}, {"fips_mode",cf_opts,CF_BOOL,"Activate full FIPS mode restrictions"}, {NULL,cf_notype,NULL,NULL} }; struct BodySyntax CFA_CONTROLBODY[] = { {"abortclasses",cf_slist,".*","A list of classes which if defined lead to termination of cf-agent"}, {"abortbundleclasses",cf_slist,".*","A list of classes which if defined lead to termination of current bundle"}, {"addclasses",cf_slist,".*","A list of classes to be defined always in the current context"}, {"agentaccess",cf_slist,".*","A list of user names allowed to execute cf-agent"}, {"agentfacility",cf_opts,CF_FACILITY,"The syslog facility for cf-agent"}, {"alwaysvalidate",cf_opts,CF_BOOL,"true/false flag to determine whether configurations will always be checked before executing, or only after updates"}, {"auditing",cf_opts,CF_BOOL,"true/false flag to activate the cf-agent audit log"}, {"binarypaddingchar",cf_str,"","Character used to pad unequal replacements in binary editing"}, {"bindtointerface",cf_str,".*","Use this interface for outgoing connections"}, {"hashupdates",cf_opts,CF_BOOL,"true/false whether stored hashes are updated when change is detected in source"}, {"childlibpath",cf_str,".*","LD_LIBRARY_PATH for child processes"}, {"checksum_alert_time",cf_int,"0,60","The persistence time for the checksum_alert class"}, {"defaultcopytype",cf_opts,"mtime,atime,ctime,digest,hash,binary"}, {"dryrun",cf_opts,CF_BOOL,"All talk and no action mode"}, {"editbinaryfilesize",cf_int,CF_VALRANGE,"Integer limit on maximum binary file size to be edited"}, {"editfilesize",cf_int,CF_VALRANGE,"Integer limit on maximum text file size to be edited"}, {"environment",cf_slist,"[A-Za-z0-9_]+=.*","List of environment variables to be inherited by children"}, {"exclamation",cf_opts,CF_BOOL,"true/false print exclamation marks during security warnings"}, {"expireafter",cf_int,CF_VALRANGE,"Global default for time before on-going promise repairs are interrupted"}, {"files_single_copy",cf_slist,"","List of filenames to be watched for multiple-source conflicts"}, {"files_auto_define",cf_slist,"","List of filenames to define classes if copied"}, {"hostnamekeys",cf_opts,CF_BOOL,"true/false label ppkeys by hostname not IP address"}, {"ifelapsed",cf_int,CF_VALRANGE,"Global default for time that must elapse before promise will be rechecked"}, {"inform",cf_opts,CF_BOOL,"true/false set inform level default"}, {"intermittency",cf_opts,CF_BOOL,"true/false store detailed recordings of last observed time for all client-server connections for reliability assessment (false)"}, {"max_children",cf_int,CF_VALRANGE,"Maximum number of background tasks that should be allowed concurrently"}, {"maxconnections",cf_int,CF_VALRANGE,"Maximum number of outgoing connections to cf-serverd"}, {"mountfilesystems",cf_opts,CF_BOOL,"true/false mount any filesystems promised"}, {"nonalphanumfiles",cf_opts,CF_BOOL,"true/false warn about filenames with no alphanumeric content"}, {"repchar",cf_str,".","The character used to canonize pathnames in the file repository"}, {"refresh_processes",cf_slist,CF_IDRANGE,"Reload the process table before verifying the bundles named in this list (lazy evaluation)"}, {"default_repository",cf_str,CF_ABSPATHRANGE,"Path to the default file repository"}, {"secureinput",cf_opts,CF_BOOL,"true/false check whether input files are writable by unauthorized users"}, {"sensiblecount",cf_int,CF_VALRANGE,"Minimum number of files a mounted filesystem is expected to have"}, {"sensiblesize",cf_int,CF_VALRANGE,"Minimum number of bytes a mounted filesystem is expected to have"}, {"skipidentify",cf_opts,CF_BOOL,"Do not send IP/name during server connection because address resolution is broken"}, {"suspiciousnames",cf_slist,"","List of names to warn about if found during any file search"}, {"syslog",cf_opts,CF_BOOL,"true/false switches on output to syslog at the inform level"}, {"track_value",cf_opts,CF_BOOL,"true/false switches on tracking of promise valuation"}, {"timezone",cf_slist,"","List of allowed timezones this machine must comply with"}, {"default_timeout",cf_int,CF_VALRANGE,"Maximum time a network connection should attempt to connect"}, {"verbose",cf_opts,CF_BOOL,"true/false switches on verbose standard output"}, {NULL,cf_notype,NULL,NULL} }; struct BodySyntax CFS_CONTROLBODY[] = { {"allowallconnects",cf_slist,"","List of IPs or hostnames that may have more than one connection to the server port"}, {"allowconnects",cf_slist,"","List of IPs or hostnames that may connect to the server port"}, {"allowusers",cf_slist,"","List of usernames who may execute requests from this server"}, {"auditing",cf_opts,CF_BOOL,"true/false activate auditing of server connections"}, {"bindtointerface",cf_str,"","IP of the interface to which the server should bind on multi-homed hosts"}, {"cfruncommand",cf_str,CF_ABSPATHRANGE,"Path to the cf-agent command or cf-execd wrapper for remote execution"}, {"denybadclocks",cf_opts,CF_BOOL,"true/false accept connections from hosts with clocks that are out of sync"}, {"denyconnects",cf_slist,"","List of IPs or hostnames that may NOT connect to the server port"}, {"dynamicaddresses",cf_slist,"","List of IPs or hostnames for which the IP/name binding is expected to change"}, {"hostnamekeys",cf_opts,CF_BOOL,"true/false store keys using hostname lookup instead of IP addresses"}, {"keycacheTTL",cf_int,CF_VALRANGE,"Maximum number of hours to hold public keys in the cache"}, {"logallconnections",cf_opts,CF_BOOL,"true/false causes the server to log all new connections to syslog"}, {"logencryptedtransfers",cf_opts,CF_BOOL,"true/false log all successful transfers required to be encrypted"}, {"maxconnections",cf_int,CF_VALRANGE,"Maximum number of connections that will be accepted by cf-serverd"}, {"port",cf_int,"1024,99999","Default port for cfengine server"}, {"serverfacility",cf_opts,CF_FACILITY,"Menu option for syslog facility level"}, {"skipverify",cf_slist,"","List of IPs or hostnames for which we expect no DNS binding and cannot verify"}, {"trustkeysfrom",cf_slist,"","List of IPs from whom we accept public keys on trust"}, {NULL,cf_notype,NULL,NULL} }; struct BodySyntax CFM_CONTROLBODY[] = { {"forgetrate",cf_real,"0,1","Decimal fraction [0,1] weighting of new values over old in 2d-average computation"}, {"monitorfacility",cf_opts,CF_FACILITY,"Menu option for syslog facility"}, {"histograms",cf_opts,CF_BOOL,"Ignored, kept for backward compatibility"}, {"tcpdump",cf_opts,CF_BOOL,"true/false use tcpdump if found"}, {"tcpdumpcommand",cf_str,CF_ABSPATHRANGE,"Path to the tcpdump command on this system"}, {NULL,cf_notype,NULL,NULL} }; struct BodySyntax CFR_CONTROLBODY[] = { {"hosts",cf_slist,"","List of host or IP addresses to attempt connection with"}, {"port",cf_int,"1024,99999","Default port for cfengine server"}, {"force_ipv4",cf_opts,CF_BOOL,"true/false force use of ipv4 in connection"}, {"trustkey",cf_opts,CF_BOOL,"true/false automatically accept all keys on trust from servers"}, {"encrypt",cf_opts,CF_BOOL,"true/false encrypt connections with servers"}, {"background_children",cf_opts,CF_BOOL,"true/false parallelize connections to servers"}, {"max_children",cf_int,CF_VALRANGE,"Maximum number of simultaneous connections to attempt"}, {"output_to_file",cf_opts,CF_BOOL,"true/false whether to send collected output to file(s)"}, {"output_directory",cf_str,CF_ABSPATHRANGE,"Directory where the output is stored"}, {"timeout",cf_int,"1,9999","Connection timeout, sec"}, {NULL,cf_notype,NULL,NULL} }; struct BodySyntax CFEX_CONTROLBODY[] = /* enum cfexcontrol */ { {"splaytime",cf_int,CF_VALRANGE,"Time in minutes to splay this host based on its name hash"}, {"mailfrom",cf_str,".*@.*","Email-address cfengine mail appears to come from"}, {"mailto",cf_str,".*@.*","Email-address cfengine mail is sent to"}, {"smtpserver",cf_str,".*","Name or IP of a willing smtp server for sending email"}, {"mailmaxlines",cf_int,"0,1000","Maximum number of lines of output to send by email"}, {"schedule",cf_slist,"","The class schedule used by cf-execd for activating cf-agent"}, {"executorfacility",cf_opts,CF_FACILITY,"Menu option for syslog facility level"}, {"exec_command",cf_str,CF_ABSPATHRANGE,"The full path and command to the executable run by default (overriding builtin)"}, {NULL,cf_notype,NULL,NULL} }; struct BodySyntax CFK_CONTROLBODY[] = { {"build_directory",cf_str,".*","The directory in which to generate output files"}, {"document_root",cf_str,".*","The directory in which the web root resides"}, {"generate_manual",cf_opts,CF_BOOL,"true/false generate texinfo manual page skeleton for this version"}, {"graph_directory",cf_str,CF_ABSPATHRANGE,"Path to directory where rendered .png files will be created"}, {"graph_output",cf_opts,CF_BOOL,"true/false generate png visualization of topic map if possible (requires lib)"}, {"html_banner",cf_str,"","HTML code for a banner to be added to rendered in html after the header"}, {"html_footer",cf_str,"","HTML code for a page footer to be added to rendered in html before the end body tag"}, {"id_prefix",cf_str,".*","The LTM identifier prefix used to label topic maps (used for disambiguation in merging)"}, {"manual_source_directory",cf_str,CF_ABSPATHRANGE,"Path to directory where raw text about manual topics is found (defaults to build_directory)"}, {"query_engine",cf_str,"","Name of a dynamic web-page used to accept and drive queries in a browser"}, {"query_output",cf_opts,"html,text","Menu option for generated output format"}, {"sql_type",cf_opts,"mysql,postgres","Menu option for supported database type"}, {"sql_database",cf_str,"","Name of database used for the topic map"}, {"sql_owner",cf_str,"","User id of sql database user"}, {"sql_passwd",cf_str,"","Embedded password for accessing sql database"}, {"sql_server",cf_str,"","Name or IP of database server (or localhost)"}, {"sql_connection_db",cf_str,"","The name of an existing database to connect to in order to create/manage other databases"}, {"style_sheet",cf_str,"","Name of a style-sheet to be used in rendering html output (added to headers)"}, {"view_projections",cf_opts,CF_BOOL,"Perform view-projection analytics in graph generation"}, {NULL,cf_notype,NULL,NULL} }; struct BodySyntax CFRE_CONTROLBODY[] = /* enum cfrecontrol */ { {"aggregation_point",cf_str,CF_ABSPATHRANGE,"The root directory of the data cache for CMDB aggregation"}, {"auto_scaling",cf_opts,CF_BOOL,"true/false whether to auto-scale graph output to optimize use of space"}, {"build_directory",cf_str,".*","The directory in which to generate output files"}, {"csv2xml",cf_slist,"","A list of csv formatted files in the build directory to convert to simple xml"}, {"error_bars",cf_opts,CF_BOOL,"true/false whether to generate error bars on graph output"}, {"html_banner",cf_str,"","HTML code for a banner to be added to rendered in html after the header"}, {"html_embed",cf_opts,CF_BOOL,"If true, no header and footer tags will be added to html output"}, {"html_footer",cf_str,"","HTML code for a page footer to be added to rendered in html before the end body tag"}, {"query_engine",cf_str,"","Name of a dynamic web-page used to accept and drive queries in a browser"}, {"reports",cf_olist,"all,audit,performance,all_locks,active_locks,hashes,classes,last_seen,monitor_now,monitor_history,monitor_summary,compliance,setuid,file_changes,installed_software,software_patches,value,variables","A list of reports that may be generated"}, {"report_output",cf_opts,"csv,html,text,xml","Menu option for generated output format. Applies only to text reports, graph data remain in xydy format."}, {"style_sheet",cf_str,"","Name of a style-sheet to be used in rendering html output (added to headers)"}, {"time_stamps",cf_opts,CF_BOOL,"true/false whether to generate timestamps in the output directory name"}, {NULL,cf_notype,NULL,NULL} }; struct BodySyntax CFH_CONTROLBODY[] = /* enum cfh_control */ { {"export_zenoss",cf_opts,CF_BOOL,"Make data available for Zenoss integration in docroot/reports/summary.z"}, {"federation",cf_slist,"","The list of CFEngine servers supporting constellation integration with this hub"}, {"exclude_hosts",cf_slist,"","A list of IP addresses of hosts to exclude from report collection"}, {"hub_schedule",cf_slist,"","The class schedule used by cf-hub for report collation"}, {"port",cf_int,"1024,99999","Default port for contacting hub nodes"}, {NULL,cf_notype,NULL,NULL} }; /*********************************************************/ /* This list is for checking free standing body lval => rval bindings */ struct SubTypeSyntax CF_ALL_BODIES[] = { {CF_COMMONC,"control",CFG_CONTROLBODY}, {CF_AGENTC,"control",CFA_CONTROLBODY}, {CF_SERVERC,"control",CFS_CONTROLBODY}, {CF_MONITORC,"control",CFM_CONTROLBODY}, {CF_RUNC,"control",CFR_CONTROLBODY}, {CF_EXECC,"control",CFEX_CONTROLBODY}, {CF_KNOWC,"control",CFK_CONTROLBODY}, {CF_REPORTC,"control",CFRE_CONTROLBODY}, {CF_HUBC,"control",CFH_CONTROLBODY}, // get others from modules e.g. "agent","files",CF_FILES_BODIES, {NULL,NULL,NULL} }; /*********************************************************/ /* */ /* Constraint values/types */ /* */ /*********************************************************/ /* This is where we place lval => rval bindings that apply to more than one subtype, e.g. generic processing behavioural details */ struct BodySyntax CF_COMMON_BODIES[] = { {CF_TRANSACTION,cf_body,CF_TRANSACTION_BODY,"Output behaviour"}, {CF_DEFINECLASSES,cf_body,CF_DEFINECLASS_BODY,"Signalling behaviour"}, {"ifvarclass",cf_str,"","Extended classes ANDed with context"}, {"handle",cf_str,CF_IDRANGE,"A unique id-tag string for referring to this as a promisee elsewhere"}, {"depends_on",cf_slist,"","A list of promise handles that this promise builds on or depends on somehow (for knowledge management)"}, {"comment",cf_str,"","A comment about this promise's real intention that follows through the program"}, {NULL,cf_notype,NULL,NULL} }; /*********************************************************/ /* This is where we place promise subtypes that apply to more than one type of bundle, e.g. agent,server.. */ struct SubTypeSyntax CF_COMMON_SUBTYPES[] = { {"*","vars",CF_VARBODY}, {"*","classes",CF_CLASSBODY}, {"*","reports",CF_REPORT_BODIES}, {"*","*",CF_COMMON_BODIES}, {NULL,NULL,NULL} }; /*********************************************************/ /* THIS IS WHERE TO ATTACH SYNTAX MODULES */ /*********************************************************/ /* Read in all parsable Bundle definitions */ /* REMEMBER TO REGISTER THESE IN cf3.extern.h */ struct SubTypeSyntax *CF_ALL_SUBTYPES[CF3_MODULES] = { CF_COMMON_SUBTYPES, /* Add modules after this, mod_report.c is here */ CF_EXEC_SUBTYPES, /* mod_exec.c */ CF_DATABASES_SUBTYPES, /* mod_databases.c */ CF_ENVIRONMENT_SUBTYPES, /* mod_environ.c */ CF_FILES_SUBTYPES, /* mod_files.c */ CF_INTERFACES_SUBTYPES, /* mod_interfaces.c */ CF_METHOD_SUBTYPES, /* mod_methods.c */ CF_OUTPUTS_SUBTYPES, /* mod_outputs.c */ CF_PACKAGES_SUBTYPES, /* mod_packages.c */ CF_PROCESS_SUBTYPES, /* mod_process.c */ CF_SERVICES_SUBTYPES, /* mod_services.c */ CF_STORAGE_SUBTYPES, /* mod_storage.c */ CF_REMACCESS_SUBTYPES, /* mod_access.c */ CF_KNOWLEDGE_SUBTYPES, /* mod_knowledge.c */ CF_MEASUREMENT_SUBTYPES, /* mod_measurement.c */ /* update CF3_MODULES in cf3.defs.h */ }; cfengine-3.2.4/src/modes.c0000644000175000017500000001735111715232734012275 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* Modestring toolkit */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /***************************************************************/ static int CheckModeState (enum modestate stateA, enum modestate stateB,enum modesort modeA, enum modesort modeB, char ch); static int SetModeMask (char action, int value, int affected, mode_t *p, mode_t *m); /***************************************************************/ int ParseModeString(char *modestring,mode_t *plusmask,mode_t *minusmask) { char *sp; int affected = 0, value = 0, gotaction, no_error = true; char action = '='; enum modestate state = unknown; enum modesort found_sort = unknown; /* Already found "sort" of mode */ enum modesort sort = unknown; /* Sort of started but not yet finished mode */ *plusmask = *minusmask = 0; if (modestring == NULL) { return true; } Debug("ParseModeString(%s)\n",modestring); gotaction = false; for (sp = modestring; true ; sp++) { switch (*sp) { case 'a': no_error = CheckModeState(who,state,symbolic,sort,*sp); affected |= 07777; sort = symbolic; break; case 'u': no_error = CheckModeState(who,state,symbolic,sort,*sp); affected |= 04700; sort = symbolic; break; case 'g': no_error = CheckModeState(who,state,symbolic,sort,*sp); affected |= 02070; sort = symbolic; break; case 'o': no_error = CheckModeState(who,state,symbolic,sort,*sp); affected |= 00007; sort = symbolic; break; case '+': case '-': case '=': if (gotaction) { CfOut(cf_error,"","Too many +-= in mode string"); return false; } no_error = CheckModeState(who,state,symbolic,sort,*sp); action = *sp; state = which; gotaction = true; sort = unknown; break; case 'r': no_error = CheckModeState(which,state,symbolic,sort,*sp); value |= 0444 & affected; sort = symbolic; break; case 'w': no_error = CheckModeState(which,state,symbolic,sort,*sp); value |= 0222 & affected; sort = symbolic; break; case 'x': no_error = CheckModeState(which,state,symbolic,sort,*sp); value |= 0111 & affected; sort = symbolic; break; case 's': no_error = CheckModeState(which,state,symbolic,sort,*sp); value |= 06000 & affected; sort = symbolic; break; case 't': no_error = CheckModeState(which,state,symbolic,sort,*sp); value |= 01000; sort = symbolic; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': no_error = CheckModeState(which,state,numeric,sort,*sp); sort = numeric; gotaction = true; state = which; affected = 07777; /* TODO: Hard-coded; see below */ sscanf(sp,"%o",&value); if (value > 07777) /* TODO: Hardcoded ! Is this correct for all sorts of Unix ? What about NT ? Any (POSIX)-constants ?? */ { CfOut(cf_error,"","Mode-Value too big : %s\n",modestring); return false; } while (isdigit((int)*sp) && (*sp != '\0')) { sp++; } sp--; break; case ',': if (!SetModeMask(action,value,affected,plusmask,minusmask)) { return false; } if (found_sort != unknown && found_sort != sort) { CfOut(cf_inform,"","Symbolic and numeric form for modes mixed"); } found_sort = sort; sort = unknown; action = '='; affected = 0; value = 0; gotaction = false; state = who; break; case '\0': if (state == who || value == 0) { if (strcmp(modestring,"0000") != 0 && strcmp(modestring,"000") != 0) { CfOut(cf_error,"","mode string is incomplete"); return false; } } if (!SetModeMask(action,value,affected,plusmask,minusmask)) { return false; } if (found_sort != unknown && found_sort != sort) { CfOut(cf_inform,"","Symbolic and numeric form for modes mixed"); } Debug1("[PLUS=%o][MINUS=%o]\n",*plusmask,*minusmask); return true; default: CfOut(cf_error,"","Invalid mode string (%s)",modestring); return false; } } if (!no_error) { CfOut(cf_error,"","Error validating mode string %s\n",modestring); } return no_error; } /*********************************************************/ static int CheckModeState(enum modestate stateA,enum modestate stateB,enum modesort sortA,enum modesort sortB,char ch) { if ((stateA != wild) && (stateB != wild) && (stateA != stateB)) { CfOut(cf_error,"","Mode string constant (%c) used out of context",ch); return false; } if ((sortA != unknown) && (sortB != unknown) && (sortA != sortB)) { CfOut(cf_error,"","Symbolic and numeric filemodes mixed within expression"); return false; } return true; } /*********************************************************/ static int SetModeMask(char action,int value,int affected,mode_t *p,mode_t *m) { Debug1("SetMask(%c%o,%o)\n",action,value,affected); switch(action) { case '+': *p |= value; *m |= 0; return true; case '-': *p |= 0; *m |= value; return true; case '=': *p |= value; *m |= ((~value) & 07777 & affected); return true; default: CfOut(cf_error,"","Mode directive %c is unknown",action); return false; } } cfengine-3.2.4/src/verify_exec.c0000644000175000017500000002351111715232734013471 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: verify_exec.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int ExecSanityChecks(struct Attributes a,struct Promise *pp); static void PreviewProtocolLine(char *line, char *comm); static void VerifyExec(struct Attributes a, struct Promise *pp); /*****************************************************************************/ void VerifyExecPromise(struct Promise *pp) { struct Attributes a = {{0}}; a = GetExecAttributes(pp); ExecSanityChecks(a,pp); VerifyExec(a,pp); DeleteScalar("this","promiser"); } /*****************************************************************************/ /* Level */ /*****************************************************************************/ static int ExecSanityChecks(struct Attributes a,struct Promise *pp) { if (a.contain.nooutput && a.contain.preview) { CfOut(cf_error,"","no_output and preview are mutually exclusive (broken promise)"); PromiseRef(cf_error,pp); return false; } #ifdef MINGW if(a.contain.umask != CF_UNDEFINED) // TODO: Always true (077 != -1?, compare positive and negative number), make false when umask not set { CfOut(cf_verbose, "", "contain.umask is ignored on Windows"); } if(a.contain.owner != CF_UNDEFINED) { CfOut(cf_verbose, "", "contain.exec_owner is ignored on Windows"); } if(a.contain.group != CF_UNDEFINED) { CfOut(cf_verbose, "", "contain.exec_group is ignored on Windows"); } if(a.contain.chroot != NULL) { CfOut(cf_verbose, "", "contain.chroot is ignored on Windows"); } #else /* NOT MINGW */ if (a.contain.umask == CF_UNDEFINED) { a.contain.umask = 077; } #endif /* NOT MINGW */ return true; } /*****************************************************************************/ static void VerifyExec(struct Attributes a, struct Promise *pp) { struct CfLock thislock; char unsafeLine[CF_BUFSIZE], line[sizeof(unsafeLine)*2],eventname[CF_BUFSIZE]; char comm[20]; char execstr[CF_EXPANDSIZE]; struct timespec start; int outsourced,count = 0; mode_t maskval = 0; FILE *pfp; char cmdOutBuf[CF_BUFSIZE]; int cmdOutBufPos = 0; int lineOutLen; if (!IsExecutable(GetArg0(pp->promiser))) { cfPS(cf_error,CF_FAIL,"",pp,a,"%s promises to be executable but isn't\n",pp->promiser); if (strchr(pp->promiser, ' ')) { CfOut(cf_verbose, "", "Paths with spaces must be inside escaped quoutes (e.g. \\\"%s\\\")", pp->promiser); } return; } else { CfOut(cf_verbose,""," -> Promiser string contains a valid executable (%s) - ok\n",GetArg0(pp->promiser)); } DeleteScalar("this","promiser"); NewScalar("this","promiser",pp->promiser,cf_str); if (a.args) { snprintf(execstr,CF_EXPANDSIZE-1,"%s %s",pp->promiser,a.args); } else { strncpy(execstr,pp->promiser,CF_BUFSIZE); } thislock = AcquireLock(execstr,VUQNAME,CFSTARTTIME,a,pp,false); if (thislock.lock == NULL) { return; } PromiseBanner(pp); CfOut(cf_inform,""," -> Executing \'%s\' ...(timeout=%d,owner=%d,group=%d)\n",execstr,a.contain.timeout,a.contain.owner,a.contain.group); start = BeginMeasure(); if (DONTDO && !a.contain.preview) { CfOut(cf_error,"","-> Would execute script %s\n",execstr); } else if(a.transaction.action != cfa_fix) { cfPS(cf_error,CF_WARN,"",pp,a," !! Command \"%s\" needs to be executed, but only warning was promised", execstr); } else { CommPrefix(execstr,comm); if (a.transaction.background) { #ifdef MINGW outsourced = true; #else CfOut(cf_verbose,""," -> Backgrounding job %s\n",execstr); outsourced = fork(); #endif } else { outsourced = false; } if (outsourced || !a.transaction.background) // work done here: either by child or non-background parent { if (a.contain.timeout != CF_NOINT) { SetTimeOut(a.contain.timeout); } #ifndef MINGW CfOut(cf_verbose,""," -> (Setting umask to %o)\n",a.contain.umask); maskval = umask(a.contain.umask); if (a.contain.umask == 0) { CfOut(cf_verbose,""," !! Programming %s running with umask 0! Use umask= to set\n",execstr); } #endif /* NOT MINGW */ if (a.contain.useshell) { pfp = cf_popen_shsetuid(execstr,"r",a.contain.owner,a.contain.group,a.contain.chdir,a.contain.chroot,a.transaction.background); } else { pfp = cf_popensetuid(execstr,"r",a.contain.owner,a.contain.group,a.contain.chdir,a.contain.chroot,a.transaction.background); } if (pfp == NULL) { cfPS(cf_error,CF_FAIL,"cf_popen",pp,a,"!! Couldn't open pipe to command %s\n",execstr); YieldCurrentLock(thislock); return; } while (!feof(pfp)) { if (ferror(pfp)) /* abortable */ { cfPS(cf_error,CF_TIMEX,"ferror",pp,a,"!! Command pipe %s\n",execstr); cf_pclose(pfp); YieldCurrentLock(thislock); return; } CfReadLine(unsafeLine,CF_BUFSIZE-1,pfp); ReplaceStr(unsafeLine,line,sizeof(line),"%","%%"); // escape format char if (strstr(line,"cfengine-die")) { break; } if (ferror(pfp)) /* abortable */ { cfPS(cf_error,CF_TIMEX,"ferror",pp,a,"!! Command pipe %s\n",execstr); cf_pclose(pfp); YieldCurrentLock(thislock); return; } if (a.contain.preview) { PreviewProtocolLine(line,execstr); } if (a.module) { ModuleProtocol(execstr,line,!a.contain.nooutput); } else if (!a.contain.nooutput && NonEmptyLine(line)) { lineOutLen = strlen(comm) + strlen(line) + 12; // if buffer is to small for this line, output it directly if(lineOutLen > sizeof(cmdOutBuf)) { CfOut(cf_cmdout,"","Q: \"...%s\": %s\n",comm,line); } else { if(cmdOutBufPos + lineOutLen > sizeof(cmdOutBuf)) { CfOut(cf_cmdout, "", "%s", cmdOutBuf); cmdOutBufPos = 0; } sprintf(cmdOutBuf + cmdOutBufPos, "Q: \"...%s\": %s\n",comm, line); cmdOutBufPos += (lineOutLen - 1); } count++; } } #ifdef MINGW if (outsourced) // only get return value if we waited for command execution { cf_pclose(pfp); } else { cf_pclose_def(pfp,a,pp); } #else /* NOT MINGW */ cf_pclose_def(pfp,a,pp); #endif } if (count) { if (cmdOutBufPos) { CfOut(cf_cmdout, "", "%s", cmdOutBuf); } CfOut(cf_cmdout,"","I: Last %d quoted lines were generated by promiser \"%s\"\n",count,execstr); } if (a.contain.timeout != CF_NOINT) { alarm(0); signal(SIGALRM,SIG_DFL); } CfOut(cf_inform,""," -> Completed execution of %s\n",execstr); #ifndef MINGW umask(maskval); #endif YieldCurrentLock(thislock); snprintf(eventname,CF_BUFSIZE-1,"Exec(%s)",execstr); #ifndef MINGW if (a.transaction.background && outsourced) { CfOut(cf_verbose,""," -> Backgrounded command (%s) is done - exiting\n",execstr); exit(0); } #endif /* NOT MINGW */ } } /*************************************************************/ /* Level */ /*************************************************************/ void PreviewProtocolLine(char *line, char *comm) { int i; enum cfreport level = cf_error; char *message = line; /* * Table matching cfoutputlevel enums to log prefixes. */ char *prefixes[] = { ":silent:", ":inform:", ":verbose:", ":editverbose:", ":error:", ":logonly:", }; int precount = sizeof(prefixes)/sizeof(char *); if (line[0] == ':') { /* * Line begins with colon - see if it matches a log prefix. */ for (i = 0; i < precount; i++) { int prelen = 0; prelen = strlen(prefixes[i]); if (strncmp(line, prefixes[i], prelen) == 0) { /* * Found log prefix - set logging level, and remove the * prefix from the log message. */ level = i; message += prelen; break; } } } CfOut(cf_verbose,"","%s (preview of %s)\n",message,comm); } cfengine-3.2.4/src/env_context.c0000644000175000017500000007710011715232734013520 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: env_context.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #include "logic_expressions.h" static bool ValidClassName(const char *str); static int GetORAtom(char *start,char *buffer); static int HasBrackets(char *s,struct Promise *pp); static int IsBracketed(char *s); /*****************************************************************************/ /* Level */ /*****************************************************************************/ static int EvalClassExpression(struct Constraint *cp,struct Promise *pp) { int result_and = true; int result_or = false; int result_xor = 0; int result = 0,total = 0; char buffer[CF_MAXVARSIZE]; struct Rlist *rp; double prob,cum = 0,fluct; struct Rval newret; struct FnCall *fp; if (cp == NULL) { CfOut(cf_error,""," !! EvalClassExpression internal diagnostic discovered an ill-formed condition"); } if (!IsDefinedClass(pp->classes)) { return false; } if (pp->done) { return false; } if (IsDefinedClass(pp->promiser)) { return false; } switch (cp->type) { case CF_FNCALL: fp = (struct FnCall *)cp->rval; /* Special expansion of functions for control, best effort only */ newret = EvaluateFunctionCall(fp,pp); DeleteFnCall(fp); cp->rval = newret.item; cp->type = newret.rtype; break; case CF_LIST: for (rp = (struct Rlist *)cp->rval; rp != NULL; rp = rp->next) { newret = EvaluateFinalRval("this",rp->item,rp->type,true,pp); DeleteRvalItem(rp->item,rp->type); rp->item = newret.item; rp->type = newret.rtype; } break; default: newret = ExpandPrivateRval("this",cp->rval,cp->type); DeleteRvalItem(cp->rval,cp->type); cp->rval = newret.item; cp->type = newret.rtype; break; } if (strcmp(cp->lval,"expression") == 0) { if (cp->type != CF_SCALAR) { return false; } if (IsDefinedClass((char *)cp->rval)) { return true; } else { return false; } } if (strcmp(cp->lval,"not") == 0) { if (cp->type != CF_SCALAR) { return false; } if (IsDefinedClass((char *)cp->rval)) { return false; } else { return true; } } // Class selection if (strcmp(cp->lval,"select_class") == 0) { char splay[CF_MAXVARSIZE]; int i,n; double hash; total = 0; for (rp = (struct Rlist *)cp->rval; rp != NULL; rp = rp->next) { total++; } if (total == 0) { CfOut(cf_error,""," !! No classes to select on RHS"); PromiseRef(cf_error,pp); return false; } snprintf(splay,CF_MAXVARSIZE,"%s+%s+%d",VFQNAME,VIPADDRESS,getuid()); hash = (double)GetHash(splay); n = (int)(total*hash/(double)CF_HASHTABLESIZE); for (rp = (struct Rlist *)cp->rval,i = 0; rp != NULL; rp = rp->next,i++) { if (i == n) { NewClass(rp->item); return true; } } } // Class distributions if (strcmp(cp->lval,"dist") == 0) { for (rp = (struct Rlist *)cp->rval; rp != NULL; rp = rp->next) { result = Str2Int(rp->item); if (result < 0) { CfOut(cf_error,""," !! Non-positive integer in class distribution"); PromiseRef(cf_error,pp); return false; } total += result; } if (total == 0) { CfOut(cf_error,""," !! An empty distribution was specified on RHS"); PromiseRef(cf_error,pp); return false; } } fluct = drand48(); /* Get random number 0-1 */ cum = 0.0; /* If we get here, anything remaining on the RHS must be a clist */ if (cp->type != CF_LIST) { CfOut(cf_error,""," !! RHS of promise body attribute \"%s\" is not a list\n",cp->lval); PromiseRef(cf_error,pp); return true; } for (rp = (struct Rlist *)cp->rval; rp != NULL; rp = rp->next) { if (rp->type != CF_SCALAR) { return false; } result = IsDefinedClass((char *)(rp->item)); result_and = result_and && result; result_or = result_or || result; result_xor ^= result; if (total > 0) // dist class { prob = ((double)Str2Int(rp->item))/((double)total); cum += prob; if ((fluct < cum) || rp->next == NULL) { snprintf(buffer,CF_MAXVARSIZE-1,"%s_%s",pp->promiser,rp->item); *(pp->donep) = true; if (strcmp(pp->bundletype,"common") == 0) { NewClass(buffer); } else { NewBundleClass(buffer,pp->bundle); } Debug(" ?? \'Strategy\' distribution class interval -> %s\n",buffer); return true; } } } // Class combinations if (strcmp(cp->lval,"or") == 0) { return result_or; } if (strcmp(cp->lval,"xor") == 0) { return (result_xor == 1) ? true : false; } if (strcmp(cp->lval,"and") == 0) { return result_and; } return false; } /*******************************************************************/ void KeepClassContextPromise(struct Promise *pp) { struct Attributes a; a = GetClassContextAttributes(pp); if (!FullTextMatch("[a-zA-Z0-9_]+",pp->promiser)) { CfOut(cf_verbose,"","Class identifier \"%s\" contains illegal characters - canonifying",pp->promiser); snprintf(pp->promiser, strlen(pp->promiser) + 1, "%s", CanonifyName(pp->promiser)); } if (a.context.broken) { cfPS(cf_error,CF_FAIL,"",pp,a,"Irreconcilable constraints in classes for %s (broken promise)",pp->promiser); return; } if (strcmp(pp->bundletype,"common") == 0) { if (EvalClassExpression(a.context.expression,pp)) { CfOut(cf_verbose,""," ?> defining additional global class %s\n",pp->promiser); if (!ValidClassName(pp->promiser)) { cfPS(cf_error,CF_FAIL,"",pp,a," !! Attempted to name a class \"%s\", which is an illegal class identifier",pp->promiser); } else { NewClass(pp->promiser); } } /* These are global and loaded once */ //*(pp->donep) = true; return; } if (strcmp(pp->bundletype,THIS_AGENT) == 0 || FullTextMatch("edit_.*",pp->bundletype)) { if (EvalClassExpression(a.context.expression,pp)) { Debug(" ?> defining explicit class %s\n",pp->promiser); if (!ValidClassName(pp->promiser)) { cfPS(cf_error,CF_FAIL,"",pp,a," !! Attempted to name a class \"%s\", which is an illegal class identifier",pp->promiser); } else { NewBundleClass(pp->promiser,pp->bundle); } } // Private to bundle, can be reloaded *(pp->donep) = false; return; } } /*******************************************************************/ void NewClass(const char *oclass) { struct Item *ip; char class[CF_MAXVARSIZE]; strncpy(class, oclass, CF_MAXVARSIZE); Chop(class); CanonifyNameInPlace(class); Debug("NewClass(%s)\n",class); if (strlen(class) == 0) { return; } if (IsRegexItemIn(ABORTBUNDLEHEAP,class)) { CfOut(cf_error,"","Bundle aborted on defined class \"%s\"\n",class); ABORTBUNDLE = true; } if (IsRegexItemIn(ABORTHEAP,class)) { CfOut(cf_error,"","cf-agent aborted on defined class \"%s\"\n",class); exit(1); } if (InAlphaList(VHEAP,class)) { return; } PrependAlphaList(&VHEAP,class); for (ip = ABORTHEAP; ip != NULL; ip = ip->next) { if (IsDefinedClass(ip->name)) { CfOut(cf_error,"","cf-agent aborted on defined class \"%s\" defined in bundle %s\n",class,THIS_BUNDLE); exit(1); } } if (!ABORTBUNDLE) { for (ip = ABORTBUNDLEHEAP; ip != NULL; ip = ip->next) { if (IsDefinedClass(ip->name)) { CfOut(cf_error,""," -> Setting abort for \"%s\" when setting \"%s\"",ip->name,class); ABORTBUNDLE = true; break; } } } } /*********************************************************************/ void DeleteClass(char *class) { int i = (int)*class; DeleteItemLiteral(&(VHEAP.list[i]),class); DeleteItemLiteral(&(VADDCLASSES.list[i]),class); } /*******************************************************************/ void NewBundleClass(char *class,char *bundle) { char copy[CF_BUFSIZE]; struct Item *ip; memset(copy,0,CF_BUFSIZE); strncpy(copy,class,CF_MAXVARSIZE); Chop(copy); if (strlen(copy) == 0) { return; } Debug("NewBundleClass(%s)\n",copy); if (IsRegexItemIn(ABORTBUNDLEHEAP,copy)) { CfOut(cf_error,"","Bundle %s aborted on defined class \"%s\"\n",bundle,copy); ABORTBUNDLE = true; } if (IsRegexItemIn(ABORTHEAP,copy)) { CfOut(cf_error,"","cf-agent aborted on defined class \"%s\" defined in bundle %s\n",copy,bundle); exit(1); } if (InAlphaList(VHEAP,copy)) { CfOut(cf_error,"","WARNING - private class \"%s\" in bundle \"%s\" shadows a global class - you should choose a different name to avoid conflicts",copy,bundle); } if (InAlphaList(VADDCLASSES,copy)) { return; } PrependAlphaList(&VADDCLASSES,copy); for (ip = ABORTHEAP; ip != NULL; ip = ip->next) { if (IsDefinedClass(ip->name)) { CfOut(cf_error,"","cf-agent aborted on defined class \"%s\" defined in bundle %s\n",copy,bundle); exit(1); } } if (!ABORTBUNDLE) { for (ip = ABORTBUNDLEHEAP; ip != NULL; ip = ip->next) { if (IsDefinedClass(ip->name)) { CfOut(cf_error,""," -> Setting abort for \"%s\" when setting \"%s\"",ip->name,class); ABORTBUNDLE = true; break; } } } } /*********************************************************************/ struct Rlist *SplitContextExpression(char *context,struct Promise *pp) { struct Rlist *list = NULL; char *sp,cbuff[CF_MAXVARSIZE]; if (context == NULL) { PrependRScalar(&list,"any",CF_SCALAR); } else { for (sp = context; *sp != '\0'; sp++) { while (*sp == '|') { sp++; } memset(cbuff,0,CF_MAXVARSIZE); sp += GetORAtom(sp,cbuff); if (strlen(cbuff) == 0) { break; } if (IsBracketed(cbuff)) { // Fully bracketed atom (protected) cbuff[strlen(cbuff)-1] = '\0'; PrependRScalar(&list,cbuff+1,CF_SCALAR); } else { if (HasBrackets(cbuff,pp)) { struct Rlist *andlist = SplitRegexAsRList(cbuff,"[.&]+",99,false); struct Rlist *rp,*orlist = NULL; char buff[CF_MAXVARSIZE]; char orstring[CF_MAXVARSIZE] = {0}; char andstring[CF_MAXVARSIZE] = {0}; // Apply distribution P.(A|B) -> P.A|P.B for (rp = andlist; rp != NULL; rp=rp->next) { if (IsBracketed(rp->item)) { // This must be an OR string to be ORed and split into a list *((char *)rp->item+strlen((char *)rp->item)-1) = '\0'; if (strlen(orstring) > 0) { strcat(orstring,"|"); } Join(orstring,(char *)(rp->item)+1,CF_MAXVARSIZE); } else { if (strlen(andstring) > 0) { strcat(andstring,"."); } Join(andstring,rp->item,CF_MAXVARSIZE); } // foreach ORlist, AND with AND string } if (strlen(orstring) > 0) { orlist = SplitRegexAsRList(orstring,"[|]+",99,false); for (rp = orlist; rp != NULL; rp=rp->next) { snprintf(buff,CF_MAXVARSIZE,"%s.%s",rp->item,andstring); PrependRScalar(&list,buff,CF_SCALAR); } } else { PrependRScalar(&list,andstring,CF_SCALAR); } DeleteRlist(orlist); DeleteRlist(andlist); } else { // Clean atom PrependRScalar(&list,cbuff,CF_SCALAR); } } if (*sp == '\0') { break; } } } return list; } /*********************************************************************/ static int IsBracketed(char *s) /* return true if the entire string is bracketed, not just if if contains brackets */ { int i, level= 0, yes = 0; if (*s != '(') { return false; } if (*(s+strlen(s)-1) != ')') { return false; } if (strstr(s,")(")) { CfOut(cf_error,""," !! Class expression \"%s\" has broken brackets",s); return false; } for (i = 0; i < strlen(s); i++) { if (s[i] == '(') { yes++; level++; if (i > 0 && !strchr(".&|!(", s[i-1])) { CfOut(cf_error,""," !! Class expression \"%s\" has a missing operator in front of '('",s); } } if (s[i] == ')') { yes++; level--; if (i < strlen(s)-1 && !strchr(".&|!)", s[i+1])) { CfOut(cf_error,""," !! Class expression \"%s\" has a missing operator after of ')'",s); } } } if (level != 0) { CfOut(cf_error,""," !! Class expression \"%s\" has broken brackets",s); return false; /* premature ) */ } if (yes > 2) { // e.g. (a|b).c.(d|e) return false; } return true; } /*********************************************************************/ static int GetORAtom(char *start,char *buffer) { char *sp = start; char *spc = buffer; int bracklevel = 0, len = 0; while ((*sp != '\0') && !((*sp == '|') && (bracklevel == 0))) { if (*sp == '(') { Debug("+(\n"); bracklevel++; } if (*sp == ')') { Debug("-)\n"); bracklevel--; } Debug("(%c)",*sp); *spc++ = *sp++; len++; } *spc = '\0'; Debug("\nGetORATom(%s)->%s\n",start,buffer); return len; } /*********************************************************************/ static int HasBrackets(char *s,struct Promise *pp) /* return true if contains brackets */ { int i, level= 0, yes = 0; for (i = 0; i < strlen(s); i++) { if (s[i] == '(') { yes++; level++; if (i > 0 && !strchr(".&|!(", s[i+1])) { CfOut(cf_error,""," !! Class expression \"%s\" has a missing operator in front of '('",s); } } if (s[i] == ')') { level--; if (i < strlen(s)-1 && !strchr(".&|!)", s[i+1])) { CfOut(cf_error,""," !! Class expression \"%s\" has a missing operator after ')'",s); } } } if (level != 0) { CfOut(cf_error,""," !! Class expression \"%s\" has unbalanced brackets",s); PromiseRef(cf_error,pp); return true; } if (yes > 1) { CfOut(cf_error,""," !! Class expression \"%s\" has multiple brackets",s); PromiseRef(cf_error,pp); } else if (yes) { return true; } return false; } /**********************************************************************/ /* Utilities */ /**********************************************************************/ /* Return expression with error position highlighted. Result is on the heap. */ static char *HighlightExpressionError(const char *str, int position) { char *errmsg = malloc(strlen(str) + 3); char *firstpart = strndup(str, position); char *secondpart = strndup(str + position, strlen(str) - position); sprintf(errmsg, "%s->%s", firstpart, secondpart); free(secondpart); free(firstpart); return errmsg; } /**********************************************************************/ /* Debugging output */ static void IndentL(int level) { int i; if (level > 0) { putc('\n', stderr); for(i = 0; i < level; ++i) { putc(' ', stderr); } } } /**********************************************************************/ static int IncIndent(int level, int inc) { if (level < 0) { return -level + inc; } else { return level + inc; } } /**********************************************************************/ static void EmitStringExpression(StringExpression *e, int level) { if (!e) { return; } switch (e->op) { case CONCAT: IndentL(level); fputs("(concat ", stderr); EmitStringExpression(e->val.concat.lhs, -IncIndent(level, 8)); EmitStringExpression(e->val.concat.rhs, IncIndent(level, 8)); fputs(")", stderr); break; case LITERAL: IndentL(level); fprintf(stderr, "\"%s\"", e->val.literal.literal); break; case VARREF: IndentL(level); fputs("($ ", stderr); EmitStringExpression(e->val.varref.name, -IncIndent(level, 3)); break; default: FatalError("Unknown type of string expression: %d\n", e->op); break; } } /**********************************************************************/ static void EmitExpression(Expression *e, int level) { if (!e) { return; } switch (e->op) { case OR: case AND: IndentL(level); fprintf(stderr, "(%s ", e->op == OR ? "|" : "&"); EmitExpression(e->val.andor.lhs, -IncIndent(level, 3)); EmitExpression(e->val.andor.rhs, IncIndent(level, 3)); fputs(")", stderr); break; case NOT: IndentL(level); fputs("(- ", stderr); EmitExpression(e->val.not.arg, -IncIndent(level, 3)); fputs(")", stderr); break; case EVAL: IndentL(level); fputs("(eval ", stderr); EmitStringExpression(e->val.eval.name, -IncIndent(level, 6)); fputs(")", stderr); break; default: FatalError("Unknown logic expression type: %d\n", e->op); } } /*****************************************************************************/ /* Syntax-checking and evaluating various expressions */ /*****************************************************************************/ static void EmitParserError(const char *str, int position) { char *errmsg = HighlightExpressionError(str, position); yyerror(errmsg); free(errmsg); } /**********************************************************************/ /* To be used from parser only (uses yyerror) */ void ValidateClassSyntax(const char *str) { ParseResult res = ParseExpression(str, 0, strlen(str)); if (DEBUG || D1 || D2) { EmitExpression(res.result, 0); putc('\n', stderr); } if (res.result) { FreeExpression(res.result); } if (!res.result || res.position != strlen(str)) { EmitParserError(str, res.position); } } /**********************************************************************/ static bool ValidClassName(const char *str) { ParseResult res = ParseExpression(str, 0, strlen(str)); if (res.result) { FreeExpression(res.result); } return res.result && res.position == strlen(str); } /**********************************************************************/ static ExpressionValue EvalTokenAsClass(const char *classname, void *param) { if (IsItemIn(VNEGHEAP, classname)) { return false; } if (IsItemIn(VDELCLASSES, classname)) { return false; } if (InAlphaList(VHEAP, classname)) { return true; } if (InAlphaList(VADDCLASSES, classname)) { return true; } return false; } /**********************************************************************/ static char *EvalVarRef(const char *varname, void *param) { /* * There should be no unexpanded variables when we evaluate any kind of * logic expressions, until parsing of logic expression changes and they are * not pre-expanded before evaluation. */ return NULL; } /**********************************************************************/ bool IsDefinedClass(const char *class) { ParseResult res; if (!class) { return true; } res = ParseExpression(class, 0, strlen(class)); if (!res.result) { char *errexpr = HighlightExpressionError(class, res.position); CfOut(cf_error,"","Unable to parse class expression: %s", errexpr); free(errexpr); return false; } else { ExpressionValue r = EvalExpression(res.result, &EvalTokenAsClass, &EvalVarRef, NULL); FreeExpression(res.result); Debug("Evaluate(%s) -> %d\n", class, r); /* r is EvalResult which could be ERROR */ return r == true; } } /**********************************************************************/ bool IsExcluded(const char *exception) { return !IsDefinedClass(exception); } /**********************************************************************/ static ExpressionValue EvalTokenFromList(const char *token, void *param) { return InAlphaList(*(struct AlphaList *)param, token); } /**********************************************************************/ static bool EvalWithTokenFromList(const char *expr, struct AlphaList *token_list) { ParseResult res = ParseExpression(expr, 0, strlen(expr)); if (!res.result) { char *errexpr = HighlightExpressionError(expr, res.position); CfOut(cf_error, "", "Syntax error in expression: %s", errexpr); free(errexpr); return false; /* FIXME: return error */ } else { ExpressionValue r = EvalExpression(res.result, &EvalTokenFromList, &EvalVarRef, token_list); FreeExpression(res.result); /* r is EvalResult which could be ERROR */ return r == true; } } /**********************************************************************/ /* Process result expression */ bool EvalProcessResult(const char *process_result, struct AlphaList *proc_attr) { return EvalWithTokenFromList(process_result, proc_attr); } /**********************************************************************/ /* File result expressions */ bool EvalFileResult(const char *file_result, struct AlphaList *leaf_attr) { return EvalWithTokenFromList(file_result, leaf_attr); } /*****************************************************************************/ void DeleteEntireHeap() { DeleteAlphaList(&VHEAP); InitAlphaList(&VHEAP); } /*****************************************************************************/ void DeletePrivateClassContext() { DeleteAlphaList(&VADDCLASSES); InitAlphaList(&VADDCLASSES); DeleteItemList(VDELCLASSES); VDELCLASSES = NULL; } /*****************************************************************************/ void PushPrivateClassContext() { struct AlphaList *ap = malloc(sizeof(struct AlphaList)); // copy to heap PushStack(&PRIVCLASSHEAP,CopyAlphaListPointers(ap,&VADDCLASSES)); InitAlphaList(&VADDCLASSES); } /*****************************************************************************/ void PopPrivateClassContext() { struct AlphaList *ap; DeleteAlphaList(&VADDCLASSES); PopStack(&PRIVCLASSHEAP,(void *)&ap,sizeof(VADDCLASSES)); CopyAlphaListPointers(&VADDCLASSES,ap); free(ap); } /*****************************************************************************/ void NewPersistentContext(char *name,unsigned int ttl_minutes,enum statepolicy policy) { int errno; CF_DB *dbp; struct CfState state; time_t now = time(NULL); char filename[CF_BUFSIZE]; snprintf(filename,CF_BUFSIZE,"%s/state/%s",CFWORKDIR,CF_STATEDB_FILE); MapName(filename); if (!OpenDB(filename,&dbp)) { return; } cf_chmod(filename,0644); if (ReadDB(dbp,name,&state,sizeof(state))) { if (state.policy == cfpreserve) { if (now < state.expires) { CfOut(cf_verbose,""," -> Persisent state %s is already in a preserved state -- %d minutes to go\n",name,(state.expires-now)/60); CloseDB(dbp); return; } } } else { CfOut(cf_verbose,""," -> New persistent state %s\n",name); state.expires = now + ttl_minutes * 60; state.policy = policy; } WriteDB(dbp,name,&state,sizeof(state)); CloseDB(dbp); } /*****************************************************************************/ void DeletePersistentContext(char *name) { int errno; CF_DB *dbp; char filename[CF_BUFSIZE]; snprintf(filename,CF_BUFSIZE,"%s/state/%s",CFWORKDIR,CF_STATEDB_FILE); MapName(filename); if (!OpenDB(filename,&dbp)) { return; } cf_chmod(filename,0644); DeleteDB(dbp,name); Debug("Deleted any persistent state %s\n",name); CloseDB(dbp); } /*****************************************************************************/ void LoadPersistentContext() { CF_DB *dbp; CF_DBC *dbcp; int ksize,vsize; char *key; void *value; time_t now = time(NULL); struct CfState q; char filename[CF_BUFSIZE]; if (LOOKUP) { return; } Banner("Loading persistent classes"); snprintf(filename,CF_BUFSIZE,"%s/state/%s",CFWORKDIR,CF_STATEDB_FILE); MapName(filename); if (!OpenDB(filename,&dbp)) { return; } /* Acquire a cursor for the database. */ if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan persistence cache"); return; } while(NextDB(dbp,dbcp,&key,&ksize,&value,&vsize)) { memcpy((void *)&q,value,sizeof(struct CfState)); Debug(" - Found key %s...\n",key); if (now > q.expires) { CfOut(cf_verbose,""," Persistent class %s expired\n",key); DeleteDB(dbp,key); } else { CfOut(cf_verbose,""," Persistent class %s for %d more minutes\n",key,(q.expires-now)/60); CfOut(cf_verbose,""," Adding persistent class %s to heap\n",key); NewClass(key); } } DeleteDBCursor(dbp,dbcp); CloseDB(dbp); Banner("Loaded persistent memory"); } /*****************************************************************************/ void AddEphemeralClasses(struct Rlist *classlist) { struct Rlist *rp; for (rp = classlist; rp != NULL; rp = rp->next) { if (!InAlphaList(VHEAP,rp->item)) { NewClass(rp->item); } } } /*********************************************************************/ void NewClassesFromString(char *classlist) { char *sp, currentitem[CF_MAXVARSIZE],local[CF_MAXVARSIZE]; if ((classlist == NULL) || strlen(classlist) == 0) { return; } memset(local,0,CF_MAXVARSIZE); strncpy(local,classlist,CF_MAXVARSIZE-1); for (sp = local; *sp != '\0'; sp++) { memset(currentitem,0,CF_MAXVARSIZE); sscanf(sp,"%250[^,]",currentitem); sp += strlen(currentitem); if (IsHardClass(currentitem)) { FatalError("cfengine: You cannot use -D to define a reserved class!"); } NewClass(currentitem); } } /*********************************************************************/ void NegateClassesFromString(char *classlist,struct Item **heap) { char *sp, currentitem[CF_MAXVARSIZE],local[CF_MAXVARSIZE]; if ((classlist == NULL) || strlen(classlist) == 0) { return; } memset(local,0,CF_MAXVARSIZE); strncpy(local,classlist,CF_MAXVARSIZE-1); for (sp = local; *sp != '\0'; sp++) { memset(currentitem,0,CF_MAXVARSIZE); sscanf(sp,"%250[^,]",currentitem); sp += strlen(currentitem); if (IsHardClass(currentitem)) { char err[CF_BUFSIZE]; sprintf (err,"Cannot negate the reserved class [%s]\n",currentitem); FatalError(err); } AppendItem(heap,currentitem,NULL); } } /*********************************************************************/ void AddPrefixedClasses(char *name,char *classlist) { char *sp, currentitem[CF_MAXVARSIZE],local[CF_MAXVARSIZE],pref[CF_BUFSIZE]; if ((classlist == NULL) || strlen(classlist) == 0) { return; } memset(local,0,CF_MAXVARSIZE); strncpy(local,classlist,CF_MAXVARSIZE-1); for (sp = local; *sp != '\0'; sp++) { memset(currentitem,0,CF_MAXVARSIZE); sscanf(sp,"%250[^.:,]",currentitem); sp += strlen(currentitem); pref[0] = '\0'; snprintf(pref,CF_BUFSIZE,"%s_%s",name,currentitem); if (IsHardClass(pref)) { FatalError("cfengine: You cannot use -D to define a reserved class!"); } NewClass(pref); } } /*********************************************************************/ int IsHardClass(char *sp) /* true if string matches a hardwired class e.g. hpux */ { int i; static char *names[] = { "any","agent","Morning","Afternoon","Evening","Night","Q1","Q2","Q3","Q4", "SuSE","suse","fedora","Ubuntu","lsb_compliant","localhost", NULL }; static char *prefixes[] = { "cfengine_","ipv4", NULL }; for (i = 2; CLASSTEXT[i] != '\0'; i++) { if (strcmp(CLASSTEXT[i],sp) == 0) { return true; } } for (i = 0; i < 7; i++) { if (strcmp(DAY_TEXT[i],sp)==0) { return true; } } for (i = 0; i < 12; i++) { if (strncmp(MONTH_TEXT[i],sp,3) == 0) { return true; } } for (i = 0; names[i] != NULL; i++) { if (strcmp(names[i],sp) == 0) { return true; } } for (i = 0; prefixes[i] != NULL; i++) { if (strncmp(prefixes[i],sp,strlen(prefixes[i])) == 0) { return true; } } if (strncmp(sp,"Min",3) == 0 && isdigit(*(sp+3))) { return true; } if (strncmp(sp,"Hr",2) == 0 && isdigit(*(sp+2))) { return true; } if (strncmp(sp,"Yr",2) == 0 && isdigit(*(sp+2))) { return true; } if (strncmp(sp,"Day",3) == 0 && isdigit(*(sp+3))) { return true; } if (strncmp(sp,"GMT",3) == 0 && *(sp+3) == '_') { return true; } if (strncmp(sp,"Lcycle",strlen("Lcycle")) == 0) { return true; } return(false); } /***************************************************************************/ int Abort() { if (ABORTBUNDLE) { ABORTBUNDLE = false; return true; } return false; } /*****************************************************************************/ int VarClassExcluded(struct Promise *pp,char **classes) { *classes = (char *)GetConstraint("ifvarclass",pp,CF_SCALAR); if (*classes == NULL) { return false; } if (strchr(*classes,'$') || strchr(*classes,'@')) { Debug("Class expression did not evaluate"); return true; } if (*classes && IsDefinedClass(*classes)) { return false; } else { return true; } } /*******************************************************************/ void SaveClassEnvironment() { char file[CF_BUFSIZE]; FILE *fp; snprintf(file,CF_BUFSIZE,"%s/state/allclasses.txt",CFWORKDIR); if ((fp = fopen(file,"w")) == NULL) { CfOut(cf_inform,"","Could not open allclasses cache file"); return; } ListAlphaList(fp,VHEAP,'\n'); ListAlphaList(fp,VADDCLASSES,'\n'); fclose(fp); } cfengine-3.2.4/src/mon_processes.c0000644000175000017500000000610311715232734014036 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #include "cf3.defs.h" #include "cf3.extern.h" #include "monitoring.h" /* Prototypes */ static int GatherProcessUsers(struct Item **userList, int *userListSz, int *numRootProcs, int *numOtherProcs); static int Unix_GatherProcessUsers(struct Item **userList, int *userListSz, int *numRootProcs, int *numOtherProcs); /* Implementation */ void MonProcessesGatherData(double *cf_this) { struct Item *userList = NULL; char vbuff[CF_BUFSIZE]; int numProcUsers = 0; int numRootProcs = 0; int numOtherProcs = 0; if (!GatherProcessUsers(&userList, &numProcUsers, &numRootProcs, &numOtherProcs)) { return; } cf_this[ob_users] += numProcUsers; cf_this[ob_rootprocs] += numRootProcs; cf_this[ob_otherprocs] += numOtherProcs; snprintf(vbuff,CF_MAXVARSIZE,"%s/state/cf_users",CFWORKDIR); MapName(vbuff); RawSaveItemList(userList,vbuff); DeleteItemList(userList); CfOut(cf_verbose,"","(Users,root,other) = (%d,%d,%d)\n",cf_this[ob_users],cf_this[ob_rootprocs],cf_this[ob_otherprocs]); } static int GatherProcessUsers(struct Item **userList, int *userListSz, int *numRootProcs, int *numOtherProcs) { #ifdef MINGW return NovaWin_GatherProcessUsers(userList, userListSz, numRootProcs, numOtherProcs); #else return Unix_GatherProcessUsers(userList, userListSz, numRootProcs, numOtherProcs); #endif } #ifndef MINGW static int Unix_GatherProcessUsers(struct Item **userList, int *userListSz, int *numRootProcs, int *numOtherProcs) { FILE *pp; char pscomm[CF_BUFSIZE]; char user[CF_MAXVARSIZE]; char vbuff[CF_BUFSIZE]; snprintf(pscomm,CF_BUFSIZE,"%s %s",VPSCOMM[VSYSTEMHARDCLASS],VPSOPTS[VSYSTEMHARDCLASS]); if ((pp = cf_popen(pscomm,"r")) == NULL) { return false; } CfReadLine(vbuff,CF_BUFSIZE,pp); while (!feof(pp)) { CfReadLine(vbuff,CF_BUFSIZE,pp); sscanf(vbuff,"%s",user); if (strcmp(user,"USER") == 0) { continue; } if (!IsItemIn(*userList,user)) { PrependItem(userList,user,NULL); (*userListSz)++; } if (strcmp(user,"root") == 0) { (*numRootProcs)++; } else { (*numOtherProcs)++; } } cf_pclose(pp); return true; } #endif cfengine-3.2.4/src/mod_interfaces.c0000644000175000017500000000466211715232734014151 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_interfaces.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*****************************************************************************/ #define CF3_MOD_INTEFACES struct BodySyntax CF_TCPIP_BODY[] = { {"ipv4_address",cf_str,"[0-9.]+/[0-4]+","IPv4 address for the interface"}, {"ipv4_netmask",cf_str,"[0-9.]+/[0-4]+","Netmask for the interface"}, {"ipv6_address",cf_str,"[0-9a-fA-F:]+/[0-9]+","IPv6 address for the interface"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the primary set of constraints for an interfaces object */ struct BodySyntax CF_INTERFACES_BODIES[] = { {"tcp_ip",cf_body,CF_TCPIP_BODY,"Interface tcp/ip properties"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_INTERFACES_SUBTYPES[] = { {"agent","interfaces",CF_INTERFACES_BODIES}, {NULL,NULL,NULL}, }; cfengine-3.2.4/src/iteration.c0000644000175000017500000001550511715232734013163 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: iteration.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void DeleteReferenceRlist(struct Rlist *list); /*****************************************************************************/ struct Rlist *NewIterationContext(char *scopeid,struct Rlist *namelist) { struct Rlist *this,*rp,*rps,*deref_listoflists = NULL; char rtype; void *returnval; enum cfdatatype dtype; struct Scope *ptr = NULL; struct CfAssoc *new; struct Rval newret; Debug("\n*\nNewIterationContext(from %s)\n*\n",scopeid); CopyScope("this",scopeid); ptr=GetScope("this"); if (namelist == NULL) { Debug("No lists to iterate over\n"); return NULL; } for (rp = namelist; rp != NULL; rp = rp->next) { dtype = GetVariable(scopeid,rp->item,&returnval,&rtype); if (dtype == cf_notype) { CfOut(cf_error,""," !! Couldn't locate variable %s apparently in %s\n",rp->item,scopeid); CfOut(cf_error,""," !! Could be incorrect use of a global iterator -- see reference manual on list substitution"); continue; } /* Make a copy of list references in scope only, without the names */ if (rtype == CF_LIST) { for (rps = (struct Rlist *)returnval; rps != NULL; rps=rps->next) { if (rps->type == CF_FNCALL) { struct FnCall *fp = (struct FnCall *)rps->item; newret = EvaluateFunctionCall(fp,NULL); DeleteFnCall(fp); rps->item = newret.item; rps->type = newret.rtype; } } } if ((new = NewAssoc(rp->item,returnval,rtype,dtype))) { this = OrthogAppendRlist(&deref_listoflists,new,CF_LIST); rp->state_ptr = new->rval; while (rp->state_ptr && strcmp(rp->state_ptr->item,CF_NULL_VALUE) == 0) { if (rp->state_ptr) { rp->state_ptr = rp->state_ptr->next; } } } } /* We now have a control list of list-variables, with internal state in state_ptr */ return deref_listoflists; } /*****************************************************************************/ void DeleteIterationContext(struct Rlist *deref) { DeleteScope("this"); if (deref != NULL) { DeleteReferenceRlist(deref); } } /*****************************************************************************/ int IncrementIterationContext(struct Rlist *iterator,int level) { struct Rlist *state; struct CfAssoc *cp; if (iterator == NULL) { return false; } // iterator->next points to the next list // iterator->state_ptr points to the current item in the current list cp = (struct CfAssoc *)iterator->item; state = iterator->state_ptr; if (state == NULL) { return false; } /* Go ahead and increment */ Debug(" -> Incrementing (%s) from \"%s\"\n", cp->lval, (char *)iterator->state_ptr->item); if (state->next == NULL) { /* This wheel has come to full revolution, so move to next */ if (iterator->next != NULL) { /* Increment next wheel */ if (IncrementIterationContext(iterator->next,level+1)) { /* Not at end yet, so reset this wheel */ iterator->state_ptr = cp->rval; iterator->state_ptr = iterator->state_ptr->next; return true; } else { /* Reached last variable wheel - pass up */ return false; } } else { /* Reached last variable wheel - waiting for end detection */ return false; } } else { /* Update the current wheel */ iterator->state_ptr = state->next; Debug(" <- Incrementing wheel (%s) to \"%s\"\n",cp->lval,iterator->state_ptr->item); while (iterator->state_ptr && strcmp(iterator->state_ptr->item,CF_NULL_VALUE) == 0) { if (IncrementIterationContext(iterator->next,level+1)) { /* Not at end yet, so reset this wheel (next because we always start with cf_null now) */ iterator->state_ptr = cp->rval; iterator->state_ptr = iterator->state_ptr->next; return true; } else { /* Reached last variable wheel - pass up */ break; } } if (EndOfIteration(iterator)) { return false; } return true; } } /*****************************************************************************/ int EndOfIteration(struct Rlist *iterator) { struct Rlist *rp,*state; if (iterator == NULL) { return true; } /* When all the wheels are at NULL, we have reached the end*/ for (rp = iterator; rp != NULL; rp = rp->next) { state = rp->state_ptr; if (state == NULL) { continue; } if (state && state->next != NULL) { return false; } } return true; } /*****************************************************************************/ int NullIterators(struct Rlist *iterator) { struct Rlist *rp,*state; if (iterator == NULL) { return false; } /* When all the wheels are at NULL, we have reached the end*/ for (rp = iterator; rp != NULL; rp = rp->next) { state = rp->state_ptr; if (state && strcmp(state->item,CF_NULL_VALUE) == 0) { return true; } } return false; } /*******************************************************************/ static void DeleteReferenceRlist(struct Rlist *list) /* Delete all contents, hash table in scope has own copy */ { if (list == NULL) { return; } DeleteAssoc((struct CfAssoc *)list->item); DeleteReferenceRlist(list->next); free((char *)list); } cfengine-3.2.4/src/conf.h.in0000644000175000017500000003733411715232774012534 00000000000000/* src/conf.h.in. Generated from configure.ac by autoheader. */ /* AIX build */ #undef AIX /* AOS build */ #undef AOS /* Special Cfengine symbol */ #undef AUTOCONF_HOSTNAME /* Speial Cfengine symbol */ #undef AUTOCONF_SYSNAME /* 4.3BSD build */ #undef BSD43 /* BSD/OS build */ #undef BSDOS /* Build Test suite */ #undef BUILD_TESTSUITE /* "Software build year" */ #undef BUILD_YEAR /* Cray build */ #undef CFCRAY /* Cygwin NT build */ #undef CFCYG /* GNU build */ #undef CFGNU /* QNX build */ #undef CFQNX /* Define if old Berkeley API */ #undef CF_OLD_DB /* Define to 1 if using `getloadavg.c'. */ #undef C_GETLOADAVG /* Darwin build */ #undef DARWIN /* Define to 1 for DGUX with . */ #undef DGUX /* FreeBSD build */ #undef FREEBSD /* Define to 1 if the `getloadavg' function needs to be run setuid or setgid. */ #undef GETLOADAVG_PRIVILEGED /* Define to 1 if you have the header file. */ #undef HAVE_ACL_H /* Define to 1 if you have the header file. */ #undef HAVE_ACL_LIBACL_H /* Define to 1 if you have the `bcopy' function. */ #undef HAVE_BCOPY /* Define to 1 if you have the `chflags' function. */ #undef HAVE_CHFLAGS /* Define to 1 if the system has the type `clockid_t'. */ #undef HAVE_CLOCKID_T /* Define to 1 if you have the `clock_gettime' function. */ #undef HAVE_CLOCK_GETTIME /* Define to 1 if you have the declaration of `clock_gettime', and to 0 if you don't. */ #undef HAVE_DECL_CLOCK_GETTIME /* Define to 1 if you have the declaration of `dirfd', and to 0 if you don't. */ #undef HAVE_DECL_DIRFD /* Define to 1 if you have the declaration of `nanosleep', and to 0 if you don't. */ #undef HAVE_DECL_NANOSLEEP /* Define to 1 if you have the declaration of `realpath', and to 0 if you don't. */ #undef HAVE_DECL_REALPATH /* Define to 1 if you have the declaration of `round', and to 0 if you don't. */ #undef HAVE_DECL_ROUND /* Define to 1 if you have the declaration of `setlinebuf', and to 0 if you don't. */ #undef HAVE_DECL_SETLINEBUF /* Define to 1 if you have the declaration of `strdup', and to 0 if you don't. */ #undef HAVE_DECL_STRDUP /* Define to 1 if you have the declaration of `strlcat', and to 0 if you don't. */ #undef HAVE_DECL_STRLCAT /* Define to 1 if you have the declaration of `strlcpy', and to 0 if you don't. */ #undef HAVE_DECL_STRLCPY /* Define to 1 if you have the declaration of `strndup', and to 0 if you don't. */ #undef HAVE_DECL_STRNDUP /* Define to 1 if you have the declaration of `strnlen', and to 0 if you don't. */ #undef HAVE_DECL_STRNLEN /* Define to 1 if you have the declaration of `unsetenv', and to 0 if you don't. */ #undef HAVE_DECL_UNSETENV /* Define to 1 if you have the header file. */ #undef HAVE_DEPOT_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H /* Define to 1 if you have the `dirfd' function. */ #undef HAVE_DIRFD /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the `door' function. */ #undef HAVE_DOOR /* Define to 1 if you have the `drand48' function. */ #undef HAVE_DRAND48 /* Define to 1 if you have the header file. */ #undef HAVE_DUSTAT_H /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the `fpathconf' function. */ #undef HAVE_FPATHCONF /* Define to 1 if you have the `getaddrinfo' function. */ #undef HAVE_GETADDRINFO /* Define to 1 if you have the `getcwd' function. */ #undef HAVE_GETCWD /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME /* Define to 1 if you have the `getloadavg' function. */ #undef HAVE_GETLOADAVG /* Define to 1 if you have the `getnetgrent' function. */ #undef HAVE_GETNETGRENT /* Define to 1 if you have the `getzoneid' function. */ #undef HAVE_GETZONEID /* Define to 1 if you have the `getzonenamebyid' function. */ #undef HAVE_GETZONENAMEBYID /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `jail_get' function. */ #undef HAVE_JAIL_GET /* Whether to use lchown(3) to change ownerships */ #undef HAVE_LCHOWN /* Define to 1 if you have the `acl' library (-lacl). */ #undef HAVE_LIBACL /* Define to 1 if you have the `crypto' library (-lcrypto). */ #undef HAVE_LIBCRYPTO /* Define to 1 if you have the `db' library (-ldb). */ #undef HAVE_LIBDB /* Define to 1 if you have the `dgc' library (-ldgc). */ #undef HAVE_LIBDGC /* Define to 1 if you have the `kstat' library (-lkstat). */ #undef HAVE_LIBKSTAT /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM /* Define to 1 if you have the `mysqlclient' library (-lmysqlclient). */ #undef HAVE_LIBMYSQLCLIENT /* Define to 1 if you have the `nsl' library (-lnsl). */ #undef HAVE_LIBNSL /* Define to 1 if you have the `nss_nis' library (-lnss_nis). */ #undef HAVE_LIBNSS_NIS /* Define to 1 if you have the `pcre' library (-lpcre). */ #undef HAVE_LIBPCRE /* Define to 1 if you have the `pq' library (-lpq). */ #undef HAVE_LIBPQ /* Define to 1 if you have the header file. */ #undef HAVE_LIBPQ_FE_H /* Define to 1 if you have the `pthread' library (-lpthread). */ #undef HAVE_LIBPTHREAD /* Define to 1 if you have the `pthreads' library (-lpthreads). */ #undef HAVE_LIBPTHREADS /* Define to 1 if you have the `PW' library (-lPW). */ #undef HAVE_LIBPW /* Define to 1 if you have the `qdbm' library (-lqdbm). */ #undef HAVE_LIBQDBM /* Define to 1 if you have the `rt' library (-lrt). */ #undef HAVE_LIBRT /* Define to 1 if you have the `socket' library (-lsocket). */ #undef HAVE_LIBSOCKET /* Define to 1 if you have the `sqlite3' library (-lsqlite3). */ #undef HAVE_LIBSQLITE3 /* Define to 1 if you have the `thread' library (-lthread). */ #undef HAVE_LIBTHREAD /* Define to 1 if you have the `tokyocabinet' library (-ltokyocabinet). */ #undef HAVE_LIBTOKYOCABINET /* Define to 1 if you have the header file. */ #undef HAVE_MACH_MACH_H /* Define to 1 if you have the header file. */ #undef HAVE_MALLOC_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `mkfifo' function. */ #undef HAVE_MKFIFO /* Define to 1 if you have the header file. */ #undef HAVE_MYSQL_H /* Define to 1 if you have the `nanosleep' function. */ #undef HAVE_NANOSLEEP /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_NLIST_H /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_OPENSSLV_H /* The old route entry structure in newer BSDs */ #undef HAVE_ORTENTRY /* Define to 1 if you have the header file. */ #undef HAVE_PCRE_H /* Define to 1 if you have the header file. */ #undef HAVE_PCRE_PCRE_H /* Define to 1 if you have the `pstat_getdynamic' function. */ #undef HAVE_PSTAT_GETDYNAMIC /* Define if you have POSIX threads libraries and header files. */ #undef HAVE_PTHREAD /* Whether the thread library has setstacksize */ #undef HAVE_PTHREAD_ATTR_SETSTACKSIZE /* Define to 1 if you have the header file. */ #undef HAVE_PTHREAD_H /* Whether the thread library has setmask */ #undef HAVE_PTHREAD_SIGMASK /* Define to 1 if you have the `putenv' function. */ #undef HAVE_PUTENV /* Define to 1 if you have the `realpath' function. */ #undef HAVE_REALPATH /* Define to 1 if you have the `round' function. */ #undef HAVE_ROUND /* Do we have any route entry structure? */ #undef HAVE_RTENTRY /* Define to 1 if you have the header file. */ #undef HAVE_SCHED_H /* Define to 1 if you have the `setegid' function. */ #undef HAVE_SETEGID /* Define to 1 if you have the `seteuid' function. */ #undef HAVE_SETEUID /* Define to 1 if you have the `setlinebuf' function. */ #undef HAVE_SETLINEBUF /* Define to 1 if you have the `setlocale' function. */ #undef HAVE_SETLOCALE /* Define to 1 if you have the `setregid' function. */ #undef HAVE_SETREGID /* Define to 1 if you have the `setreuid' function. */ #undef HAVE_SETREUID /* Define to 1 if you have the `setsid' function. */ #undef HAVE_SETSID /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF /* Define to 1 if you have the header file. */ #undef HAVE_SQLITE3_H /* Define to 1 if you have the `srand48' function. */ #undef HAVE_SRAND48 /* Define to 1 if you have the `statfs' function. */ #undef HAVE_STATFS /* Define to 1 if you have the `statvfs' function. */ #undef HAVE_STATVFS /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_H /* 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 `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strlcat' function. */ #undef HAVE_STRLCAT /* Define to 1 if you have the `strlcpy' function. */ #undef HAVE_STRLCPY /* Define to 1 if you have the `strndup' function. */ #undef HAVE_STRNDUP /* Define to 1 if you have the `strnlen' function. */ #undef HAVE_STRNLEN /* Define to 1 if you have the `strrchr' function. */ #undef HAVE_STRRCHR /* Define to 1 if you have the `strsep' function. */ #undef HAVE_STRSEP /* Define to 1 if you have the `strstr' function. */ #undef HAVE_STRSTR /* Define to 1 if `n_un.n_name' is a member of `struct nlist'. */ #undef HAVE_STRUCT_NLIST_N_UN_N_NAME /* Define to 1 if `sa_len' is a member of `struct sockaddr'. */ #undef HAVE_STRUCT_SOCKADDR_SA_LEN /* Define to 1 if you have the `sysconf' function. */ #undef HAVE_SYSCONF /* Define to 1 if you have the `sysinfo' function. */ #undef HAVE_SYSINFO /* Define to 1 if you have the header file. */ #undef HAVE_SYS_ACL_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_FILESYS_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_LOADAVG_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_MALLOC_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_MOUNT_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKIO_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STATFS_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STATVFS_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_SYSTEMINFO_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_SYS_UIO_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_VFS_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the header file. */ #undef HAVE_TCHDB_H /* Define to 1 if you have the header file. */ #undef HAVE_TCUTIL_H /* Define to 1 if you have the header file. */ #undef HAVE_THREAD_H /* Define to 1 if you have the header file. */ #undef HAVE_TIME_H /* Define to 1 if you have the `uname' function. */ #undef HAVE_UNAME /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `unsetenv' function. */ #undef HAVE_UNSETENV /* Define to 1 if you have the header file. */ #undef HAVE_UTIME_H /* Define to 1 if you have the header file. */ #undef HAVE_VFS_H /* Define to 1 if you have the `waitpid' function. */ #undef HAVE_WAITPID /* Define to 1 if you have the header file. */ #undef HAVE_WINSOCK2_H /* Define to 1 if you have the header file. */ #undef HAVE_ZONE_H /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* HP/UX build */ #undef HPuUX /* IRIX build */ #undef IRIX /* Linux build */ #undef LINUX /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Native NT build */ #undef MINGW /* NetBSD build */ #undef NETBSD /* NewsOS build */ #undef NEWS_OS /* NeXTSTEP build */ #undef NEXTSTEP /* Define to 1 if your `struct nlist' has an `n_un' member. Obsolete, depend on `HAVE_STRUCT_NLIST_N_UN_N_NAME */ #undef NLIST_NAME_UNION /* NT build */ #undef NT /* OpenBSD build */ #undef OPENBSD /* OSF/1 build */ #undef OSF /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to necessary symbol if this constant uses a non-standard name on your system. */ #undef PTHREAD_CREATE_JOINABLE /* Define if QDBM is available. */ #undef QDB /* Whether to use the local regex functions */ #undef REGEX_MALLOC /* SCO build */ #undef SCO /* Solaris build */ #undef SOLARIS /* Define if SQLite 3 is available. */ #undef SQLITE3 /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* SunOS 3.x build */ #undef SUN3 /* SunOS 4.x build */ #undef SUN4 /* Define to 1 on System V Release 4. */ #undef SVR4 /* Define if Tokyo Cabinet is available. */ #undef TCDB /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Ultrix build */ #undef ULTRIX /* Define to 1 for Encore UMAX. */ #undef UMAX /* Define to 1 for Encore UMAX 4.3 that has instead of . */ #undef UMAX4_3 /* Unixware build */ #undef UNIXWARE /* Define if BerkeleyDB is available. */ #undef USE_BERKELEYDB /* Version number of package */ #undef VERSION /* Define if you want to use SELinux */ #undef WITH_SELINUX /* lock and log directories */ #undef WORKDIR /* Define if XEN cpuid-based HVM detection is available. */ #undef XEN_CPUID_SUPPORT /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a `char[]'. */ #undef YYTEXT_POINTER /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES /* SVR4 header stuff */ #undef _POSIX_C_SOURCE /* Use POSIX pthread semantics on Solaris */ #undef _POSIX_PTHREAD_SEMANTICS /* Solaris 2.6-related stuff */ #undef __BIT_TYPES_DEFINED__ /* SVR4 header stuff */ #undef __EXTENSIONS__ /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `int' if doesn't define. */ #undef gid_t /* Define to `int' if does not define. */ #undef mode_t /* Define to `long int' if does not define. */ #undef off_t /* Define to `int' if does not define. */ #undef pid_t /* Define to `unsigned int' if does not define. */ #undef size_t /* Define to `int' if doesn't define. */ #undef uid_t cfengine-3.2.4/src/full-write.c0000644000175000017500000000353311715232734013255 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifdef HAVE_CONFIG_H # include #endif #include "cf.defs.h" #include /* Forward declaration copied from prototypes.h to avoid compile-time warning */ int cf_full_write (int desc, char *ptr, size_t len); #ifdef HAVE_UNISTD_H #include #endif #include #ifndef STDC_HEADERS extern int errno; #endif /* Write LEN bytes at PTR to descriptor DESC, retrying if interrupted. Return LEN upon success, write's (negative) error code otherwise. */ int cf_full_write (desc,ptr,len) int desc; char *ptr; size_t len; { int total_written; total_written = 0; while (len > 0) { int written = write(desc,ptr,len); if (written < 0) { if (errno == EINTR) { continue; } return written; } total_written += written; ptr += written; len -= written; } return total_written; } cfengine-3.2.4/src/mod_report.c0000644000175000017500000000566611715232734013346 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_report.c */ /* */ /*****************************************************************************/ #define CF3_MOD_REPORT #include "cf3.defs.h" #include "cf3.extern.h" struct BodySyntax CF_PRINTFILE_BODY[] = { {"file_to_print",cf_str,CF_ABSPATHRANGE,"Path name to the file that is to be sent to standard output"}, {"number_of_lines",cf_int,CF_VALRANGE,"Integer maximum number of lines to print from selected file"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the primary set of constraints for a file object */ struct BodySyntax CF_REPORT_BODIES[] = { {"friend_pattern",cf_str,"","Regular expression to keep selected hosts from the friends report list"}, {"intermittency",cf_real,"0,1","Real number threshold [0,1] of intermittency about current peers, report above"}, {"lastseen",cf_int,CF_VALRANGE,"Integer time threshold in hours since current peers were last seen, report absence"}, {"printfile",cf_body,CF_PRINTFILE_BODY,"Quote part of a file to standard output"}, {"report_to_file",cf_str,CF_ABSPATHRANGE,"The path and filename to which output should be appended"}, {"showstate",cf_slist,"","List of services about which status reports should be reported to standard output"}, {NULL,cf_notype,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_REPORT_SUBTYPES[] = { /* Body lists belonging to "reports:" type in Agent */ {"agent","reports",CF_REPORT_BODIES}, {NULL,NULL,NULL}, }; cfengine-3.2.4/src/cf3lex.c0000644000175000017500000015105211715233327012346 00000000000000 #line 3 "cf3lex.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 */ #define yywrap(n) 1 #define YY_SKIP_YYWRAP 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 14 #define YY_END_OF_BUFFER 15 /* 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[50] = { 0, 0, 0, 15, 13, 11, 1, 13, 13, 13, 12, 13, 13, 13, 4, 13, 4, 13, 4, 11, 1, 0, 0, 0, 9, 0, 12, 0, 0, 0, 0, 6, 4, 5, 8, 4, 0, 4, 4, 7, 0, 0, 4, 4, 10, 3, 4, 4, 2, 0 } ; static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 5, 6, 7, 8, 1, 5, 9, 10, 11, 1, 1, 1, 12, 13, 1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 1, 1, 16, 17, 1, 8, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 1, 19, 1, 1, 18, 20, 18, 21, 18, 22, 23, 18, 18, 18, 18, 18, 18, 24, 18, 25, 26, 18, 18, 18, 18, 18, 27, 18, 18, 18, 28, 18, 29, 5, 30, 1, 1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 } ; static yyconst flex_int32_t yy_meta[31] = { 0, 1, 1, 2, 1, 3, 1, 1, 1, 1, 3, 3, 1, 4, 4, 3, 1, 1, 4, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1 } ; static yyconst flex_int16_t yy_base[59] = { 0, 0, 0, 70, 142, 65, 142, 63, 50, 25, 0, 22, 24, 47, 47, 44, 58, 39, 69, 54, 142, 40, 39, 28, 142, 0, 0, 0, 0, 26, 0, 142, 93, 142, 38, 104, 30, 27, 23, 142, 35, 12, 13, 18, 142, 0, 15, 15, 0, 142, 117, 121, 125, 129, 131, 133, 137, 33, 32 } ; static yyconst flex_int16_t yy_def[59] = { 0, 49, 1, 49, 49, 49, 49, 49, 50, 51, 52, 49, 53, 49, 54, 49, 55, 56, 49, 49, 49, 50, 49, 51, 49, 51, 52, 57, 58, 53, 53, 49, 54, 49, 49, 55, 56, 35, 35, 49, 57, 58, 35, 35, 49, 35, 35, 35, 35, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49 } ; static yyconst flex_int16_t yy_nxt[173] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 8, 8, 13, 8, 14, 4, 15, 4, 16, 4, 17, 18, 16, 16, 16, 16, 16, 16, 16, 4, 4, 24, 27, 24, 24, 24, 41, 40, 48, 47, 46, 45, 44, 30, 25, 30, 44, 25, 43, 42, 24, 28, 21, 39, 39, 22, 19, 21, 21, 24, 21, 33, 22, 21, 31, 22, 20, 19, 21, 21, 49, 21, 32, 34, 21, 49, 49, 49, 49, 21, 21, 49, 21, 32, 34, 49, 49, 35, 49, 49, 35, 35, 35, 35, 35, 37, 38, 35, 21, 49, 49, 49, 49, 21, 21, 49, 21, 49, 22, 21, 49, 49, 49, 49, 21, 21, 49, 21, 32, 34, 21, 21, 23, 23, 23, 23, 26, 49, 26, 26, 29, 29, 29, 29, 32, 32, 35, 35, 36, 36, 36, 36, 3, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49 } ; static yyconst flex_int16_t yy_chk[173] = { 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, 9, 11, 12, 23, 29, 58, 57, 47, 46, 43, 42, 41, 12, 9, 29, 40, 23, 38, 37, 36, 11, 14, 34, 22, 21, 19, 14, 14, 17, 14, 15, 14, 16, 13, 8, 7, 5, 16, 16, 3, 16, 16, 16, 18, 0, 0, 0, 0, 18, 18, 0, 18, 18, 18, 0, 0, 18, 0, 0, 18, 18, 18, 18, 18, 18, 18, 18, 32, 0, 0, 0, 0, 32, 32, 0, 32, 0, 32, 35, 0, 0, 0, 0, 35, 35, 0, 35, 35, 35, 50, 50, 51, 51, 51, 51, 52, 0, 52, 52, 53, 53, 53, 53, 54, 54, 55, 55, 56, 56, 56, 56, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49 } ; 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 "cf3lex.l" #line 2 "cf3lex.l" /* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*******************************************************************/ /* */ /* LEXER for cfengine 3 */ /* */ /*******************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #include "cf3parse.h" // Do not use lex - flex only /* * Three types of quoted strings: * * - string in double quotes, starts with double quote, runs until another * double quote, \" masks the double quote. * - string in single quotes, starts with single quote, runs until another * single quote, \' masks the single quote. * - string in backquotes, starts with backquote, runs until another backquote. * * The same rule formatted for the better readability: * * := \" \" | \' \' | ` ` * = * * = \\ | [^"\\] * = * * = \\ | [^'\\] * = * * = [^`] * = . | \n * */ #line 571 "cf3lex.c" #define INITIAL 0 #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 static void yyunput (int c,char *buf_ptr ); #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 /* 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 87 "cf3lex.l" #line 761 "cf3lex.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 >= 50 ) 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] != 142 ); 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: /* rule 1 can match eol */ YY_RULE_SETUP #line 89 "cf3lex.l" { P.line_no++; P.line_pos = 0; } YY_BREAK case 2: YY_RULE_SETUP #line 94 "cf3lex.l" { /* Note this has to come before "id" since it is a subset of id */ if (P.currentclasses != NULL) { free(P.currentclasses); P.currentclasses = NULL; } P.line_pos += strlen(yytext); return BUNDLE; } YY_BREAK case 3: YY_RULE_SETUP #line 106 "cf3lex.l" { /* Note this has to come before "id" since it is a subset of id */ if (P.currentclasses != NULL) { free(P.currentclasses); P.currentclasses = NULL; } P.line_pos += strlen(yytext); return BODY; } YY_BREAK case 4: YY_RULE_SETUP #line 118 "cf3lex.l" { P.line_pos += strlen(yytext); if (strlen(yytext) > CF_MAXVARSIZE-1) { yyerror("identifier too long"); } strncpy(P.currentid,yytext,CF_MAXVARSIZE); return ID; } YY_BREAK case 5: YY_RULE_SETUP #line 129 "cf3lex.l" { P.line_pos += strlen(yytext); return ASSIGN; } YY_BREAK case 6: YY_RULE_SETUP #line 134 "cf3lex.l" { P.line_pos += strlen(yytext); return ARROW; } YY_BREAK case 7: YY_RULE_SETUP #line 139 "cf3lex.l" { P.line_pos += strlen(yytext); if (P.currentclasses != NULL) { free(P.currentclasses); } yytext[strlen(yytext)-2] = '\0'; ValidateClassSyntax(yytext); P.currentclasses = strdup(yytext); return CLASS; } YY_BREAK case 8: YY_RULE_SETUP #line 153 "cf3lex.l" { P.line_pos += strlen(yytext); yytext[strlen(yytext)-1] = '\0'; strncpy(P.currenttype,yytext,CF_MAXVARSIZE); if (P.currentclasses != NULL) { free(P.currentclasses); P.currentclasses = NULL; } return CATEGORY; } YY_BREAK case 9: /* rule 9 can match eol */ YY_RULE_SETUP #line 167 "cf3lex.l" { char *tmp = NULL; int less = 0; P.line_pos += strlen(yytext); if ((tmp = malloc(strlen(yytext)+1)) == NULL) { FatalError("Malloc failure in parsing"); } if ((less = DeEscapeQuotedString(yytext,tmp)) > 0) { yyless(less); } if (P.currentstring) { free(P.currentstring); } P.currentstring = strdup(tmp); if (THIS_AGENT_TYPE == cf_common) { IsCf3VarString(tmp); } free(tmp); return QSTRING; } YY_BREAK case 10: YY_RULE_SETUP #line 200 "cf3lex.l" { P.line_pos += strlen(yytext); P.currentstring = strdup(yytext); return NAKEDVAR; } YY_BREAK case 11: YY_RULE_SETUP #line 207 "cf3lex.l" { P.line_pos += strlen(yytext); } YY_BREAK case 12: YY_RULE_SETUP #line 211 "cf3lex.l" { } YY_BREAK case 13: YY_RULE_SETUP #line 215 "cf3lex.l" { P.line_pos++; return yytext[0]; } YY_BREAK case 14: YY_RULE_SETUP #line 221 "cf3lex.l" ECHO; YY_BREAK #line 1017 "cf3lex.c" case YY_STATE_EOF(INITIAL): yyterminate(); 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 >= 50 ) 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 >= 50 ) 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 == 49); return yy_is_jam ? 0 : yy_current_state; } static void yyunput (int c, register char * yy_bp ) { register char *yy_cp; yy_cp = (yy_c_buf_p); /* undo effects of setting up yytext */ *yy_cp = (yy_hold_char); if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ register int number_to_move = (yy_n_chars) + 2; register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; register char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; (yytext_ptr) = yy_bp; (yy_hold_char) = *yy_cp; (yy_c_buf_p) = yy_cp; } #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; } #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; /* 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; /* 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 221 "cf3lex.l" /* EOF */ cfengine-3.2.4/src/monitor.c0000644000175000017500000001564511715232734012661 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: monitor.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*****************************************************************************/ /* Globals */ /*****************************************************************************/ extern int NO_FORK; extern struct BodySyntax CFM_CONTROLBODY[]; /*******************************************************************/ /* Command line options */ /*******************************************************************/ const char *ID = "The monitoring agent is a machine-learning, sampling\n" "daemon which learns the normal state of the current\n" "host and classifies new observations in terms of the\n" "patterns formed by previous ones. The data are made\n" "available to and read by cf-agent for classification\n" "of responses to anomalous states."; const struct option OPTIONS[14] = { { "help",no_argument,0,'h' }, { "debug",optional_argument,0,'d' }, { "verbose",no_argument,0,'v' }, { "dry-run",no_argument,0,'n'}, { "version",no_argument,0,'V' }, { "no-lock",no_argument,0,'K'}, { "file",required_argument,0,'f'}, { "inform",no_argument,0,'I'}, { "diagnostic",no_argument,0,'x'}, { "no-fork",no_argument,0,'F'}, { "histograms",no_argument,0,'H'}, { "tcpdump",no_argument,0,'T'}, { NULL,0,0,'\0' } }; const char *HINTS[14] = { "Print the help message", "Set debugging level 0,1,2,3", "Output verbose information about the behaviour of the agent", "All talk and no action mode - make no changes, only inform of promises not kept", "Output the version of the software", "Ignore system lock", "Specify an alternative input file than the default", "Print basic information about changes made to the system, i.e. promises repaired", "Activate internal diagnostics (developers only)", "Run process in foreground, not as a daemon", "Ignored for backward compatibility", "Interface with tcpdump if available to collect data about network", NULL }; /*****************************************************************************/ int main(int argc,char *argv[]) { CheckOpts(argc,argv); GenericInitialize(argc,argv,"monitor"); ThisAgentInit(); KeepPromises(); StartServer(argc,argv); return 0; } /*******************************************************************/ void CheckOpts(int argc,char **argv) { extern char *optarg; int optindex = 0; int c; while ((c=getopt_long(argc,argv,"d:vnIf:VSxHTKMF",OPTIONS,&optindex)) != EOF) { switch ((char) c) { case 'f': strncpy(VINPUTFILE,optarg,CF_BUFSIZE-1); VINPUTFILE[CF_BUFSIZE-1] = '\0'; MINUSF = true; break; case 'd': NewClass("opt_debug"); switch ((optarg==NULL) ? '3' : *optarg) { case '1': D1 = true; DEBUG = true; break; case '2': D2 = true; DEBUG = true; break; default: DEBUG = true; break; } NO_FORK = true; break; case 'K': IGNORELOCK = true; break; case 'I': INFORM = true; break; case 'v': VERBOSE = true; NO_FORK = true; break; case 'F': NO_FORK = true; break; case 'H': /* Keep accepting this option for compatibility -- no longer used */ break; case 'T': MonNetworkSnifferEnable(true); break; case 'V': PrintVersionBanner("cf-monitord"); exit(0); case 'h': Syntax("cf-monitord - cfengine's monitoring agent",OPTIONS,HINTS,ID); exit(0); case 'M': ManPage("cf-monitord - cfengine's monitoring agent",OPTIONS,HINTS,ID); exit(0); case 'x': SelfDiagnostic(); exit(0); default: Syntax("cf-monitord - cfengine's monitoring agent",OPTIONS,HINTS,ID); exit(1); } } Debug("Set debugging\n"); } /*****************************************************************************/ void KeepPromises(void) { struct Constraint *cp; char rettype; void *retval; for (cp = ControlBodyConstraints(cf_monitor); cp != NULL; cp=cp->next) { if (IsExcluded(cp->classes)) { continue; } if (GetVariable("control_monitor",cp->lval,&retval,&rettype) == cf_notype) { CfOut(cf_error,"","Unknown lval %s in monitor control body",cp->lval); continue; } if (strcmp(cp->lval,CFM_CONTROLBODY[cfm_histograms].lval) == 0) { /* Keep accepting this option for backward compatibility. */ } if (strcmp(cp->lval,CFM_CONTROLBODY[cfm_tcpdump].lval) == 0) { MonNetworkSnifferEnable(GetBoolean(retval)); } if (strcmp(cp->lval,CFM_CONTROLBODY[cfm_forgetrate].lval) == 0) { sscanf(retval,"%lf",&FORGETRATE); Debug("forget rate = %f\n",FORGETRATE); } } } /*****************************************************************************/ /* Level 1 */ /*****************************************************************************/ void ThisAgentInit(void) { umask(077); sprintf(VPREFIX, "cf-monitord"); LOGGING = true; /* Do output to syslog */ SetReferenceTime(false); SetStartTime(false); signal(SIGINT,HandleSignals); signal(SIGTERM,HandleSignals); signal(SIGHUP,SIG_IGN); signal(SIGPIPE,SIG_IGN); signal(SIGCHLD,SIG_IGN); signal(SIGUSR1,HandleSignals); signal(SIGUSR2,HandleSignals); FORGETRATE = 0.6; MonInitialize(); } cfengine-3.2.4/src/agent.c0000644000175000017500000010451411715232734012262 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: agent.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*******************************************************************/ /* Agent specific variables */ /*******************************************************************/ enum typesequence { kp_vars, kp_classes, kp_outputs, kp_interfaces, kp_files, kp_packages, kp_environments, kp_methods, kp_processes, kp_services, kp_commands, kp_storage, kp_databases, kp_reports, kp_none }; char *TYPESEQUENCE[] = { "vars", "classes", /* Maelstrom order 2 */ "outputs", "interfaces", "files", "packages", "environments", "methods", "processes", "services", "commands", "storage", "databases", "reports", NULL }; int main (int argc,char *argv[]); void CheckAgentAccess(struct Rlist *list); void KeepAgentPromise(struct Promise *pp); int NewTypeContext(enum typesequence type); void DeleteTypeContext(enum typesequence type); void ClassBanner(enum typesequence type); void ParallelFindAndVerifyFilesPromises(struct Promise *pp); static bool VerifyBootstrap(void); extern struct BodySyntax CFA_CONTROLBODY[]; extern struct Rlist *SERVERLIST; /*******************************************************************/ /* Command line options */ /*******************************************************************/ const char *ID = "The main Cfengine agent is the instigator of change\n" "in the system. In that sense it is the most important\n" "part of the Cfengine suite.\n"; const struct option OPTIONS[15] = { { "bootstrap",no_argument,0,'B' }, { "bundlesequence",required_argument,0,'b' }, { "debug",optional_argument,0,'d' }, { "define",required_argument,0,'D' }, { "diagnostic",optional_argument,0,'x'}, { "dry-run",no_argument,0,'n'}, { "file",required_argument,0,'f'}, { "help",no_argument,0,'h' }, { "inform",no_argument,0,'I'}, { "negate",required_argument,0,'N' }, { "no-lock",no_argument,0,'K'}, { "policy-server",required_argument,0,'s' }, { "verbose",no_argument,0,'v' }, { "version",no_argument,0,'V' }, { NULL,0,0,'\0' } }; const char *HINTS[15] = { "Bootstrap/repair a cfengine configuration from failsafe file in the WORKDIR else in current directory", "Set or override bundlesequence from command line", "Set debugging level 0,1,2", "Define a list of comma separated classes to be defined at the start of execution", "Do internal diagnostic (developers only) level in optional argument", "All talk and no action mode - make no changes, only inform of promises not kept", "Specify an alternative input file than the default", "Print the help message", "Print basic information about changes made to the system, i.e. promises repaired", "Define a list of comma separated classes to be undefined at the start of execution", "Ignore locking constraints during execution (ifelapsed/expireafter) if \"too soon\" to run", "Define the server name or IP address of the a policy server (for use with bootstrap)", "Output verbose information about the behaviour of the agent", "Output the version of the software", NULL }; /*******************************************************************/ int main(int argc,char *argv[]) { int ret = 0; CheckOpts(argc,argv); GenericInitialize(argc,argv,"agent"); ThisAgentInit(); KeepPromises(); NoteClassUsage(VHEAP); #ifdef HAVE_NOVA Nova_NoteVarUsageDB(); #endif PurgeLocks(); if(BOOTSTRAP && !VerifyBootstrap()) { ret = 1; } GenericDeInitialize(); return ret; } /*******************************************************************/ /* Level 1 */ /*******************************************************************/ void CheckOpts(int argc,char **argv) { extern char *optarg; char arg[CF_BUFSIZE],*sp; int optindex = 0; int c,alpha = false,v6 = false; /* Because of the MacOS linker we have to call this from each agent individually before Generic Initialize */ POLICY_SERVER[0] = '\0'; while ((c=getopt_long(argc,argv,"rd:vnKIf:D:N:Vs:x:MBb:",OPTIONS,&optindex)) != EOF) { switch ((char) c) { case 'f': if (optarg == NULL) { FatalError(" -f used but no argument"); } if (optarg && strlen(optarg) < 5) { snprintf(arg,CF_MAXVARSIZE," -f used but argument \"%s\" incorrect",optarg); FatalError(arg); } strncpy(VINPUTFILE,optarg,CF_BUFSIZE-1); MINUSF = true; break; case 'b': if (optarg) { CBUNDLESEQUENCE = SplitStringAsRList(optarg,','); CBUNDLESEQUENCE_STR = optarg; } break; case 'd': NewClass("opt_debug"); switch ((optarg==NULL) ? '3' : *optarg) { case '1': D1 = true; DEBUG = true; break; case '2': D2 = true; DEBUG = true; break; default: DEBUG = true; break; } break; case 'B': BOOTSTRAP = true; MINUSF = true; IGNORELOCK = true; NewClass("bootstrap_mode"); break; case 's': // temporary assure that network functions are working OpenNetwork(); strncpy(POLICY_SERVER,Hostname2IPString(optarg),CF_BUFSIZE-1); CloseNetwork(); for (sp = POLICY_SERVER; *sp != '\0'; sp++) { if (isalpha(*sp)) { alpha = true; } if (ispunct(*sp) && *sp != ':' && *sp != '.') { alpha = true; } if (*sp == ':') { v6 = true; } } if (alpha && !v6) { FatalError("Error specifying policy server. The policy server's IP address could not be looked up. Please use the IP address instead if there is no error."); } break; case 'K': IGNORELOCK = true; break; case 'D': NewClassesFromString(optarg); break; case 'N': NegateClassesFromString(optarg,&VNEGHEAP); break; case 'I': INFORM = true; break; case 'v': VERBOSE = true; break; case 'n': DONTDO = true; IGNORELOCK = true; NewClass("opt_dry_run"); break; case 'V': PrintVersionBanner("cf-agent"); exit(0); case 'h': Syntax("cf-agent - cfengine's change agent",OPTIONS,HINTS,ID); exit(0); case 'M': ManPage("cf-agent - cfengine's change agent",OPTIONS,HINTS,ID); exit(0); case 'x': AgentDiagnostic(optarg); exit(0); case 'r': SHOWREPORTS = true; break; default: Syntax("cf-agent - cfengine's change agent",OPTIONS,HINTS,ID); exit(1); } } if (argv[optind] != NULL) { CfOut(cf_error,"","Unexpected argument with no preceding option: %s\n",argv[optind]); FatalError("Aborted"); } Debug("Set debugging\n"); } /*******************************************************************/ void ThisAgentInit() { FILE *fp; char filename[CF_BUFSIZE]; #ifdef HAVE_SETSID CfOut(cf_verbose,""," -> Immunizing against parental death"); setsid(); #endif signal(SIGINT,HandleSignals); signal(SIGTERM,HandleSignals); signal(SIGHUP,SIG_IGN); signal(SIGPIPE,SIG_IGN); signal(SIGUSR1,HandleSignals); signal(SIGUSR2,HandleSignals); CFA_MAXTHREADS = 30; EDITFILESIZE = 100000; /* do not set signal(SIGCHLD,SIG_IGN) in agent near popen() - or else pclose will fail to return status which we need for setting returns */ snprintf(filename,CF_BUFSIZE,"%s/cfagent.%s.log",CFWORKDIR,VSYSNAME.nodename); MapName(filename); if ((fp = fopen(filename,"a")) != NULL) { fclose(fp); } } /*******************************************************************/ void KeepPromises() { double efficiency; BeginAudit(); KeepControlPromises(); KeepPromiseBundles(); EndAudit(); // TOPICS counts the number of currently defined promises // OCCUR counts the number of objects touched while verifying config efficiency = 100.0*CF_OCCUR/(double)(CF_OCCUR+CF_TOPICS); NoteEfficiency(efficiency); CfOut(cf_verbose,""," -> Checked %d objects with %d promises, efficiency %.2lf",CF_OCCUR,CF_TOPICS,efficiency); } /*******************************************************************/ /* Level 2 */ /*******************************************************************/ void KeepControlPromises() { struct Constraint *cp; char rettype; void *retval; struct Rlist *rp; for (cp = ControlBodyConstraints(cf_agent); cp != NULL; cp=cp->next) { if (IsExcluded(cp->classes)) { continue; } if (GetVariable("control_common",cp->lval,&retval,&rettype) != cf_notype) { /* Already handled in generic_agent */ continue; } if (GetVariable("control_agent",cp->lval,&retval,&rettype) == cf_notype) { CfOut(cf_error,"","Unknown lval %s in agent control body",cp->lval); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_maxconnections].lval) == 0) { CFA_MAXTHREADS = (int)Str2Int(retval); CfOut(cf_verbose,"","SET maxconnections = %d\n",CFA_MAXTHREADS); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_checksum_alert_time].lval) == 0) { CF_PERSISTENCE = (int)Str2Int(retval); CfOut(cf_verbose,"","SET checksum_alert_time = %d\n",CF_PERSISTENCE); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_agentfacility].lval) == 0) { SetFacility(retval); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_agentaccess].lval) == 0) { ACCESSLIST = (struct Rlist *) retval; CheckAgentAccess(ACCESSLIST); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_refresh_processes].lval) == 0) { struct Rlist *rp; if (VERBOSE) { printf("%s> SET refresh_processes when starting: ",VPREFIX); for (rp = (struct Rlist *) retval; rp != NULL; rp = rp->next) { printf(" %s",(char *)rp->item); PrependItem(&PROCESSREFRESH,rp->item,NULL); } printf("\n"); } continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_abortclasses].lval) == 0) { struct Rlist *rp; CfOut(cf_verbose,"","SET Abort classes from ...\n"); for (rp = (struct Rlist *) retval; rp != NULL; rp = rp->next) { char name[CF_MAXVARSIZE] = ""; strncpy(name, rp->item, CF_MAXVARSIZE - 1); CanonifyNameInPlace(name); if (!IsItemIn(ABORTHEAP,name)) { AppendItem(&ABORTHEAP,name,cp->classes); } } continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_abortbundleclasses].lval) == 0) { struct Rlist *rp; CfOut(cf_verbose,"","SET Abort bundle classes from ...\n"); for (rp = (struct Rlist *) retval; rp != NULL; rp = rp->next) { char name[CF_MAXVARSIZE] = ""; strncpy(name, rp->item, CF_MAXVARSIZE - 1); CanonifyNameInPlace(name); if (!IsItemIn(ABORTBUNDLEHEAP,name)) { AppendItem(&ABORTBUNDLEHEAP,name,cp->classes); } } continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_addclasses].lval) == 0) { struct Rlist *rp; CfOut(cf_verbose,"","-> Add classes ...\n"); for (rp = (struct Rlist *) retval; rp != NULL; rp = rp->next) { CfOut(cf_verbose,""," -> ... %s\n",rp->item); NewClass(rp->item); } continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_auditing].lval) == 0) { AUDIT = GetBoolean(retval); CfOut(cf_verbose,"","SET auditing = %d\n",AUDIT); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_alwaysvalidate].lval) == 0) { ALWAYS_VALIDATE = GetBoolean(retval); CfOut(cf_verbose,"","SET alwaysvalidate = %d\n",ALWAYS_VALIDATE); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_secureinput].lval) == 0) { CFPARANOID = GetBoolean(retval); CfOut(cf_verbose,"","SET secure input = %d\n",CFPARANOID); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_binarypaddingchar].lval) == 0) { PADCHAR = *(char *)retval; CfOut(cf_verbose,"","SET binarypaddingchar = %c\n",PADCHAR); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_bindtointerface].lval) == 0) { strncpy(BINDINTERFACE,retval,CF_BUFSIZE-1); CfOut(cf_verbose,"","SET bindtointerface = %s\n",BINDINTERFACE); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_hashupdates].lval) == 0) { CHECKSUMUPDATES = GetBoolean(retval); CfOut(cf_verbose,"","SET ChecksumUpdates %d\n",CHECKSUMUPDATES); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_exclamation].lval) == 0) { EXCLAIM = GetBoolean(retval); CfOut(cf_verbose,"","SET exclamation %d\n",EXCLAIM); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_childlibpath].lval) == 0) { char output[CF_BUFSIZE]; snprintf(output,CF_BUFSIZE,"LD_LIBRARY_PATH=%s",(char *)retval); if (putenv(strdup(output)) == 0) { CfOut(cf_verbose,"","Setting %s\n",output); } continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_defaultcopytype].lval) == 0) { DEFAULT_COPYTYPE = (char *)retval; CfOut(cf_verbose,"","SET defaultcopytype = %c\n",DEFAULT_COPYTYPE); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_fsinglecopy].lval) == 0) { SINGLE_COPY_LIST = (struct Rlist *)retval; CfOut(cf_verbose,"","SET file single copy list\n"); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_fautodefine].lval) == 0) { AUTO_DEFINE_LIST = (struct Rlist *)retval; CfOut(cf_verbose,"","SET file auto define list\n"); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_dryrun].lval) == 0) { DONTDO = GetBoolean(retval); CfOut(cf_verbose,"","SET dryrun = %c\n",DONTDO); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_inform].lval) == 0) { INFORM = GetBoolean(retval); CfOut(cf_verbose,"","SET inform = %c\n",INFORM); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_verbose].lval) == 0) { VERBOSE = GetBoolean(retval); CfOut(cf_verbose,"","SET inform = %c\n",VERBOSE); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_repository].lval) == 0) { VREPOSITORY = strdup(retval); CfOut(cf_verbose,"","SET repository = %s\n",VREPOSITORY); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_skipidentify].lval) == 0) { SKIPIDENTIFY = GetBoolean(retval); CfOut(cf_verbose,"","SET skipidentify = %d\n",SKIPIDENTIFY); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_suspiciousnames].lval) == 0) { for (rp = (struct Rlist *) retval; rp != NULL; rp = rp->next) { PrependItem(&SUSPICIOUSLIST,rp->item,NULL); CfOut(cf_verbose,"", "-> Concidering %s as suspicious file", rp->item); } continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_repchar].lval) == 0) { REPOSCHAR = *(char *)retval; CfOut(cf_verbose,"","SET repchar = %c\n",REPOSCHAR); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_mountfilesystems].lval) == 0) { CF_MOUNTALL = GetBoolean(retval); CfOut(cf_verbose,"","SET mountfilesystems = %d\n",CF_MOUNTALL); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_editfilesize].lval) == 0) { EDITFILESIZE = Str2Int(retval); CfOut(cf_verbose,"","SET EDITFILESIZE = %d\n",EDITFILESIZE); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_ifelapsed].lval) == 0) { VIFELAPSED = Str2Int(retval); CfOut(cf_verbose,"","SET ifelapsed = %d\n",VIFELAPSED); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_expireafter].lval) == 0) { VEXPIREAFTER = Str2Int(retval); CfOut(cf_verbose,"","SET ifelapsed = %d\n",VEXPIREAFTER); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_timeout].lval) == 0) { CONNTIMEOUT = Str2Int(retval); CfOut(cf_verbose,"","SET timeout = %d\n",CONNTIMEOUT); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_max_children].lval) == 0) { CFA_BACKGROUND_LIMIT = Str2Int(retval); CfOut(cf_verbose,"","SET MAX_CHILDREN = %d\n",CFA_BACKGROUND_LIMIT); if (CFA_BACKGROUND_LIMIT > 10) { CfOut(cf_error,"","Silly value for max_children in agent control promise (%d > 10)",CFA_BACKGROUND_LIMIT); CFA_BACKGROUND_LIMIT = 1; } continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_syslog].lval) == 0) { LOGGING = GetBoolean(retval); CfOut(cf_verbose,"","SET syslog = %d\n",LOGGING); continue; } if (strcmp(cp->lval,CFA_CONTROLBODY[cfa_environment].lval) == 0) { struct Rlist *rp; CfOut(cf_verbose,"","SET environment variables from ...\n"); for (rp = (struct Rlist *) retval; rp != NULL; rp = rp->next) { if (putenv(rp->item) != 0) { CfOut(cf_error, "putenv", "Failed to set environment variable %s", rp->item); } } continue; } } if (GetVariable("control_common",CFG_CONTROLBODY[cfg_lastseenexpireafter].lval,&retval,&rettype) != cf_notype) { LASTSEENEXPIREAFTER = Str2Int(retval); } if (GetVariable("control_common",CFG_CONTROLBODY[cfg_fips_mode].lval,&retval,&rettype) != cf_notype) { FIPS_MODE = GetBoolean(retval); CfOut(cf_verbose,"","SET FIPS_MODE = %d\n",FIPS_MODE); } if (GetVariable("control_common",CFG_CONTROLBODY[cfg_syslog_port].lval,&retval,&rettype) != cf_notype) { SYSLOGPORT = (unsigned short)Str2Int(retval); CfOut(cf_verbose,"","SET syslog_port to %d",SYSLOGPORT); } if (GetVariable("control_common",CFG_CONTROLBODY[cfg_syslog_host].lval,&retval,&rettype) != cf_notype) { strncpy(SYSLOGHOST,Hostname2IPString(retval),CF_MAXVARSIZE-1); CfOut(cf_verbose,"","SET syslog_host to %s",SYSLOGHOST); } #ifdef HAVE_NOVA Nova_Initialize(); #endif } /*********************************************************************/ void KeepPromiseBundles() { struct Bundle *bp; struct Rlist *rp,*params; struct FnCall *fp; char rettype,*name; void *retval; int ok = true; if (CBUNDLESEQUENCE) { CfOut(cf_inform,""," >> Using command line specified bundlesequence"); retval = CBUNDLESEQUENCE; rettype = CF_LIST; } else if (GetVariable("control_common","bundlesequence",&retval,&rettype) == cf_notype) { CfOut(cf_error,""," !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); CfOut(cf_error,""," !! No bundlesequence in the common control body"); CfOut(cf_error,""," !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); exit(1); } if (rettype != CF_LIST) { FatalError("Promised bundlesequence was not a list"); } for (rp = (struct Rlist *)retval; rp != NULL; rp=rp->next) { switch (rp->type) { case CF_SCALAR: name = (char *)rp->item; params = NULL; if (strcmp(name,CF_NULL_VALUE) == 0) { continue; } break; case CF_FNCALL: fp = (struct FnCall *)rp->item; name = (char *)fp->name; params = (struct Rlist *)fp->args; break; default: name = NULL; params = NULL; CfOut(cf_error,"","Illegal item found in bundlesequence: "); ShowRval(stdout,rp->item,rp->type); printf(" = %c\n",rp->type); ok = false; break; } if (!IGNORE_MISSING_BUNDLES) { if (!(GetBundle(name,"agent")||(GetBundle(name,"common")))) { CfOut(cf_error,"","Bundle \"%s\" listed in the bundlesequence was not found\n",name); ok = false; } } } if (!ok) { FatalError("Errors in agent bundles"); } if (VERBOSE || DEBUG) { printf("%s> -> Bundlesequence => ",VPREFIX); ShowRval(stdout,retval,rettype); printf("\n"); } /* If all is okay, go ahead and evaluate */ for (rp = (struct Rlist *)retval; rp != NULL; rp=rp->next) { switch (rp->type) { case CF_FNCALL: fp = (struct FnCall *)rp->item; name = (char *)fp->name; params = (struct Rlist *)fp->args; break; default: name = (char *)rp->item; params = NULL; break; } if ((bp = GetBundle(name,"agent")) || (bp = GetBundle(name,"common"))) { SetBundleOutputs(bp->name); AugmentScope(bp->name,bp->args,params); BannerBundle(bp,params); THIS_BUNDLE = bp->name; DeletePrivateClassContext(); // Each time we change bundle ScheduleAgentOperations(bp); ResetBundleOutputs(bp->name); } } } /*********************************************************************/ /* Level 3 */ /*********************************************************************/ int ScheduleAgentOperations(struct Bundle *bp) { struct SubType *sp; struct Promise *pp; enum typesequence type; int pass; if (PROCESSREFRESH == NULL || (PROCESSREFRESH && IsRegexItemIn(PROCESSREFRESH,bp->name))) { DeleteItemList(PROCESSTABLE); PROCESSTABLE = NULL; } for (pass = 1; pass < CF_DONEPASSES; pass++) { for (type = 0; TYPESEQUENCE[type] != NULL; type++) { ClassBanner(type); if ((sp = GetSubTypeForBundle(TYPESEQUENCE[type],bp)) == NULL) { continue; } BannerSubType(bp->name,sp->name,pass); SetScope(bp->name); if (!NewTypeContext(type)) { continue; } for (pp = sp->promiselist; pp != NULL; pp=pp->next) { SaveClassEnvironment(); ExpandPromise(cf_agent,bp->name,pp,KeepAgentPromise); if (Abort()) { NoteClassUsage(VADDCLASSES); DeleteTypeContext(type); return false; } } DeleteTypeContext(type); } } NoteClassUsage(VADDCLASSES); return true; } /*********************************************************************/ void CheckAgentAccess(struct Rlist *list) #ifdef MINGW { } #else /* NOT MINGW */ { struct Rlist *rp,*rp2; struct stat sb; uid_t uid; int access = false; uid = getuid(); for (rp = list; rp != NULL; rp = rp->next) { if (Str2Uid(rp->item,NULL,NULL) == uid) { return; } } if (VINPUTLIST != NULL) { for (rp = VINPUTLIST; rp != NULL; rp=rp->next) { cfstat(rp->item,&sb); if (ACCESSLIST) { for (rp2 = ACCESSLIST; rp2 != NULL; rp2 = rp2->next) { if (Str2Uid(rp2->item,NULL,NULL) == sb.st_uid) { access = true; break; } } if (!access) { CfOut(cf_error,"","File %s is not owned by an authorized user (security exception)",rp->item); exit(1); } } else if (CFPARANOID && IsPrivileged()) { if (sb.st_uid != getuid()) { CfOut(cf_error,"","File %s is not owned by uid %d (security exception)",rp->item,getuid()); exit(1); } } } } FatalError("You are denied access to run this policy"); } #endif /* NOT MINGW */ /*********************************************************************/ void KeepAgentPromise(struct Promise *pp) { char *sp = NULL; struct timespec start = BeginMeasure(); if (!IsDefinedClass(pp->classes)) { CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,"",". . . . . . . . . . . . . . . . . . . . . . . . . . . . \n"); CfOut(cf_verbose,"","Skipping whole next promise (%s), as context %s is not relevant\n",pp->promiser,pp->classes); CfOut(cf_verbose,"",". . . . . . . . . . . . . . . . . . . . . . . . . . . . \n"); return; } if (pp->done) { return; } if (VarClassExcluded(pp,&sp)) { CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,"",". . . . . . . . . . . . . . . . . . . . . . . . . . . . \n"); CfOut(cf_verbose,"","Skipping whole next promise (%s), as var-context %s is not relevant\n",pp->promiser,sp); CfOut(cf_verbose,"",". . . . . . . . . . . . . . . . . . . . . . . . . . . . \n"); return; } // Record promises examined for efficiency calc CF_TOPICS++; if (strcmp("vars",pp->agentsubtype) == 0) { ConvergeVarHashPromise(pp->bundle,pp,true); return; } if (strcmp("classes",pp->agentsubtype) == 0) { KeepClassContextPromise(pp); return; } if (strcmp("outputs",pp->agentsubtype) == 0) { VerifyOutputsPromise(pp); return; } SetPromiseOutputs(pp); if (strcmp("interfaces",pp->agentsubtype) == 0) { VerifyInterfacesPromise(pp); return; } if (strcmp("processes",pp->agentsubtype) == 0) { VerifyProcessesPromise(pp); return; } if (strcmp("storage",pp->agentsubtype) == 0) { FindAndVerifyStoragePromises(pp); EndMeasurePromise(start,pp); return; } if (strcmp("packages",pp->agentsubtype) == 0) { VerifyPackagesPromise(pp); EndMeasurePromise(start,pp); return; } if (strcmp("files",pp->agentsubtype) == 0) { if (GetBooleanConstraint("background",pp)) { ParallelFindAndVerifyFilesPromises(pp); } else { FindAndVerifyFilesPromises(pp); } EndMeasurePromise(start,pp); return; } if (strcmp("commands",pp->agentsubtype) == 0) { VerifyExecPromise(pp); EndMeasurePromise(start,pp); return; } if (strcmp("databases",pp->agentsubtype) == 0) { VerifyDatabasePromises(pp); EndMeasurePromise(start,pp); return; } if (strcmp("methods",pp->agentsubtype) == 0) { VerifyMethodsPromise(pp); EndMeasurePromise(start,pp); return; } if (strcmp("services",pp->agentsubtype) == 0) { VerifyServicesPromise(pp); EndMeasurePromise(start,pp); return; } if (strcmp("environments",pp->agentsubtype) == 0) { VerifyEnvironmentsPromise(pp); EndMeasurePromise(start,pp); return; } if (strcmp("reports",pp->agentsubtype) == 0) { VerifyReportPromise(pp); return; } } /*********************************************************************/ /* Type context */ /*********************************************************************/ int NewTypeContext(enum typesequence type) { // get maxconnections switch(type) { case kp_environments: #ifdef HAVE_NOVA Nova_NewEnvironmentsContext(); #endif break; case kp_files: SERVERLIST = NULL; break; case kp_processes: if (!LoadProcessTable(&PROCESSTABLE)) { CfOut(cf_error,"","Unable to read the process table - cannot keep process promises\n",""); return false; } break; case kp_storage: #ifndef MINGW // TODO: Run if implemented on Windows if (MOUNTEDFSLIST != NULL) { DeleteMountInfo(MOUNTEDFSLIST); MOUNTEDFSLIST = NULL; } #endif /* NOT MINGW */ break; } return true; } /*********************************************************************/ void DeleteTypeContext(enum typesequence type) { struct Rlist *rp; struct ServerItem *svp; struct Attributes a = {{0}}; switch(type) { case kp_classes: HashVariables(THIS_BUNDLE); break; case kp_environments: #ifdef HAVE_NOVA Nova_DeleteEnvironmentsContext(); #endif break; case kp_files: /* Cleanup shared connection array for non-threaded remote copies */ for (rp = SERVERLIST; rp != NULL; rp = rp->next) { svp = (struct ServerItem *)rp->item; if (svp == NULL) { continue; } ServerDisconnection(svp->conn); if (svp->server) { free(svp->server); } rp->item = NULL; } DeleteRlist(SERVERLIST); SERVERLIST = NULL; break; case kp_processes: break; case kp_storage: #ifndef MINGW CfOut(cf_verbose,""," -> Number of changes observed in %s is %d\n",VFSTAB[VSYSTEMHARDCLASS],FSTAB_EDITS); if (FSTAB_EDITS && FSTABLIST && !DONTDO) { if (FSTABLIST) { SaveItemListAsFile(FSTABLIST,VFSTAB[VSYSTEMHARDCLASS],a,NULL); DeleteItemList(FSTABLIST); FSTABLIST = NULL; } FSTAB_EDITS = 0; } if (!DONTDO && CF_MOUNTALL) { CfOut(cf_verbose,"",""); CfOut(cf_verbose,""," -> Mounting all filesystems\n"); MountAll(); CfOut(cf_verbose,"",""); } #endif /* NOT MINGW */ break; case kp_packages: if (!DONTDO) { ExecuteScheduledPackages(); } CleanScheduledPackages(); break; } } /**************************************************************/ void ClassBanner(enum typesequence type) { struct Item *ip; int i; if (type != kp_interfaces) /* Just parsed all local classes */ { return; } CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,""," + Private classes augmented:\n"); for (i = 0; i < CF_ALPHABETSIZE; i++) { for (ip = VADDCLASSES.list[i]; ip != NULL; ip=ip->next) { CfOut(cf_verbose,""," + %s\n",ip->name); } } CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,""," - Private classes diminished:\n"); for (ip = VNEGHEAP; ip != NULL; ip=ip->next) { CfOut(cf_verbose,""," - %s\n",ip->name); } CfOut(cf_verbose,"","\n"); Debug(" ? Public class context:\n"); for (i = 0; i < CF_ALPHABETSIZE; i++) { for (ip = VHEAP.list[i]; ip != NULL; ip=ip->next) { Debug(" ? %s\n",ip->name); } } CfOut(cf_verbose,"","\n"); } /**************************************************************/ /* Thread context */ /**************************************************************/ void ParallelFindAndVerifyFilesPromises(struct Promise *pp) { pid_t child = 1; int background = GetBooleanConstraint("background",pp); #ifdef MINGW if (background) { CfOut(cf_verbose, "", "Background processing of files promises is not supported on Windows"); } FindAndVerifyFilesPromises(pp); #else /* NOT MINGW */ if (background && (CFA_BACKGROUND < CFA_BACKGROUND_LIMIT)) { CFA_BACKGROUND++; CfOut(cf_verbose,"","Spawning new process...\n"); child = fork(); if (child == 0) { ALARM_PID = -1; AM_BACKGROUND_PROCESS = true; } else { AM_BACKGROUND_PROCESS = false; } } else if (CFA_BACKGROUND >= CFA_BACKGROUND_LIMIT) { CfOut(cf_verbose,""," !> Promised parallel execution promised but exceeded the max number of promised background tasks, so serializing"); } if (child == 0 || !background) { FindAndVerifyFilesPromises(pp); } #endif /* NOT MINGW */ } /**************************************************************/ static bool VerifyBootstrap(void) { struct stat sb; char filePath[CF_MAXVARSIZE]; if(EMPTY(POLICY_SERVER)) { CfOut(cf_error, "", "!! Bootstrapping failed, no policy server is specified"); return false; } // we should at least have gotten promises.cf from the policy hub snprintf(filePath, sizeof(filePath), "%s/inputs/promises.cf", CFWORKDIR); MapName(filePath); if(cfstat(filePath, &sb) == -1) { CfOut(cf_error, "", "!! Bootstrapping failed, no input file at %s after bootstrap", filePath); return false; } // embedded failsafe.cf (bootstrap.c) contains a promise to start cf-execd (executed while running this cf-agent) DeleteItemList(PROCESSTABLE); PROCESSTABLE = NULL; LoadProcessTable(&PROCESSTABLE); if(!IsProcessNameRunning(".*cf-execd.*")) { CfOut(cf_error, "", "!! Bootstrapping failed, cf-execd is not running"); return false; } CfOut(cf_cmdout, "", "-> Bootstrap to %s completed successfully", POLICY_SERVER); return true; } cfengine-3.2.4/src/classes.c0000644000175000017500000005342511715232734012625 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*******************************************************************/ /* */ /* GLOBAL class default variables for cfengine */ /* These variables are what needs to be modified if you add or */ /* modify class definitions... remember also to change clsattr */ /* and search for the os types in cfengine.c (mount stuff) */ /* */ /*******************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*********************************************************************/ /* See also "enum classes" in cf.defs.h */ char *CLASSTEXT[] = /* If you change here change enum classes too! */ { "", "", "sun4", "ultrix", "hpux", "aix", "linux", "solaris", "osf", "digital", "sun3", "irix4", "irix", "irix64", "freebsd", "solarisx86", "bsd4_3", "newsos", "netbsd", "aos", "bsdos", "nextstep", "cray", "gnu", "windows", "unix_sv", "openbsd", "sco", "darwin", "ux4800", "qnx", "dragonfly", "windows", "vmware", "unused1", "unused2", "unused3", NULL }; /*********************************************************************/ /* remember to change cf.defs.h !! */ char *CLASSATTRIBUTES[CF_CLASSATTR][CF_ATTRDIM] = { {"-","-","-"}, /* as appear here are matched. The */ {"-","-","-"}, /* fields are sysname and machine */ {"sunos",".*","4.*"}, /* sun 4 */ {"ultrix","risc","4.*"}, /* ultrix */ {"hp-ux",".*",".*"}, /* hpux */ {"aix",".*",".*"}, /* aix */ {"linux",".*",".*"}, /* linux */ {"sunos","sun4.*","5.*"}, /* solaris */ {"osf1","alpha",".*"}, /* osf1 */ {"osf1","alpha","4.*"}, /* digital */ {"sunos","sun3","4.*"}, /* sun3 */ {"irix4","ip.*","4.*"}, /* irix4 */ {"irix", "ip.*",".*"}, /* irix */ {"irix64","ip.*",".*"}, /* irix64 */ {"freebsd",".*",".*"}, /* freebsd */ {"sunos","i86pc","5.*"}, /* solarisx86 */ {"bsd",".*",".*"}, /* bsd 4.3 */ {"newsos",".*",".*"}, /* newsos4 */ {"netbsd",".*",".*"}, /* NetBSD */ {"aos",".*",".*"}, /* AOS */ {"bsd/os",".*",".*"}, /* BSDI */ {"nextstep",".*",".*"}, /* nextstep */ {"sn.*","cray*",".*"}, /* cray */ {"gnu.*",".*",".*"}, /* gnu */ {"cygwin_nt.*",".*",".*"}, /* NT (cygwin) */ {"unix_sv",".*",".*"}, /* Unixware */ {"openbsd",".*",".*"}, /* OpenBSD */ {"sco_sv",".*",".*"}, /* SCO */ {"darwin",".*",".*"}, /* Darwin, aka MacOS X */ {"ux4800",".*",".*"}, /* UX/4800 */ {"qnx",".*",".*"}, /* qnx */ {"dragonfly",".*",".*"}, /* dragonfly */ {"windows_nt.*",".*",".*"}, /* NT (native) */ {"vmkernel",".*",".*"}, /* VMWARE / ESX */ {"unused1","blah","blah"}, {"unused2","blah","blah"}, {"unused3","blah","blah"}, {NULL,NULL,NULL} }; /*********************************************************************/ char *VPSCOMM[CF_CLASSATTR] = { "", "", "/bin/ps", /* sun 4 */ "/bin/ps", /* ultrix */ "/bin/ps", /* hpux */ "/bin/ps", /* aix */ "/bin/ps", /* linux */ "/bin/ps", /* solaris */ "/bin/ps", /* osf1 */ "/bin/ps", /* digital */ "/bin/ps", /* sun3 */ "/bin/ps", /* irix4 */ "/bin/ps", /* irix */ "/bin/ps", /* irix64 */ "/bin/ps", /* freebsd */ "/bin/ps", /* solarisx86 */ "/bin/ps", /* bsd 4.3 */ "/bin/ps", /* newos4 */ "/bin/ps", /* netbsd */ "/bin/ps", /* AOS */ "/bin/ps", /* BSDI */ "/bin/ps", /* nextstep */ "/bin/ps", /* cray */ "/bin/ps", /* gnu */ "/bin/ps", /* NT - cygnus */ "/bin/ps", /* unixware */ "/bin/ps", /* openbsd */ "/bin/ps", /* sco */ "/bin/ps", /* darwin */ "/bin/ps", /* ux4800 */ "/bin/ps", /* qnx */ "/bin/ps", /* dragonfly */ "mingw-invalid", /* mingw */ "/bin/ps", /* vmware */ "/bin/ps", "/bin/ps", "/bin/ps", NULL }; /*********************************************************************/ // linux after rhel 3: ps -eo user,pid,ppid,pgid,%cpu,%mem,vsize,ni,rss,stat,nlwp,stime,time,args // solaris: ps -eo user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,nlwp,stime,time,args char *VPSOPTS[CF_CLASSATTR] = { "", "", "auxw", /* sun4 */ "auxw", /* ultrix */ "-ef", /* hpux */ "-eo user,pid,ppid,pgid,pcpu,pmem,vsz,ni,stat,stime,time,args", /* aix */ "-eo user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,nlwp,stime,time,args", /* linux */ "-eo user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,nlwp,stime,time,args", /* solaris */ "-ef", /* osf1 */ "auxw", /* digital */ "auxw", /* sun3 */ "-ef", /* irix4 */ "-ef", /* irix */ "-ef", /* irix64 */ "auxw", /* freebsd */ "-eo user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,nlwp,stime,time,args", /* solarisx86 */ "-ax", /* bsd 4.3 */ "auxw", /* newsos4 */ "auxw", /* netbsd */ "auxw", /* AOS */ "auxw", /* BSDI */ "auxw", /* nextstep */ "-elyf", /* cray */ "auxw", /* gnu */ "-aW", /* NT */ "-ef", /* Unixware */ "auxw", /* openbsd */ "-ef", /* sco */ "auxw", /* darwin */ "-ef", /* ux4800 */ "-elyf", /* qnx */ "auxw", /* dragonfly */ "mingw-invalid", /* mingw */ "?", /* vmware*/ "-", "-", "-", NULL }; /*********************************************************************/ char *VMOUNTCOMM[CF_CLASSATTR] = { "", /* see cf.defs.h */ "", "/etc/mount -va", /* sun4 */ "/etc/mount -va", /* ultrix */ "/sbin/mount -ea", /* hpux */ /*"/etc/mount -t nfs",*/ /* aix */ "/usr/sbin/mount -t nfs", /* aix */ "/bin/mount -va", /* linux */ "/usr/sbin/mount -a", /* solaris */ "/usr/sbin/mount -va", /* osf1 */ "/usr/sbin/mount -va", /* digital */ "/etc/mount -va", /* sun3 */ "/sbin/mount -va", /* irix4 */ "/sbin/mount -va", /* irix */ "/sbin/mount -va", /* irix64 */ "/sbin/mount -va", /* freebsd */ "/usr/sbin/mount -a", /* solarisx86 */ "/etc/mount -a", /* bsd 4.3 */ "/etc/mount -a", /* newsos4 */ "/sbin/mount -a", /* netbsd */ "/etc/mount -a", /* AOS */ "/sbin/mount -a", /* BSDI */ "/usr/etc/mount -a", /* nextstep */ "/etc/mount -va", /* cray */ "/bin/mount -va", /* gnu */ "/bin/sh /etc/fstab", /* NT - possible security issue */ "/sbin/mountall", /* Unixware */ "/sbin/mount", /* openbsd */ "/etc/mountall", /* sco */ "/sbin/mount -va", /* darwin */ "/sbin/mount -v", /* ux4800 */ "/bin/mount -v", /* qnx */ "/sbin/mount -va", /* dragonfly */ "mingw-invalid", /* mingw */ "/bin/mount -a", /* vmware */ "unused-blah", "unused-blah", "unused-blah", NULL }; /*********************************************************************/ char *VUNMOUNTCOMM[CF_CLASSATTR] = { "", /* see cf.defs.h */ "", "/etc/umount", /* sun4 */ "/etc/umount", /* ultrix */ "/sbin/umount", /* hpux */ "/usr/sbin/umount", /* aix */ "/bin/umount", /* linux */ "/etc/umount", /* solaris */ "/usr/sbin/umount", /* osf1 */ "/usr/sbin/umount", /* digital */ "/etc/umount", /* sun3 */ "/sbin/umount", /* irix4 */ "/sbin/umount", /* irix */ "/sbin/umount", /* irix64 */ "/sbin/umount", /* freebsd */ "/etc/umount", /* solarisx86 */ "/etc/umount", /* bsd4.3 */ "/etc/umount", /* newsos4 */ "/sbin/umount", /* netbsd */ "/etc/umount", /* AOS */ "/sbin/umount", /* BSDI */ "/usr/etc/umount", /* nextstep */ "/etc/umount", /* cray */ "/sbin/umount", /* gnu */ "/bin/umount", /* NT */ "/sbin/umount", /* Unixware */ "/sbin/umount", /* openbsd */ "/etc/umount", /* sco */ "/sbin/umount", /* darwin */ "/sbin/umount", /* ux4800 */ "/bin/umount", /* qnx */ "/sbin/umount", /* dragonfly */ "mingw-invalid", /* mingw */ "/bin/umount", /* vmware */ "unused-blah", "unused-blah", "unused-blah", NULL }; /*********************************************************************/ char *VMOUNTOPTS[CF_CLASSATTR] = { "", /* see cf.defs.h */ "", "bg,hard,intr", /* sun4 */ "bg,hard,intr", /* ultrix */ "bg,hard,intr", /* hpux */ "bg,hard,intr", /* aix */ "defaults", /* linux */ "bg,hard,intr", /* solaris */ "bg,hard,intr", /* osf1 */ "bg,hard,intr", /* digital */ "bg,hard,intr", /* sun3 */ "bg,hard,intr", /* irix4 */ "bg,hard,intr", /* irix */ "bg,hard,intr", /* irix64 */ "bg,intr", /* freebsd */ "bg,hard,intr", /* solarisx86 */ "bg,hard,intr", /* bsd4.3 */ "bg,hard,intr", /* newsos4 */ "-i,-b", /* netbsd */ "bg,hard,intr", /* AOS */ "bg,intr", /* BSDI */ "bg,hard,intr", /* nextstep */ "bg,hard,intr", /* cray */ "defaults", /* gnu */ "", /* NT */ "bg,hard,intr", /* Unixware */ "-i,-b", /* openbsd */ "bg,hard,intr", /* sco */ "-i,-b", /* darwin */ "bg,hard,intr", /* ux4800 */ "bg,hard,intr", /* qnx */ "bg,intr", /* dragonfly */ "mingw-invalid", /* mingw */ "defaults", /* vmstate */ "unused-blah", "unused-blah", "unused-blah", NULL }; /*********************************************************************/ char *VRESOLVCONF[CF_CLASSATTR] = { "-", "-", /* see cf.defs.h */ "/etc/resolv.conf", /* sun4 */ "/etc/resolv.conf", /* ultrix */ "/etc/resolv.conf", /* hpux */ "/etc/resolv.conf", /* aix */ "/etc/resolv.conf", /* linux */ "/etc/resolv.conf", /* solaris */ "/etc/resolv.conf", /* osf1 */ "/etc/resolv.conf", /* digital */ "/etc/resolv.conf", /* sun3 */ "/usr/etc/resolv.conf", /* irix4 */ "/etc/resolv.conf", /* irix */ "/etc/resolv.conf", /* irix64 */ "/etc/resolv.conf", /* freebsd */ "/etc/resolv.conf", /* solarisx86 */ "/etc/resolv.conf", /* bsd4.3 */ "/etc/resolv.conf", /* newsos4 */ "/etc/resolv.conf", /* netbsd */ "/etc/resolv.conf", /* AOS */ "/etc/resolv.conf", /* BSDI */ "/etc/resolv.conf", /* nextstep */ "/etc/resolv.conf", /* cray */ "/etc/resolv.conf", /* gnu */ "/etc/resolv.conf", /* NT */ "/etc/resolv.conf", /* Unixware */ "/etc/resolv.conf", /* openbsd */ "/etc/resolv.conf", /* sco */ "/etc/resolv.conf", /* darwin */ "/etc/resolv.conf", /* ux4800 */ "/etc/resolv.conf", /* qnx */ "/etc/resolv.conf", /* dragonfly */ "", /* mingw */ "/etc/resolv.conf", /* vmware */ "unused-blah", "unused-blah", "unused-blah", NULL }; /*********************************************************************/ char *VFSTAB[CF_CLASSATTR] = { "-", "-", /* see cf.defs.h */ "/etc/fstab", /* sun4 */ "/etc/fstab", /* ultrix */ "/etc/fstab", /* hpux */ "/etc/filesystems", /* aix */ "/etc/fstab", /* linux */ "/etc/vfstab", /* solaris */ "/etc/fstab", /* osf1 */ "/etc/fstab", /* digital */ "/etc/fstab", /* sun3 */ "/etc/fstab", /* irix4 */ "/etc/fstab", /* irix */ "/etc/fstab", /* irix64 */ "/etc/fstab", /* freebsd */ "/etc/vfstab", /* solarisx86 */ "/etc/fstab", /* bsd4.3 */ "/etc/fstab", /* newsos4 */ "/etc/fstab", /* netbsd */ "/etc/fstab", /* AOS */ "/etc/fstab", /* BSDI */ "/etc/fstab", /* nextstep */ "/etc/fstab", /* cray */ "/etc/fstab", /* gnu */ "/etc/fstab", /* NT */ "/etc/vfstab", /* Unixware */ "/etc/fstab", /* openbsd */ "/etc/default/filesys", /* sco */ "/etc/fstab", /* darwin */ "/etc/vfstab", /* ux4800 */ "/etc/fstab", /* qnx */ "/etc/fstab", /* dragonfly */ "", /* mingw */ "/etc/fstab", /* vmware */ "unused-blah", "unused-blah", "unused-blah", NULL }; /*********************************************************************/ char *VMAILDIR[CF_CLASSATTR] = { "-", "-", /* see cf.defs.h */ "/var/spool/mail", /* sun4 */ "/usr/spool/mail", /* ultrix */ "/var/mail", /* hpux */ "/var/spool/mail", /* aix */ "/var/spool/mail", /* linux */ "/var/mail", /* solaris */ "/usr/spool/mail", /* osf1 */ "/usr/spool/mail", /* digital */ "/var/spool/mail", /* sun3 */ "/usr/mail", /* irix4 */ "/usr/mail", /* irix */ "/usr/var/mail", /* irix64 */ "/var/mail", /* freebsd */ "/var/mail", /* solarisx86 */ "/usr/spool/mail", /* bsd4.3 */ "/usr/spool/mail", /* newsos4 */ "/var/mail", /* netbsd */ "/usr/spool/mail", /* AOS */ "/var/mail", /* BSDI */ "/usr/spool/mail", /* nextstep */ "/usr/mail", /* cray */ "/var/spool/mail", /* gnu */ "N/A", /* NT */ "/var/mail", /* Unixware */ "/var/mail", /* openbsd */ "/var/spool/mail", /* sco */ "/var/mail", /* darwin */ "/var/mail", /* ux4800 */ "/var/spool/mail", /* qnx */ "/var/mail", /* dragonfly */ "", /* mingw */ "/var/spool/mail", /* vmware */ "unused-blah", "unused-blah", "unused-blah", NULL }; /*********************************************************************/ char *VNETSTAT[CF_CLASSATTR] = { "-", "-", "/usr/ucb/netstat -rn", /* sun4 */ "/usr/ucb/netstat -rn", /* ultrix */ "/usr/bin/netstat -rn", /* hpux */ "/usr/bin/netstat -rn", /* aix */ "/bin/netstat -rn", /* linux */ "/usr/bin/netstat -rn", /* solaris */ "/usr/sbin/netstat -rn", /* osf1 */ "/usr/sbin/netstat -rn", /* digital */ "/usr/ucb/netstat -rn", /* sun3 */ "/usr/etc/netstat -rn", /* irix4 */ "/usr/etc/netstat -rn", /* irix */ "/usr/etc/netstat -rn", /* irix64 */ "/usr/bin/netstat -rn", /* freebsd */ "/bin/netstat -rn", /* solarisx86 */ "/usr/ucb/netstat -rn", /* bsd4.3 */ "/usr/ucb/netstat -rn", /* newsos4 */ "/usr/bin/netstat -rn", /* netbsd */ "/usr/ucb/netstat -rn", /* AOS */ "/usr/sbin/netstat -rn", /* BSDI */ "/usr/ucb/netstat -rn", /* nextstep */ "/usr/ucb/netstat -rn", /* cray */ "/bin/netstat -rn", /* gnu */ "/cygdrive/c/WINNT/System32/netstat", /* NT */ "/usr/bin/netstat -rn", /* Unixware */ "/usr/bin/netstat -rn", /* openbsd */ "/usr/bin/netstat -rn", /* sco */ "/usr/sbin/netstat -rn", /* darwin */ "/usr/bin/netstat -rn", /* ux4800 */ "/usr/bin/netstat -rn", /* qnx */ "/usr/bin/netstat -rn", /* dragonfly */ "mingw-invalid", /* mingw */ "/usr/bin/netstat", /* vmware */ "unused-blah", "unused-blah", "unused-blah", NULL }; /*********************************************************************/ char *VEXPORTS[CF_CLASSATTR] = { "-", "-", "/etc/exports", /* sun4 */ "/etc/exports", /* ultrix */ "/etc/exports", /* hpux */ "/etc/exports", /* aix */ "/etc/exports", /* linux */ "/etc/dfs/dfstab", /* solaris */ "/etc/exports", /* osf1 */ "/etc/exports", /* digital */ "/etc/exports", /* sun3 */ "/etc/exports", /* irix4 */ "/etc/exports", /* irix */ "/etc/exports", /* irix64 */ "/etc/exports", /* freebsd */ "/etc/dfs/dfstab", /* solarisx86 */ "/etc/exports", /* bsd4.3 */ "/etc/exports", /* newsos4 */ "/etc/exports", /* netbsd */ "/etc/exports", /* AOS */ "/etc/exports", /* BSDI */ "/etc/exports", /* nextstep */ "/etc/exports", /* cray */ "/etc/exports", /* gnu */ "/etc/exports", /* NT */ "/etc/dfs/dfstab", /* Unixware */ "/etc/exports", /* openbsd */ "/etc/dfs/dfstab", /* sco */ "/etc/exports", /* darwin */ "/etc/exports", /* ux4800 */ "/etc/exports", /* qnx */ "/etc/exports", /* dragonfly */ "", /* mingw */ "none", /* vmware */ "unused-blah", "unused-blah", "unused-blah", NULL }; /*********************************************************************/ char *VROUTE[CF_CLASSATTR] = { "-", "-", "-", /* sun4 */ "-", /* ultrix */ "-", /* hpux */ "-", /* aix */ "/sbin/route", /* linux */ "/usr/sbin/route",/* solaris */ "-", /* osf1 */ "-", /* digital */ "-", /* sun3 */ "-", /* irix4 */ "-", /* irix */ "-", /* irix64 */ "/sbin/route", /* freebsd */ "/usr/sbin/route",/* solarisx86 */ "-", /* bsd4.3 */ "-", /* newsos4 */ "-", /* netbsd */ "-", /* AOS */ "-", /* BSDI */ "-", /* nextstep */ "-", /* cray */ "-", /* gnu */ "-", /* NT */ "-", /* Unixware */ "/sbin/route", /* openbsd */ "-", /* sco */ "/sbin/route", /* darwin */ "-", /* ux4800 */ "-", /* qnx */ "/sbin/route", /* dragonfly */ "-", /* mingw */ "-", /* vmware */ "unused-blah", "unused-blah", "unused-blah", NULL }; /*********************************************************************/ char *VROUTEADDFMT[CF_CLASSATTR] = { "-", "-", "-", /* sun4 */ "-", /* ultrix */ "-", /* hpux */ "-", /* aix */ "add %s gw %s", /* linux */ "add %s %s", /* solaris */ "-", /* osf1 */ "-", /* digital */ "-", /* sun3 */ "-", /* irix4 */ "-", /* irix */ "-", /* irix64 */ "add %s %s", /* freebsd */ "add %s %s", /* solarisx86 */ "-", /* bsd4.3 */ "-", /* newsos4 */ "-", /* netbsd */ "-", /* AOS */ "-", /* BSDI */ "-", /* nextstep */ "-", /* cray */ "-", /* gnu */ "-", /* NT */ "-", /* Unixware */ "add %s %s", /* openbsd */ "-", /* sco */ "add %s %s", /* darwin */ "-", /* ux4800 */ "-", /* qnx */ "add %s %s", /* dragonfly */ "-", /* mingw */ "-", /* vmware */ "unused-blah", "unused-blah", "unused-blah", NULL }; /*********************************************************************/ char *VROUTEDELFMT[CF_CLASSATTR] = { "-", "-", "-", /* sun4 */ "-", /* ultrix */ "-", /* hpux */ "-", /* aix */ "del %s", /* linux */ "delete %s", /* solaris */ "-", /* osf1 */ "-", /* digital */ "-", /* sun3 */ "-", /* irix4 */ "-", /* irix */ "-", /* irix64 */ "delete %s", /* freebsd */ "delete %s", /* solarisx86 */ "-", /* bsd4.3 */ "-", /* newsos4 */ "-", /* netbsd */ "-", /* AOS */ "-", /* BSDI */ "-", /* nextstep */ "-", /* cray */ "-", /* gnu */ "-", /* NT */ "-", /* Unixware */ "delete %s", /* openbsd */ "-", /* sco */ "delete %s", /* darwin */ "-", /* ux4800 */ "-", /* qnx */ "delete %s", /* dragonfly */ "-", /* mingw */ "-", /* vmware */ "unused-blah", "unused-blah", "unused-blah", NULL }; cfengine-3.2.4/src/Makefile.am0000644000175000017500000003000711715232734013047 00000000000000AM_CFLAGS = $(GCC_CFLAG) $(NOVA_CFLAGS) $(CONSTELLATION_CFLAGS) @CFLAGS@ AM_YFLAGS = -d LEXLIB = @LEXLIB@ LDADD = libpromises.la BUILT_SOURCES = cf3parse.h lib_LTLIBRARIES = libpromises.la libpromises_la_LDFLAGS = -version-info 1:0:0 -no-undefined libpromises_la_LIBADD = ../pub/libcfpub.la $(NOVA_LDADD) $(CONSTELLATION_LDADD) libpromises_la_CFLAGS = $(AM_CFLAGS) # Separate out a library libpromises_la_SOURCES = \ cf3parse.y \ cf3lex.l \ alloc.c \ patches.c \ attributes.c \ install.c \ generic_agent.c \ dbm_api.c \ dbm_berkeley.c \ dbm_quick.c \ dbm_tokyocab.c \ dbm_sqlite3.c \ dir.c \ dtypes.c \ classes.c \ env_context.c \ string_expressions.c \ logic_expressions.c \ files_interfaces.c \ files_properties.c \ files_select.c \ files_operators.c \ files_repository.c \ files_copy.c \ files_editline.c \ files_edit.c \ files_links.c \ files_hashes.c \ files_names.c \ chflags.c \ modes.c \ exec_tools.c \ nfs.c \ item-lib.c \ alphalist.c \ cf_sql.c \ client_protocol.c \ client_code.c \ communication.c \ net.c \ sockaddr.c \ recursion.c \ processes_select.c \ fncall.c \ cf3globals.c \ reporting.c \ evalfunction.c \ sysinfo.c \ conversion.c \ scope.c \ assoc.c \ comparray.c \ vars.c \ args.c \ hashes.c \ crypto.c \ sort.c \ keyring.c \ full-write.c \ expand.c \ matching.c \ selfdiagnostic.c \ instrumentation.c \ granules.c \ timeout.c \ promises.c \ ontology.c \ constraints.c \ iteration.c \ rlist.c \ syntax.c \ logging.c \ signals.c \ transaction.c \ cfstream.c \ pipes.c \ html.c \ interfaces.c \ storage_tools.c \ verify_reports.c \ verify_processes.c \ enterprise_stubs.c \ bootstrap.c \ mod_defaults.c \ mod_common.c \ mod_access.c \ mod_exec.c \ mod_methods.c \ mod_interfaces.c \ mod_packages.c \ mod_files.c \ mod_report.c \ mod_storage.c \ mod_knowledge.c \ mod_measurement.c \ mod_databases.c \ mod_services.c \ mod_process.c \ mod_environ.c \ mod_outputs.c \ unix.c # Automake need to be guided due to symlinking libpromises_la_DEPENDENCIES = ../pub/libcfpub.la $(NOVA_LDADD) $(CONSTELLATION_LDADD) sbin_PROGRAMS = cf-know cf-promises cf-agent cf-monitord cf-serverd cf-execd cf-runagent cf-key cf-report if HAVE_NOVA sbin_PROGRAMS += cf-hub endif cf_promises_SOURCES = \ cfpromises.c cf_key_SOURCES = \ cfkey.c cf_report_SOURCES = \ cfreport.c cf_agent_SOURCES = \ agent.c \ verify_files.c \ verify_storage.c \ verify_exec.c \ verify_methods.c \ verify_interfaces.c \ verify_packages.c \ verify_databases.c \ verify_services.c \ verify_environments.c \ agentdiagnostic.c cf_serverd_SOURCES = \ server.c \ server_transform.c cf_monitord_SOURCES = \ verify_measurements.c \ env_monitor.c \ mon_cpu.c \ mon_disk.c \ mon_entropy.c \ mon_load.c \ mon_network_sniffer.c \ mon_network.c \ mon_processes.c \ mon_temp.c \ monitor.c cf_monitord_LDADD = libpromises.la if HAVE_NOVA cf_monitord_LDADD += ../nova/src/libcfmonitord.la endif cf_execd_SOURCES = \ exec.c if HAVE_NOVA cf_hub_SOURCES = cf_hub_LDADD = \ ../nova/src/libcfhub.la libpromises.la endif cf_runagent_SOURCES = \ runagent.c cf_know_SOURCES = \ cfknow.c \ manual.c EXTRA_DIST = cf3lex.c cf3parse.c # # Pickup header files here so Automake knows about them # noinst_HEADERS = \ cf.defs.h \ cf.extern.h \ config.h \ prototypes3.h \ cf3.defs.h \ cf3.server.h \ cf3parse.h \ cf3.extern.h \ cf.events.h \ string_expressions.h \ logic_expressions.h \ compiler.h \ monitoring.h \ bool.h # # Some basic clean ups # MOSTLYCLEANFILES = *~ *.orig *.rej # # Get everything removed down to where rebuilding requires: # "make; make install" # CLEANFILES = cf3lex.c cf3parse.c cf3parse.h # # Get everything removed down to where rebuilding requires: # "configure; make; make install" # DISTCLEANFILES = cflex.c cfparse.c cfparse.h # # Get everything removed down to where rebuilding requires: # "aclocal; autoconf; autoheader; automake --add-missing" # "configure; make; make install" # MAINTAINERCLEANFILES = Makefile.in conf.h.in stamp-h.in SUFFIXES= .h cf3.defs.h: cd ./../core/src; svn update ln -fs ../../core/src/cf3.defs.h cf3.defs.hcfengine-3.2.4/src/mon_disk.c0000644000175000017500000000553511715232734012772 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #include "cf3.defs.h" #include "cf3.extern.h" #include "monitoring.h" /* Globals */ static double LASTQ[CF_OBSERVABLES]; /* Prototypes */ static int GetFileGrowth(const char *filename, enum observables index); /* Implementation */ void MonDiskGatherData(double *cf_this) { char accesslog[CF_BUFSIZE]; char errorlog[CF_BUFSIZE]; char syslog[CF_BUFSIZE]; char messages[CF_BUFSIZE]; CfOut(cf_verbose,"","Gathering disk data\n"); cf_this[ob_diskfree] = GetDiskUsage("/",cfpercent); CfOut(cf_verbose,"","Disk free = %.0lf%%\n",cf_this[ob_diskfree]); /* Here would should have some detection based on OS type VSYSTEMHARDCLASS */ switch(VSYSTEMHARDCLASS) { default: strcpy(accesslog,"/var/log/apache2/access_log"); strcpy(errorlog,"/var/log/apache2/error_log"); strcpy(syslog,"/var/log/syslog"); strcpy(messages,"/var/log/messages"); } cf_this[ob_webaccess] = GetFileGrowth(accesslog,ob_webaccess); CfOut(cf_verbose,"","Webaccess = %.2lf%%\n",cf_this[ob_webaccess]); cf_this[ob_weberrors] = GetFileGrowth(errorlog,ob_weberrors); CfOut(cf_verbose,"","Web error = %.2lf%%\n",cf_this[ob_weberrors]); cf_this[ob_syslog] = GetFileGrowth(syslog,ob_syslog); CfOut(cf_verbose,"","Syslog = %.2lf%%\n",cf_this[ob_syslog]); cf_this[ob_messages] = GetFileGrowth(messages,ob_messages); CfOut(cf_verbose,"","Messages = %.2lf%%\n",cf_this[ob_messages]); } /****************************************************************************/ static int GetFileGrowth(const char *filename, enum observables index) { struct stat statbuf; size_t q; double dq; if (cfstat(filename,&statbuf) == -1) { return 0; } q = statbuf.st_size; CfOut(cf_verbose,"","GetFileGrowth(%s) = %d\n",filename,q); dq = (double)q - LASTQ[index]; if (LASTQ[index] == 0) { LASTQ[index] = q; return (int)(q/100+0.5); /* arbitrary spike mitigation */ } LASTQ[index] = q; return (int)(dq+0.5); } cfengine-3.2.4/src/runagent.c0000644000175000017500000005053511715232734013012 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: runagent.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" int main (int argc,char *argv[]); int HailServer(char *host,struct Attributes a,struct Promise *pp); void ThisAgentInit(void); int ParseHostname(char *hostname,char *new_hostname); void SendClassData(struct cfagent_connection *conn); struct Promise *MakeDefaultRunAgentPromise(void); void HailExec(struct cfagent_connection *conn,char *peer,char *recvbuffer,char *sendbuffer); FILE *NewStream(char *name); void DeleteStream(FILE *fp); /*******************************************************************/ /* Command line options */ /*******************************************************************/ const char *ID = "The run agent connects to a list of running instances of\n" "the cf-serverd service. The agent allows a user to\n" "forego the usual scheduling interval for the agent and\n" "activate cf-agent on a remote host. Additionally, a user\n" "can send additional classes to be defined on the remote\n" "host. Two kinds of classes may be sent: classes to decide\n" "on which hosts the agent will be started, and classes that\n" "the user requests the agent should define on execution.\n" "The latter type is regulated by cf-serverd's role based\n" "access control."; const struct option OPTIONS[17] = { { "help",no_argument,0,'h' }, { "background",optional_argument,0,'b' }, { "debug",optional_argument,0,'d' }, { "verbose",no_argument,0,'v' }, { "dry-run",no_argument,0,'n'}, { "version",no_argument,0,'V' }, { "file",required_argument,0,'f'}, { "define-class",required_argument,0,'D' }, { "select-class",required_argument,0,'s' }, { "inform",no_argument,0,'I'}, { "remote-options",required_argument,0,'o'}, { "diagnostic",no_argument,0,'x'}, { "hail",required_argument,0,'H'}, { "interactive",no_argument,0,'i'}, { "query",optional_argument,0,'q'}, { "timeout",required_argument,0,'t'}, { NULL,0,0,'\0' } }; const char *HINTS[17] = { "Print the help message", "Parallelize connections (50 by default)", "Set debugging level 0,1,2,3", "Output verbose information about the behaviour of the agent", "All talk and no action mode - make no changes, only inform of promises not kept", "Output the version of the software", "Specify an alternative input file than the default", "Define a list of comma separated classes to be sent to a remote agent", "Define a list of comma separated classes to be used to select remote agents by constraint", "Print basic information about changes made to the system, i.e. promises repaired", "Pass options to a remote server process", "Activate internal diagnostics (developers only)", "Hail the following comma-separated lists of hosts, overriding default list", "Enable interactive mode for key trust", "Query a server for a knowledge menu", "Connection timeout, seconds", NULL }; extern struct BodySyntax CFR_CONTROLBODY[]; int INTERACTIVE = false; int OUTPUT_TO_FILE = false; char OUTPUT_DIRECTORY[CF_BUFSIZE]; int BACKGROUND = false; int MAXCHILD = 50; char REMOTE_AGENT_OPTIONS[CF_MAXVARSIZE]; struct Attributes RUNATTR = {{0}}; struct Rlist *HOSTLIST = NULL; char SENDCLASSES[CF_MAXVARSIZE]; char DEFINECLASSES[CF_MAXVARSIZE]; char MENU[CF_MAXVARSIZE]; /*****************************************************************************/ int main(int argc,char *argv[]) { struct Rlist *rp; struct Promise *pp; int count = 0; int status; int pid; CheckOpts(argc,argv); GenericInitialize(argc,argv,"runagent"); ThisAgentInit(); KeepControlPromises(); // Set RUNATTR using copy if (BACKGROUND && INTERACTIVE) { CfOut(cf_error,""," !! You cannot specify background mode and interactive mode together"); exit(1); } pp = MakeDefaultRunAgentPromise(); /* HvB */ if (HOSTLIST) { rp = HOSTLIST; while ( rp != NULL ) { #ifdef MINGW if (BACKGROUND) { CfOut(cf_verbose, "", "Windows does not support starting processes in the background - starting in foreground"); BACKGROUND = false; } #else if (BACKGROUND) /* parallel */ { if (count <= MAXCHILD) { if (fork() == 0) /* child process */ { HailServer(rp->item,RUNATTR,pp); exit(0); } else /* parent process */ { rp = rp->next; count++; } } else { pid = wait(&status); Debug("child = %d, child number = %d\n", pid, count); count--; } } else /* serial */ #endif /* MINGW */ { HailServer(rp->item,RUNATTR,pp); rp = rp->next; } } /* end while */ } /* end if HOSTLIST */ #ifndef MINGW if (BACKGROUND) { printf("Waiting for child processes to finish\n"); while (count > 1) { pid = wait(&status); CfOut(cf_verbose, "", "Child = %d ended, number = %d\n", pid, count); count--; } } #endif return 0; } /*******************************************************************/ void CheckOpts(int argc,char **argv) { extern char *optarg; int optindex = 0; int c; DEFINECLASSES[0] = '\0'; SENDCLASSES[0] = '\0'; while ((c=getopt_long(argc,argv,"t:q:d:b:vnKhIif:D:VSxo:s:MH:",OPTIONS,&optindex)) != EOF) { switch ((char) c) { case 'f': strncpy(VINPUTFILE,optarg,CF_BUFSIZE-1); VINPUTFILE[CF_BUFSIZE-1] = '\0'; MINUSF = true; break; case 'b': BACKGROUND = true; if (optarg) { MAXCHILD = atoi(optarg); } break; case 'd': NewClass("opt_debug"); switch ((optarg==NULL) ? '3' : *optarg) { case '1': D1 = true; DEBUG = true; break; case '2': D2 = true; DEBUG = true; break; default: DEBUG = true; break; } break; case 'q': if (optarg==NULL) { strcpy(MENU,"delta"); } else { strncpy(MENU,optarg,CF_MAXVARSIZE); } break; case 'K': IGNORELOCK = true; break; case 's': strncpy(SENDCLASSES,optarg,CF_MAXVARSIZE); if (strlen(optarg) > CF_MAXVARSIZE) { FatalError("Argument too long\n"); } break; case 'D': strncpy(DEFINECLASSES,optarg,CF_MAXVARSIZE); if (strlen(optarg) > CF_MAXVARSIZE) { FatalError("Argument too long\n"); } break; case 'H': HOSTLIST = SplitStringAsRList(optarg,','); break; case 'o': strncpy(REMOTE_AGENT_OPTIONS,optarg,CF_MAXVARSIZE); break; case 'I': INFORM = true; break; case 'i': INTERACTIVE = true; break; case 'v': VERBOSE = true; break; case 'n': DONTDO = true; IGNORELOCK = true; NewClass("opt_dry_run"); break; case 't': CONNTIMEOUT = atoi(optarg); break; case 'V': PrintVersionBanner("cf-runagent"); exit(0); case 'h': Syntax("cf-runagent - Run agent",OPTIONS,HINTS,ID); exit(0); case 'M': ManPage("cf-runagent - Run agent",OPTIONS,HINTS,ID); exit(0); case 'x': SelfDiagnostic(); exit(0); default: Syntax("cf-runagent - Run agent",OPTIONS,HINTS,ID); exit(1); } } Debug("Set debugging\n"); } /*******************************************************************/ void ThisAgentInit() { umask(077); if (strstr(REMOTE_AGENT_OPTIONS,"--file")||strstr(REMOTE_AGENT_OPTIONS,"-f")) { CfOut(cf_error,"","The specified remote options include a useless --file option. The remote server has promised to ignore this, thus it is disallowed.\n"); exit(1); } } /********************************************************************/ int HailServer(char *host,struct Attributes a,struct Promise *pp) { struct cfagent_connection *conn; char sendbuffer[CF_BUFSIZE],recvbuffer[CF_BUFSIZE],peer[CF_MAXVARSIZE],ipv4[CF_MAXVARSIZE],digest[CF_MAXVARSIZE],user[CF_SMALLBUF]; long gotkey; char reply[8]; struct Item *queries; a.copy.portnumber = (short)ParseHostname(host,peer); snprintf(ipv4,CF_MAXVARSIZE,"%s",Hostname2IPString(peer)); IPString2KeyDigest(ipv4,digest); GetCurrentUserName(user,CF_SMALLBUF); if (INTERACTIVE) { CfOut(cf_verbose,""," -> Using interactive key trust...\n"); gotkey = (long)HavePublicKey(user,peer,digest); if (!gotkey) { gotkey = (long)HavePublicKey(user,ipv4,digest); } if (!gotkey) { printf("WARNING - You do not have a public key from host %s = %s\n",host,ipv4); printf(" Do you want to accept one on trust? (yes/no)\n\n--> "); while (true) { fgets(reply,8,stdin); Chop(reply); if (strcmp(reply,"yes")==0) { printf(" -> Will trust the key...\n"); a.copy.trustkey = true; break; } else if (strcmp(reply,"no")==0) { printf(" -> Will not trust the key...\n"); a.copy.trustkey = false; break; } else { printf(" !! Please reply yes or no...(%s)\n",reply); } } } } /* Continue */ #ifdef MINGW CfOut(cf_inform,"","...........................................................................\n"); CfOut(cf_inform,""," * Hailing %s : %u, with options \"%s\" (serial)\n",peer,a.copy.portnumber,REMOTE_AGENT_OPTIONS); CfOut(cf_inform,"","...........................................................................\n"); #else /* NOT MINGW */ if (BACKGROUND) { CfOut(cf_inform,"","Hailing %s : %u, with options \"%s\" (parallel)\n",peer,a.copy.portnumber,REMOTE_AGENT_OPTIONS); } else { CfOut(cf_inform,"","...........................................................................\n"); CfOut(cf_inform,""," * Hailing %s : %u, with options \"%s\" (serial)\n",peer,a.copy.portnumber,REMOTE_AGENT_OPTIONS); CfOut(cf_inform,"","...........................................................................\n"); } #endif /* NOT MINGW */ a.copy.servers = SplitStringAsRList(peer,'*'); if (a.copy.servers == NULL || strcmp(a.copy.servers->item,"localhost") == 0) { cfPS(cf_inform,CF_NOP,"",pp,a,"No hosts are registered to connect to"); return false; } else { conn = NewServerConnection(a,pp); if (conn == NULL) { CfOut(cf_verbose,""," -> No suitable server responded to hail\n"); return false; } } /* Check trust interaction*/ pp->cache = NULL; if (strlen(MENU) > 0) { #ifdef HAVE_NOVA enum cfd_menu menu = String2Menu(MENU); switch(menu) { case cfd_menu_delta: Nova_QueryForKnowledgeMap(conn,MENU,time(0) - SECONDS_PER_MINUTE * 10); break; case cfd_menu_full: Nova_QueryForKnowledgeMap(conn,MENU,time(0) - SECONDS_PER_WEEK); break; case cfd_menu_relay: #ifdef HAVE_CONSTELLATION queries = Constellation_CreateAllQueries(); Constellation_QueryRelay(conn,queries); DeleteItemList(queries); #endif break; default: break; } #endif /* HAVE_NOVA */ } else { HailExec(conn,peer,recvbuffer,sendbuffer); } ServerDisconnection(conn); DeleteRlist(a.copy.servers); return true; } /********************************************************************/ /* Level 2 */ /********************************************************************/ void KeepControlPromises() { struct Constraint *cp; char rettype; void *retval; RUNATTR.copy.trustkey = false; RUNATTR.copy.encrypt = true; RUNATTR.copy.force_ipv4 = false; RUNATTR.copy.portnumber = SHORT_CFENGINEPORT; /* Keep promised agent behaviour - control bodies */ for (cp = ControlBodyConstraints(cf_runagent); cp != NULL; cp=cp->next) { if (IsExcluded(cp->classes)) { continue; } if (GetVariable("control_runagent",cp->lval,&retval,&rettype) == cf_notype) { CfOut(cf_error,"","Unknown lval %s in runagent control body",cp->lval); continue; } if (strcmp(cp->lval,CFR_CONTROLBODY[cfr_force_ipv4].lval) == 0) { RUNATTR.copy.force_ipv4 = GetBoolean(retval); CfOut(cf_verbose,"","SET force_ipv4 = %d\n",RUNATTR.copy.force_ipv4); continue; } if (strcmp(cp->lval,CFR_CONTROLBODY[cfr_trustkey].lval) == 0) { RUNATTR.copy.trustkey = GetBoolean(retval); CfOut(cf_verbose,"","SET trustkey = %d\n",RUNATTR.copy.trustkey); continue; } if (strcmp(cp->lval,CFR_CONTROLBODY[cfr_encrypt].lval) == 0) { RUNATTR.copy.encrypt = GetBoolean(retval); CfOut(cf_verbose,"","SET encrypt = %d\n",RUNATTR.copy.encrypt); continue; } if (strcmp(cp->lval,CFR_CONTROLBODY[cfr_portnumber].lval) == 0) { RUNATTR.copy.portnumber = (short)Str2Int(retval); CfOut(cf_verbose,"","SET default portnumber = %u\n",(int)RUNATTR.copy.portnumber); continue; } if (strcmp(cp->lval,CFR_CONTROLBODY[cfr_background].lval) == 0) { /* * Only process this option if are is no -b or -i options specified on * command line. */ if (BACKGROUND || INTERACTIVE) { CfOut(cf_error, "", "Warning: 'background_children' setting from 'body runagent control' is overriden by command-line option."); } else { BACKGROUND = GetBoolean(retval); } continue; } if (strcmp(cp->lval,CFR_CONTROLBODY[cfr_maxchild].lval) == 0) { MAXCHILD = (short)Str2Int(retval); continue; } if (strcmp(cp->lval,CFR_CONTROLBODY[cfr_output_to_file].lval) == 0) { OUTPUT_TO_FILE = GetBoolean(retval); continue; } /* * HvB: add variabele output directory */ if (strcmp(cp->lval,CFR_CONTROLBODY[cfr_output_directory].lval) == 0) { if ( IsAbsPath(retval) ) { strncpy(OUTPUT_DIRECTORY,retval,CF_BUFSIZE-1); CfOut(cf_verbose,"","SET output direcory to = %s\n", OUTPUT_DIRECTORY); } continue; } if (strcmp(cp->lval,CFR_CONTROLBODY[cfr_timeout].lval) == 0) { RUNATTR.copy.timeout = (short)Str2Int(retval); continue; } if (strcmp(cp->lval,CFR_CONTROLBODY[cfr_hosts].lval) == 0) { if (HOSTLIST == NULL) // Don't override if command line setting { HOSTLIST = retval; } continue; } } } /********************************************************************/ struct Promise *MakeDefaultRunAgentPromise() { struct Promise *pp; /* The default promise here is to hail associates */ if ((pp = (struct Promise *)malloc(sizeof(struct Promise))) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Promise"); FatalError(""); } pp->audit = NULL; pp->lineno = 0; pp->bundle = strdup("implicit internal bundle for runagent"); pp->promiser = strdup("runagent"); pp->promisee = NULL; pp->petype = CF_NOPROMISEE; pp->classes = NULL; pp->conlist = NULL; pp->done = false; pp->donep = &(pp->done); pp->ref = NULL; pp->agentsubtype = NULL; pp->this_server = NULL; pp->cache = NULL; pp->conn = NULL; pp->inode_cache = NULL; pp->next = NULL; return pp; } /********************************************************************/ int ParseHostname(char *name,char *hostname) { int port = ntohs(SHORT_CFENGINEPORT); if (strchr(name,':')) { sscanf(name,"%250[^:]:%d",hostname,&port); } else { strncpy(hostname,name,CF_MAXVARSIZE); } return(port); } /********************************************************************/ void SendClassData(struct cfagent_connection *conn) { struct Rlist *classes,*rp; char sendbuffer[CF_BUFSIZE]; classes = SplitRegexAsRList(SENDCLASSES,"[,: ]",99,false); for (rp = classes; rp != NULL; rp = rp->next) { if (SendTransaction(conn->sd,rp->item,0,CF_DONE) == -1) { CfOut(cf_error,"send","Transaction failed"); return; } } snprintf(sendbuffer,CF_MAXVARSIZE,"%s",CFD_TERMINATOR); if (SendTransaction(conn->sd,sendbuffer,0,CF_DONE) == -1) { CfOut(cf_error,"send","Transaction failed"); return; } } /********************************************************************/ void HailExec(struct cfagent_connection *conn,char *peer,char *recvbuffer,char *sendbuffer) { FILE *fp = stdout; char *sp; int n_read; if (strlen(DEFINECLASSES)) { snprintf(sendbuffer,CF_BUFSIZE,"EXEC %s -D%s",REMOTE_AGENT_OPTIONS,DEFINECLASSES); } else { snprintf(sendbuffer,CF_BUFSIZE,"EXEC %s",REMOTE_AGENT_OPTIONS); } if (SendTransaction(conn->sd,sendbuffer,0,CF_DONE) == -1) { CfOut(cf_error,"send","Transmission rejected"); ServerDisconnection(conn); return; } fp = NewStream(peer); SendClassData(conn); while (true) { memset(recvbuffer,0,CF_BUFSIZE); if ((n_read = ReceiveTransaction(conn->sd,recvbuffer,NULL)) == -1) { DestroyServerConnection(conn); break; } if (n_read == 0) { break; } if (strlen(recvbuffer) == 0) { continue; } if ((sp = strstr(recvbuffer,CFD_TERMINATOR)) != NULL) { CfFile(fp," !!\n\n"); break; } if ((sp = strstr(recvbuffer,"BAD:")) != NULL) { CfFile(fp," !! %s",recvbuffer+4); continue; } if (strstr(recvbuffer,"too soon")) { CfFile(fp," !! %s",recvbuffer); continue; } CfFile(fp," -> %s",recvbuffer); } DeleteStream(fp); } /********************************************************************/ /* Level */ /********************************************************************/ FILE *NewStream(char *name) { FILE *fp; char filename[CF_BUFSIZE]; if ( OUTPUT_DIRECTORY[0] != '\0') { snprintf(filename,CF_BUFSIZE,"%s/%s_runagent.out",OUTPUT_DIRECTORY,name); } else { snprintf(filename,CF_BUFSIZE,"%s/outputs/%s_runagent.out",CFWORKDIR,name); } if (OUTPUT_TO_FILE) { printf("Opening file...%s\n",filename); if ((fp = fopen(filename,"w")) == NULL) { CfOut(cf_error,"Unable to open file %s\n",filename); fp = stdout; } } else { fp = stdout; } return fp; } /********************************************************************/ void DeleteStream(FILE *fp) { if (fp != stdout) { fclose(fp); } } cfengine-3.2.4/src/vars.c0000644000175000017500000005565311715232734012150 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*******************************************************************/ /* */ /* vars.c */ /* */ /*******************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void ExtendList(char *scope,char *lval,void *rval,enum cfdatatype dt); static void IdempNewScalar(char *scope,char *lval,char *rval,enum cfdatatype dt); static void DeleteAllVariables(char *scope); static int IsCf3Scalar(char *str); /*******************************************************************/ void LoadSystemConstants() { NewScalar("const","dollar","$",cf_str); NewScalar("const","n","\n",cf_str); NewScalar("const","r","\r",cf_str); NewScalar("const","t","\t",cf_str); NewScalar("const","endl","\n",cf_str); /* NewScalar("const","0","\0",cf_str); - this cannot work */ #ifdef HAVE_NOVA Nova_EnterpriseDiscovery(); #endif } /*******************************************************************/ /* Variables */ /*******************************************************************/ void ForceScalar(char *lval,char *rval) { char rtype,*retval; if (THIS_AGENT_TYPE != cf_agent && THIS_AGENT_TYPE != cf_know) { return; } if (GetVariable("match",lval,(void *)&retval,&rtype) != cf_notype) { DeleteVariable("match",lval); } NewScalar("match",lval,rval,cf_str); Debug("Setting local variable \"match.%s\" context; $(%s) = %s\n",lval,lval,rval); } /*******************************************************************/ void NewScalar(char *scope,char *lval,char *rval,enum cfdatatype dt) { struct Rval rvald; struct Scope *ptr; Debug("NewScalar(%s,%s,%s)\n",scope,lval,rval); ptr = GetScope(scope); if (ptr == NULL) { CfOut(cf_error, "", "!! Attempt to add variable \"%s\" to non-existant scope \"%s\" - ignored", lval, scope); return; } // Newscalar allocates memory through NewAssoc if (GetVariable(scope,lval,&rvald.item,&rvald.rtype) != cf_notype) { DeleteScalar(scope,lval); } AddVariableHash(scope,lval,rval,CF_SCALAR,dt,NULL,0); } /*******************************************************************/ static void IdempNewScalar(char *scope,char *lval,char *rval,enum cfdatatype dt) { struct Rval rvald; Debug("IdempNewScalar(%s,%s,%s)\n",scope,lval,rval); if (GetVariable(scope,lval,&rvald.item,&rvald.rtype) != cf_notype) { return; } AddVariableHash(scope,lval,rval,CF_SCALAR,dt,NULL,0); } /*******************************************************************/ void DeleteScalar(char *scope_name, char *lval) { struct Scope *scope = GetScope(scope_name); if (scope == NULL) { return; } if (HashDeleteElement(scope->hashtable, lval) == false) { Debug("Attempt to delete non-existent variable %s in scope %s\n", lval, scope_name); } } /*******************************************************************/ void NewList(char *scope,char *lval,void *rval,enum cfdatatype dt) { char *sp1; struct Rval rvald; if (GetVariable(scope,lval,&rvald.item,&rvald.rtype) != cf_notype) { DeleteVariable(scope,lval); } sp1 = strdup(lval); AddVariableHash(scope,sp1,rval,CF_LIST,dt,NULL,0); } /*******************************************************************/ static void ExtendList(char *scope,char *lval,void *rval,enum cfdatatype dt) { struct Rval rvald; struct Rlist *list,*rp; if (GetVariable(scope,lval,&rvald.item,&rvald.rtype) != cf_notype) { list = rvald.item; switch(rvald.rtype) { case CF_SCALAR: IdempAppendRlist(&list,rval,CF_SCALAR); break; case CF_LIST: for (rp = rval; rp != NULL; rp = rp->next) { IdempAppendRlist(&list,rval,CF_SCALAR); } break; case CF_FNCALL: rp = IdempAppendRScalar(&list,"dummy",CF_SCALAR); free(rp->item); rp->item = rval; rp->type = CF_FNCALL; break; default: CfOut(cf_error,"","Attempt to extend a list with something unknown"); break; } } else { NewList(scope,lval,rval,dt); } } /*******************************************************************/ enum cfdatatype GetVariable(const char *scope, const char *lval, void **returnv, char *rtype) { struct Scope *ptr = NULL; char scopeid[CF_MAXVARSIZE],vlval[CF_MAXVARSIZE],sval[CF_MAXVARSIZE]; char expbuf[CF_EXPANDSIZE]; CfAssoc *assoc; Debug("\nGetVariable(%s,%s) type=(to be determined)\n",scope,lval); if (lval == NULL) { *returnv = (void*)lval; *rtype = CF_SCALAR; return cf_notype; } if (!IsExpandable(lval)) { strncpy(sval,lval,CF_MAXVARSIZE-1); } else { if (ExpandScalar(lval,expbuf)) { strncpy(sval,expbuf,CF_MAXVARSIZE-1); } else { *returnv = (void*)lval; *rtype = CF_SCALAR; Debug("Couldn't expand array-like variable (%s) due to undefined dependencies\n",lval); return cf_notype; } } if (IsQualifiedVariable(sval)) { scopeid[0] = '\0'; sscanf(sval,"%[^.].%s",scopeid,vlval); Debug("Variable identifier %s is prefixed with scope id %s\n",vlval,scopeid); ptr = GetScope(scopeid); } else { strcpy(vlval,sval); strcpy(scopeid,scope); } Debug("Looking for %s.%s\n",scopeid,vlval); if (ptr == NULL) { /* Assume current scope */ strcpy(vlval,lval); ptr = GetScope(scopeid); } if (ptr == NULL) { Debug("Scope for variable \"%s.%s\" does not seem to exist\n",scope,lval); *returnv = (void*)lval; *rtype = CF_SCALAR; return cf_notype; } Debug("GetVariable(%s,%s): using scope '%s' for variable '%s'\n",scopeid,vlval,ptr->scope,vlval); assoc = HashLookupElement(ptr->hashtable, vlval); if (assoc == NULL) { Debug("No such variable found %s.%s\n\n",scopeid,lval); *returnv = (void*)lval; *rtype = CF_SCALAR; return cf_notype; } Debug("return final variable type=%s, value={\n",CF_DATATYPES[assoc->dtype]); if (DEBUG) { ShowRval(stdout,assoc->rval,assoc->rtype); } Debug("}\n"); *returnv = assoc->rval; *rtype = assoc->rtype; return assoc->dtype; } /*******************************************************************/ void DeleteVariable(char *scope,char *id) { struct Scope *ptr = GetScope(scope); if (ptr == NULL) { return; } if (HashDeleteElement(ptr->hashtable, id) == false) { Debug("No variable matched %s\n",id); } } /*******************************************************************/ int CompareVariable(const char *lval,struct CfAssoc *ap) { if (ap == NULL || lval == NULL) { return 1; } return strcmp(ap->lval,lval); } /*******************************************************************/ int CompareVariableValue(void *rval,char rtype,struct CfAssoc *ap) { struct Rlist *list, *rp; if (ap == NULL || rval == NULL) { return 1; } switch (rtype) { case CF_SCALAR: return strcmp(ap->rval,rval); case CF_LIST: list = (struct Rlist *)rval; for (rp = list; rp != NULL; rp=rp->next) { if (!CompareVariableValue(rp->item,rp->type,ap)) { return -1; } } return 0; default: return 0; } return strcmp(ap->rval,rval); } /*******************************************************************/ int UnresolvedVariables(struct CfAssoc *ap,char rtype) { struct Rlist *list, *rp; if (ap == NULL) { return false; } switch (rtype) { case CF_SCALAR: return IsCf3VarString(ap->rval); case CF_LIST: list = (struct Rlist *)ap->rval; for (rp = list; rp != NULL; rp=rp->next) { if (IsCf3VarString(rp->item)) { return true; } } return false; default: return false; } } /*******************************************************************/ int UnresolvedArgs(struct Rlist *args) { struct Rlist *rp; for (rp = args; rp != NULL; rp = rp->next) { if (rp->type != CF_SCALAR) { return true; } if (IsCf3Scalar(rp->item)) { return true; } } return false; } /*******************************************************************/ static void DeleteAllVariables(char *scope) { struct Scope *ptr; ptr = GetScope(scope); HashClear(ptr->hashtable); } /******************************************************************/ int StringContainsVar(char *s,char *v) { char varstr[CF_MAXVARSIZE]; if (s == NULL) { return false; } snprintf(varstr,CF_MAXVARSIZE-1,"${%s}",v); if (strstr(s,varstr) != NULL) { return true; } snprintf(varstr,CF_MAXVARSIZE-1,"$(%s)",v); if (strstr(s,varstr) != NULL) { return true; } snprintf(varstr,CF_MAXVARSIZE-1,"@{%s}",v); if (strstr(s,varstr) != NULL) { return true; } snprintf(varstr,CF_MAXVARSIZE-1,"@(%s)",v); if (strstr(s,varstr) != NULL) { return true; } return false; } /*********************************************************************/ int IsCf3VarString(char *str) { char *sp; char left = 'x', right = 'x'; int dollar = false; int bracks = 0, vars = 0; Debug1("IsCf3VarString(%s) - syntax verify\n",str); if (str == NULL) { return false; } for (sp = str; *sp != '\0' ; sp++) /* check for varitems */ { switch (*sp) { case '$': case '@': if (*(sp+1) == '{' || *(sp+1) == '(') { dollar = true; } break; case '(': case '{': if (dollar) { left = *sp; bracks++; } break; case ')': case '}': if (dollar) { bracks--; right = *sp; } break; } /* Some chars cannot be in variable ids, e.g. $(/bin/cat file) is legal in bash */ if (bracks > 0) { switch (*sp) { case '/': return false; } } if (left == '(' && right == ')' && dollar && (bracks == 0)) { vars++; dollar=false; } if (left == '{' && right == '}' && dollar && (bracks == 0)) { vars++; dollar = false; } } if (dollar && (bracks != 0)) { char output[CF_BUFSIZE]; snprintf(output,CF_BUFSIZE,"Broken variable syntax or bracket mismatch in string (%s)",str); yyerror(output); return false; } Debug("Found %d variables in (%s)\n",vars,str); return vars; } /*********************************************************************/ static int IsCf3Scalar(char *str) { char *sp; char left = 'x', right = 'x'; int dollar = false; int bracks = 0, vars = 0; Debug1("IsCf3Scalar(%s) - syntax verify\n",str); if (str == NULL) { return false; } for (sp = str; *sp != '\0' ; sp++) /* check for varitems */ { switch (*sp) { case '$': if (*(sp+1) == '{' || *(sp+1) == '(') { dollar = true; } break; case '(': case '{': if (dollar) { left = *sp; bracks++; } break; case ')': case '}': if (dollar) { bracks--; right = *sp; } break; } /* Some chars cannot be in variable ids, e.g. $(/bin/cat file) is legal in bash */ if (bracks > 0) { switch (*sp) { case '/': return false; } } if (left == '(' && right == ')' && dollar && (bracks == 0)) { vars++; dollar=false; } if (left == '{' && right == '}' && dollar && (bracks == 0)) { vars++; dollar = false; } } if (dollar && (bracks != 0)) { char output[CF_BUFSIZE]; snprintf(output,CF_BUFSIZE,"Broken scalar variable syntax or bracket mismatch in \"%s\"",str); yyerror(output); return false; } Debug("Found %d variables in (%s)\n",vars,str); return vars; } /*******************************************************************/ int DefinedVariable(char *name) { struct Rval rval; if (name == NULL) { return false; } if (GetVariable("this",name,&rval.item,&rval.rtype) == cf_notype) { return false; } return true; } /*******************************************************************/ int BooleanControl(char *scope,char *name) { char varbuf[CF_BUFSIZE], rtype; if (name == NULL) { return false; } if (GetVariable(scope,name,(void *)varbuf,&rtype) != cf_notype) { return GetBoolean(varbuf); } return false; } /*******************************************************************/ const char *ExtractInnerCf3VarString(const char *str,char *substr) { const char *sp; int bracks = 1; Debug("ExtractInnerVarString( %s ) - syntax verify\n",str); if (str == NULL || strlen(str) == 0) { return NULL; } memset(substr,0,CF_BUFSIZE); if (*(str+1) != '(' && *(str+1) != '{') { return NULL; } /* Start this from after the opening $( */ for (sp = str+2; *sp != '\0' ; sp++) /* check for varitems */ { switch (*sp) { case '(': case '{': bracks++; break; case ')': case '}': bracks--; break; default: if (isalnum((int)*sp) || strchr("_[]$.:-", *sp)) { } else { Debug("Illegal character found: '%c'\n", *sp); Debug("Illegal character somewhere in variable \"%s\" or nested expansion",str); } } if (bracks == 0) { strncpy(substr,str+2,sp-str-2); Debug("Returning substring value %s\n",substr); return substr; } } if (bracks != 0) { char output[CF_BUFSIZE]; if (strlen(substr) > 0) { snprintf(output,CF_BUFSIZE,"Broken variable syntax or bracket mismatch - inner (%s/%s)",str,substr); yyerror(output); } return NULL; } return sp-1; } /*********************************************************************/ const char *ExtractOuterCf3VarString(const char *str, char *substr) /* Should only by applied on str[0] == '$' */ { const char *sp; int dollar = false; int bracks = 0, onebrack = false; int nobracks = true; Debug("ExtractOuterVarString(\"%s\") - syntax verify\n",str); memset(substr,0,CF_BUFSIZE); for (sp = str; *sp != '\0' ; sp++) /* check for varitems */ { switch (*sp) { case '$': dollar = true; switch (*(sp+1)) { case '(': case '{': break; default: /* Stray dollar not a variable */ return NULL; } break; case '(': case '{': bracks++; onebrack = true; nobracks = false; break; case ')': case '}': bracks--; break; } if (dollar && (bracks == 0) && onebrack) { strncpy(substr,str,sp-str+1); Debug("Extracted outer variable |%s|\n",substr); return substr; } } if (dollar == false) { return str; /* This is not a variable*/ } if (bracks != 0) { char output[CF_BUFSIZE]; snprintf(output,CF_BUFSIZE,"Broken variable syntax or bracket mismatch in - outer (%s/%s)",str,substr); yyerror(output); return NULL; } /* Return pointer to first position in string (shouldn't happen) as long as we only call this function from the first $ position */ return str; } /*********************************************************************/ int IsQualifiedVariable(char *var) { int isarraykey = false; char *sp; for (sp = var; *sp != '\0'; sp++) { if (*sp == '[') { isarraykey = true; } if (isarraykey) { return false; } else { if (*sp == '.') { return true; } } } return false; } /*********************************************************************/ int IsCfList(char *type) { char *listTypes[] = { "sl", "il", "rl", "ml", NULL }; int i; for(i = 0; listTypes[i] != NULL; i++) { if(strcmp(type, listTypes[i]) == 0) { return true; } } return false; } /*******************************************************************/ int AddVariableHash(char *scope,char *lval,void *rval,char rtype,enum cfdatatype dtype,char *fname,int lineno) { struct Scope *ptr; struct Rlist *rp; struct CfAssoc *assoc; if (rtype == CF_SCALAR) { Debug("AddVariableHash(%s.%s=%s (%s) rtype=%c)\n",scope,lval,rval,CF_DATATYPES[dtype],rtype); } else { Debug("AddVariableHash(%s.%s=(list) (%s) rtype=%c)\n",scope,lval,CF_DATATYPES[dtype],rtype); } if (lval == NULL || scope == NULL) { CfOut(cf_error,"","scope.value = %s.%s = %s",scope,lval,rval); ReportError("Bad variable or scope in a variable assignment"); FatalError("Should not happen - forgotten to register a function call in fncall.c?"); } if (rval == NULL) { Debug("No value to assignment - probably a parameter in an unused bundle/body\n"); return false; } if (strlen(lval) > CF_MAXVARSIZE) { ReportError("variable lval too long"); return false; } /* If we are not expanding a body template, check for recursive singularities */ if (strcmp(scope,"body") != 0) { switch (rtype) { case CF_SCALAR: if (StringContainsVar((char *)rval,lval)) { CfOut(cf_error,"","Scalar variable %s.%s contains itself (non-convergent): %s",scope,lval,(char *)rval); return false; } break; case CF_LIST: for (rp = rval; rp != NULL; rp=rp->next) { if (StringContainsVar((char *)rp->item,lval)) { CfOut(cf_error,"","List variable %s contains itself (non-convergent)",lval); return false; } } break; } } ptr = GetScope(scope); if (ptr == NULL) { return false; } // Look for outstanding lists in variable rvals if (THIS_AGENT_TYPE == cf_common) { struct Rlist *listvars = NULL, *scalarvars = NULL; if (strcmp(CONTEXTID,"this") != 0) { ScanRval(CONTEXTID,&scalarvars,&listvars,rval,rtype,NULL); if (listvars != NULL) { CfOut(cf_error,""," !! Redefinition of variable \"%s\" (embedded list in RHS) in context \"%s\"",lval,CONTEXTID); } DeleteRlist(scalarvars); DeleteRlist(listvars); } } assoc = HashLookupElement(ptr->hashtable, lval); if (assoc) { if (CompareVariableValue(rval, rtype, assoc) == 0) { /* Identical value, keep as is */ } else { /* Different value, bark and replace */ if (!UnresolvedVariables(assoc, rtype)) { CfOut(cf_inform,""," !! Duplicate selection of value for variable \"%s\" in scope %s",lval,ptr->scope); if (fname) { CfOut(cf_inform,""," !! Rule from %s at/before line %d\n",fname,lineno); } else { CfOut(cf_inform,""," !! in bundle parameterization\n",fname,lineno); } } DeleteRvalItem(assoc->rval, assoc->rtype); assoc->rval = CopyRvalItem(rval, rtype); assoc->rtype = rtype; assoc->dtype = dtype; Debug("Stored \"%s\" in context %s\n",lval,scope); } } else { if (!HashInsertElement(ptr->hashtable, lval, rval, rtype, dtype)) { FatalError("Hash table is full"); } } Debug("Added Variable %s in scope %s with value (omitted)\n",lval,scope); return true; } /*******************************************************************/ void DeRefListsInHashtable(char *scope,struct Rlist *namelist,struct Rlist *dereflist) // Go through scope and for each variable in name-list, replace with a // value from the deref "lol" (list of lists) clock { int len; struct Scope *ptr; struct Rlist *rp,*state; struct CfAssoc *cplist; HashIterator i; CfAssoc *assoc; if ((len = RlistLen(namelist)) != RlistLen(dereflist)) { CfOut(cf_error,""," !! Name list %d, dereflist %d\n",len, RlistLen(dereflist)); FatalError("Software Error DeRefLists... correlated lists not same length"); } if (len == 0) { return; } ptr = GetScope(scope); i = HashIteratorInit(ptr->hashtable); while ((assoc = HashIteratorNext(&i))) { for (rp = dereflist; rp != NULL; rp = rp->next) { cplist = (struct CfAssoc *)rp->item; if (strcmp(cplist->lval,assoc->lval) == 0) { /* Link up temp hash to variable lol */ state = (struct Rlist *)(cplist->rval); if (rp->state_ptr == NULL || rp->state_ptr->type == CF_FNCALL) { /* Unexpanded function, or blank variable must be skipped.*/ return; } if (rp->state_ptr) { Debug("Rewriting expanded type for %s from %s to %s\n",assoc->lval,CF_DATATYPES[assoc->dtype],rp->state_ptr->item); // must first free existing rval in scope, then allocate new (should always be string) DeleteRvalItem(assoc->rval,assoc->rtype); // avoids double free - borrowing value from lol (freed in DeleteScope()) assoc->rval = strdup(rp->state_ptr->item); } switch(assoc->dtype) { case cf_slist: assoc->dtype = cf_str; assoc->rtype = CF_SCALAR; break; case cf_ilist: assoc->dtype = cf_int; assoc->rtype = CF_SCALAR; break; case cf_rlist: assoc->dtype = cf_real; assoc->rtype = CF_SCALAR; break; } Debug(" to %s\n",CF_DATATYPES[assoc->dtype]); } } } } cfengine-3.2.4/src/verify_environments.c0000644000175000017500000000417211715232734015276 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: verify_environments.c */ /* */ /* Created: Mon May 17 08:50:59 2010 */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*****************************************************************************/ void VerifyEnvironmentsPromise(struct Promise *pp) { #ifdef HAVE_NOVA Nova_VerifyEnvironmentsPromise(pp); #else CfOut(cf_inform,""," !! Environments promises are not available in the Community Edition of Cfengine"); #endif } /*****************************************************************************/ /* Level */ /*****************************************************************************/ cfengine-3.2.4/src/mod_exec.c0000644000175000017500000001026611715232734012747 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_exec.c */ /* */ /*****************************************************************************/ /* This file can act as a template for adding functionality to cfengine 3. All functionality can be added by extending the main array CF_MOD_SUBTYPES[CF3_MODULES] and its array dimension, in mod_common, in the manner shown here. */ #define CF3_MOD_EXEC #include "cf3.defs.h" #include "cf3.extern.h" /***********************************************************/ /* Read this module file backwards, as dependencies have */ /* to be defined first - these arrays declare pairs of */ /* constraints */ /* */ /* lval => rval */ /* */ /* in the form (lval,type,range) */ /* */ /* If the type is cf_body then the range is a pointer */ /* to another array of pairs, like in a body "sub-routine" */ /* */ /***********************************************************/ /***************************************************************/ struct BodySyntax CF_EXECCONTAIN_BODY[] = { {"useshell",cf_opts,CF_BOOL,"true/false embed the command in a shell environment (true)"}, {"umask",cf_opts,"0,77,22,27,72,077,022,027,072","The umask value for the child process"}, {"exec_owner",cf_str,"","The user name or id under which to run the process"}, {"exec_group",cf_str,"","The group name or id under which to run the process"}, {"exec_timeout",cf_int,"1,3600","Timeout in seconds for command completion"}, {"chdir",cf_str,CF_ABSPATHRANGE,"Directory for setting current/base directory for the process"}, {"chroot",cf_str,CF_ABSPATHRANGE,"Directory of root sandbox for process"}, {"preview",cf_opts,CF_BOOL,"true/false preview command when running in dry-run mode (with -n)"}, {"no_output",cf_opts,CF_BOOL,"true/false discard all output from the command"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the primary set of constraints for an exec object */ struct BodySyntax CF_EXEC_BODIES[] = { {"args",cf_str,"","Alternative string of arguments for the command (concatenated with promiser string)"}, {"contain",cf_body,CF_EXECCONTAIN_BODY,"Containment options for the execution process"}, {"module",cf_opts,CF_BOOL,"true/false whether to expect the cfengine module protocol"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_EXEC_SUBTYPES[] = { {"agent","commands",CF_EXEC_BODIES}, {NULL,NULL,NULL}, }; cfengine-3.2.4/src/mod_process.c0000644000175000017500000001312211715232734013473 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_process.c */ /* */ /*****************************************************************************/ /* This file can act as a template for adding functionality to cfengine 3. All functionality can be added by extending the main array CF_MOD_SUBTYPES[CF3_MODULES] and its array dimension, in mod_common, in the manner shown here. */ #define CF3_MOD_PROCESS #include "cf3.defs.h" #include "cf3.extern.h" /***********************************************************/ /* Read this module file backwards, as dependencies have */ /* to be defined first - these arrays declare pairs of */ /* constraints */ /* */ /* lval => rval */ /* */ /* in the form (lval,type,range) */ /* */ /* If the type is cf_body then the range is a pointer */ /* to another array of pairs, like in a body "sub-routine" */ /* */ /***********************************************************/ struct BodySyntax CF_MATCHCLASS_BODY[] = { {"in_range_define",cf_slist,"","List of classes to define if the matches are in range"}, {"match_range",cf_irange,CF_VALRANGE,"Integer range for acceptable number of matches for this process"}, {"out_of_range_define",cf_slist,"","List of classes to define if the matches are out of range"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ struct BodySyntax CF_PROCFILTER_BODY[] = { {"command",cf_str,"","Regular expression matching the command/cmd field of a process"}, {"pid",cf_irange,CF_VALRANGE,"Range of integers matching the process id of a process"}, {"pgid",cf_irange,CF_VALRANGE,"Range of integers matching the parent group id of a process"}, {"ppid",cf_irange,CF_VALRANGE,"Range of integers matching the parent process id of a process"}, {"priority",cf_irange,"-20,+20","Range of integers matching the priority field (PRI/NI) of a process"}, {"process_owner",cf_slist,"","List of regexes matching the user of a process"}, {"process_result",cf_str,"[(process_owner|pid|ppid||pgid|rsize|vsize|status|command|ttime|stime|tty|priority|threads)[|&!.]*]*","Boolean class expression returning the logical combination of classes set by a process selection test"}, {"rsize",cf_irange,CF_VALRANGE,"Range of integers matching the resident memory size of a process, in kilobytes"}, {"status",cf_str,"","Regular expression matching the status field of a process"}, {"stime_range",cf_irange,CF_TIMERANGE,"Range of integers matching the start time of a process"}, {"ttime_range",cf_irange,CF_TIMERANGE,"Range of integers matching the total elapsed time of a process"}, {"tty",cf_str,"","Regular expression matching the tty field of a process"}, {"threads",cf_irange,CF_VALRANGE,"Range of integers matching the threads (NLWP) field of a process"}, {"vsize",cf_irange,CF_VALRANGE,"Range of integers matching the virtual memory size of a process, in kilobytes"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the primary set of constraints for an exec object */ struct BodySyntax CF_PROCESS_BODIES[] = { {"process_count",cf_body,CF_MATCHCLASS_BODY,"Criteria for constraining the number of processes matching other criteria"}, {"process_select",cf_body,CF_PROCFILTER_BODY,"Criteria for matching processes in the system process table"}, {"process_stop",cf_str,CF_ABSPATHRANGE,"A command used to stop a running process"}, {"restart_class",cf_str,CF_IDRANGE,"A class to be defined globally if the process is not running, so that a command: rule can be referred to restart the process"}, {"signals",cf_olist,CF_SIGNALRANGE,"A list of menu options representing signals to be sent to a process"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_PROCESS_SUBTYPES[] = { {"agent","processes",CF_PROCESS_BODIES}, {NULL,NULL,NULL}, }; cfengine-3.2.4/src/cf3lex.l.in0000644000175000017500000001456411715232734012773 00000000000000%{ /* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*******************************************************************/ /* */ /* LEXER for cfengine 3 */ /* */ /*******************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #include "cf3parse.h" // Do not use lex - flex only %} @NOWRAP@ space [ \t]+ newline ([\n]|[\xd][\xa]) comment #[^\n]* promises bundle body body nakedvar [$@][(][a-zA-Z0-9_\200-\377.]+[)]|[$@][{][a-zA-Z0-9_\200-\377.]+[}] id [a-zA-Z0-9_\200-\377]+ assign => arrow -> /* * Three types of quoted strings: * * - string in double quotes, starts with double quote, runs until another * double quote, \" masks the double quote. * - string in single quotes, starts with single quote, runs until another * single quote, \' masks the single quote. * - string in backquotes, starts with backquote, runs until another backquote. * * The same rule formatted for the better readability: * * := \" \" | \' \' | ` ` * = * * = \\ | [^"\\] * = * * = \\ | [^'\\] * = * * = [^`] * = . | \n * */ qstring \"((\\(.|\n))|[^"\\])*\"|\'((\\(.|\n))|[^'\\])*\'|`[^`]*` class [.|&!()a-zA-Z0-9_\200-\377]+:: category [a-zA-Z_]+: %% {newline} { P.line_no++; P.line_pos = 0; } {promises} { /* Note this has to come before "id" since it is a subset of id */ if (P.currentclasses != NULL) { free(P.currentclasses); P.currentclasses = NULL; } P.line_pos += strlen(yytext); return BUNDLE; } {body} { /* Note this has to come before "id" since it is a subset of id */ if (P.currentclasses != NULL) { free(P.currentclasses); P.currentclasses = NULL; } P.line_pos += strlen(yytext); return BODY; } {id} { P.line_pos += strlen(yytext); if (strlen(yytext) > CF_MAXVARSIZE-1) { yyerror("identifier too long"); } strncpy(P.currentid,yytext,CF_MAXVARSIZE); return ID; } {assign} { P.line_pos += strlen(yytext); return ASSIGN; } {arrow} { P.line_pos += strlen(yytext); return ARROW; } {class} { P.line_pos += strlen(yytext); if (P.currentclasses != NULL) { free(P.currentclasses); } yytext[strlen(yytext)-2] = '\0'; ValidateClassSyntax(yytext); P.currentclasses = strdup(yytext); return CLASS; } {category} { P.line_pos += strlen(yytext); yytext[strlen(yytext)-1] = '\0'; strncpy(P.currenttype,yytext,CF_MAXVARSIZE); if (P.currentclasses != NULL) { free(P.currentclasses); P.currentclasses = NULL; } return CATEGORY; } {qstring} { char *tmp = NULL; int less = 0; P.line_pos += strlen(yytext); if ((tmp = malloc(strlen(yytext)+1)) == NULL) { FatalError("Malloc failure in parsing"); } if ((less = DeEscapeQuotedString(yytext,tmp)) > 0) { yyless(less); } if (P.currentstring) { free(P.currentstring); } P.currentstring = strdup(tmp); if (THIS_AGENT_TYPE == cf_common) { IsCf3VarString(tmp); } free(tmp); return QSTRING; } {nakedvar} { P.line_pos += strlen(yytext); P.currentstring = strdup(yytext); return NAKEDVAR; } {space}+ { P.line_pos += strlen(yytext); } {comment} { } . { P.line_pos++; return yytext[0]; } %% /* EOF */ cfengine-3.2.4/src/cf.extern.h0000644000175000017500000001246111715232734013064 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifndef CFENGINE_CF_EXTERN_H #define CFENGINE_CF_EXTERN_H #include "../pub/getopt.h" #if defined HAVE_PTHREAD_H && (defined HAVE_LIBPTHREAD || defined BUILDTIN_GCC_THREAD) extern pthread_mutex_t MUTEX_SYSCALL; extern pthread_mutex_t MUTEX_LOCK; extern pthread_attr_t PTHREADDEFAULTS; extern pthread_mutex_t MUTEX_COUNT; extern pthread_mutex_t MUTEX_OUTPUT; extern pthread_mutex_t MUTEX_DBHANDLE; extern pthread_mutex_t MUTEX_POLICY; extern pthread_mutex_t MUTEX_GETADDR; extern pthread_mutex_t MUTEX_DB_LASTSEEN; extern pthread_mutex_t MUTEX_DB_REPORT; extern pthread_mutex_t MUTEX_VSCOPE; extern pthread_mutex_t MUTEX_SERVER_KEYSEEN; extern pthread_mutex_t MUTEX_SERVER_CHILDREN; # endif extern pid_t ALARM_PID; extern RSA *PRIVKEY, *PUBKEY; extern char PUBKEY_DIGEST[CF_MAXVARSIZE]; extern char BINDINTERFACE[CF_BUFSIZE]; extern struct sock ECGSOCKS[ATTR]; extern char *TCPNAMES[CF_NETATTR]; extern struct Audit *AUDITPTR; extern struct Audit *VAUDIT; extern int PR_KEPT; extern int PR_REPAIRED; extern int PR_NOTKEPT; extern char CONTEXTID[32]; extern char PADCHAR; extern struct Item *IPADDRESSES; extern char PIDFILE[CF_BUFSIZE]; extern char STR_CFENGINEPORT[16]; extern unsigned short SHORT_CFENGINEPORT; extern time_t CONNTIMEOUT; extern time_t RECVTIMEOUT; extern char CFLOCK[CF_BUFSIZE]; extern char CFLOG[CF_BUFSIZE]; extern char CFLAST[CF_BUFSIZE]; extern char LOCKDB[CF_BUFSIZE]; extern int CFSIGNATURE; /*?*/ extern char CFPUBKEYFILE[CF_BUFSIZE]; extern char CFPRIVKEYFILE[CF_BUFSIZE]; extern char CFWORKDIR[CF_BUFSIZE]; extern char AVDB[CF_MAXVARSIZE]; extern char VYEAR[]; extern char VDAY[]; extern char VMONTH[]; extern char VSHIFT[]; extern char *CLASSTEXT[]; extern char *CLASSATTRIBUTES[CF_CLASSATTR][CF_ATTRDIM]; extern char VINPUTFILE[]; extern CF_DB *AUDITDBP; extern int AUDIT; extern char REPOSCHAR; extern char PURGE; extern int CHECKSUMUPDATES; extern int ERRORCOUNT; extern time_t CFSTARTTIME; extern time_t CFINITSTARTTIME; extern struct utsname VSYSNAME; extern mode_t DEFAULTMODE; extern char *PROTOCOL[]; extern char VIPADDRESS[]; extern char VPREFIX[]; extern int VRECURSE; extern int RPCTIMEOUT; extern int SKIPIDENTIFY; extern char DEFAULTCOPYTYPE; extern char VDOMAIN[CF_MAXVARSIZE]; extern char VMAILSERVER[CF_BUFSIZE]; extern struct Item *VDEFAULTROUTE; extern char *VREPOSITORY; extern enum classes VSYSTEMHARDCLASS; extern char VFQNAME[]; extern char VUQNAME[]; extern char LOGFILE[]; extern struct Item *VNEGHEAP; extern struct Item *VDELCLASSES; extern struct Item *ABORTHEAP; extern struct Mounted *MOUNTED; /* Files systems already mounted */ extern struct Item *VSETUIDLIST; extern struct Item *SUSPICIOUSLIST; extern struct Item *SCHEDULE; extern struct Item *NONATTACKERLIST; extern struct Item *MULTICONNLIST; extern struct Item *TRUSTKEYLIST; extern struct Item *DHCPLIST; extern struct Item *ALLOWUSERLIST; extern struct Item *SKIPVERIFY; extern struct Item *ATTACKERLIST; extern struct AlphaList VHEAP; extern struct AlphaList VADDCLASSES; extern struct Rlist *PRIVCLASSHEAP; extern struct Item *VREPOSLIST; extern struct Auth *VADMIT; extern struct Auth *VDENY; extern struct Auth *VADMITTOP; extern struct Auth *VDENYTOP; extern struct Auth *VARADMIT; extern struct Auth *VARADMITTOP; extern struct Auth *VARDENY; extern struct Auth *VARDENYTOP; extern int DEBUG; extern int D1; extern int D2; extern int D3; extern int D4; extern int PARSING; extern int VERBOSE; extern int EXCLAIM; extern int INFORM; extern int LOGGING; extern int CFPARANOID; extern int DONTDO; extern int IGNORELOCK; extern int MINUSF; extern int NOSPLAY; extern char *VPSCOMM[]; extern char *VPSOPTS[]; extern char *VMOUNTCOMM[]; extern char *VMOUNTOPTS[]; extern char *VRESOLVCONF[]; extern char *VHOSTEQUIV[]; extern char *VFSTAB[]; extern char *VMAILDIR[]; extern char *VNETSTAT[]; extern char *VEXPORTS[]; extern char *VROUTE[]; extern char *VROUTEADDFMT[]; extern char *VROUTEDELFMT[]; extern char *VUNMOUNTCOMM[]; extern char *SIGNALS[]; #ifndef MINGW extern char *tzname[2]; /* see man ctime */ #endif extern int EDITFILESIZE; extern int EDITBINFILESIZE; extern int VIFELAPSED; extern int VEXPIREAFTER; extern char *OBS[CF_OBSERVABLES][2]; extern char *CF_DIGEST_TYPES[10][2]; extern int CF_DIGEST_SIZES[10]; /* Windows version constants */ extern unsigned int WINVER_MAJOR; extern unsigned int WINVER_MINOR; extern unsigned int WINVER_BUILD; #endif cfengine-3.2.4/src/files_properties.c0000644000175000017500000001106711715232734014542 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: files_properties.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*********************************************************************/ /* Files to be ignored when parsing directories */ /*********************************************************************/ /*********************************************************************/ int ConsiderFile(const char *nodename,char *path,struct Attributes attr,struct Promise *pp) { int i, suspicious = true; struct stat statbuf; char newname[CF_BUFSIZE],vbuff[CF_BUFSIZE]; const char *sp; static char *skipfiles[] = { ".", "..", "lost+found", ".cfengine.rm", NULL }; if (strlen(nodename) < 1) { CfOut(cf_error,"","Empty (null) filename detected in %s\n",path); return true; } if (IsItemIn(SUSPICIOUSLIST,nodename)) { struct stat statbuf; if (cfstat(nodename,&statbuf) != -1) { if (S_ISREG(statbuf.st_mode)) { CfOut(cf_error,"","Suspicious file %s found in %s\n",nodename,path); return false; } } } if (strcmp(nodename,"...") == 0) { CfOut(cf_verbose,"","Possible DFS/FS cell node detected in %s...\n",path); return true; } for (i = 0; skipfiles[i] != NULL; i++) { if (strcmp(nodename,skipfiles[i]) == 0) { Debug("Filename %s/%s is classified as ignorable\n",path,nodename); return false; } } if ((strcmp("[",nodename) == 0) && (strcmp("/usr/bin",path) == 0)) { if (VSYSTEMHARDCLASS == linuxx) { return true; } } suspicious = true; for (sp = nodename; *sp != '\0'; sp++) { if ((*sp > 31) && (*sp < 127)) { suspicious = false; break; } } strcpy(vbuff,path); AddSlash(vbuff); strcat(vbuff,nodename); for (sp = nodename; *sp != '\0'; sp++) /* Check for files like ".. ." */ { if ((*sp != '.') && ! isspace(*sp)) { suspicious = false; return true; } } if (cf_lstat(vbuff,&statbuf,attr,pp) == -1) { CfOut(cf_verbose,"lstat","Couldn't stat %s",vbuff); return true; } if (statbuf.st_size == 0 && ! (VERBOSE||INFORM)) /* No sense in warning about empty files */ { return false; } CfOut(cf_error,"","Suspicious looking file object \"%s\" masquerading as hidden file in %s\n",nodename,path); Debug("Filename looks suspicious\n"); if (S_ISLNK(statbuf.st_mode)) { CfOut(cf_inform,""," %s is a symbolic link\n",nodename); } else if (S_ISDIR(statbuf.st_mode)) { CfOut(cf_inform,""," %s is a directory\n",nodename); } CfOut(cf_verbose,"","[%s] has size %ld and full mode %o\n",nodename,(unsigned long)(statbuf.st_size),(unsigned int)(statbuf.st_mode)); return true; } /********************************************************************/ void SetSearchDevice(struct stat *sb,struct Promise *pp) { Debug("Registering root device as %d\n",sb->st_dev); pp->rootdevice = sb->st_dev; } /********************************************************************/ int DeviceBoundary(struct stat *sb,struct Promise *pp) { if (sb->st_dev == pp->rootdevice) { return false; } else { CfOut(cf_verbose,"","Device change from %d to %d\n",pp->rootdevice,sb->st_dev); return true; } } cfengine-3.2.4/src/cf3.server.h0000644000175000017500000000502711715232734013150 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*******************************************************************/ /* */ /* HEADER for cfServerd - Not generically includable! */ /* */ /*******************************************************************/ #ifndef CFENGINE_CF3_SERVER_H #define CFENGINE_CF3_SERVER_H #define queuesize 50 #define connection 1 #define RFC931_PORT 113 #define CF_BUFEXT 128 /**********************************************************************/ struct cfd_connection { int id_verified; int rsa_auth; int synchronized; int maproot; int trust; int sd_reply; unsigned char *session_key; unsigned char digest[EVP_MAX_MD_SIZE+1]; char hostname[CF_MAXVARSIZE]; char username[CF_MAXVARSIZE]; #ifdef MINGW char sid[CF_MAXSIDSIZE]; /* we avoid dynamically allocated buffers due to potential memory leaks */ #else uid_t uid; #endif char encryption_type; char ipaddr[CF_MAX_IP_LEN]; char output[CF_BUFSIZE*2]; /* Threadsafe output channel */ }; struct cfd_get_arg { struct cfd_connection *connect; int encrypt; int buf_size; char *replybuff; char *replyfile; }; /*******************************************************************/ /* PARSER */ /*******************************************************************/ extern char CFRUNCOMMAND[]; extern time_t CFDSTARTTIME; #ifdef RE_DUP_MAX # undef RE_DUP_MAX #endif #endif cfengine-3.2.4/src/hashes.c0000644000175000017500000001537511715232734012445 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: hashes.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void EditHashValue(char *scopeid,char *lval,void *rval); /*******************************************************************/ /* Hashes */ /*******************************************************************/ void InitHashes(struct CfAssoc **table) { int i; for (i = 0; i < CF_HASHTABLESIZE; i++) { table[i] = NULL; } } /******************************************************************/ void CopyHashes(struct CfAssoc **newhash,struct CfAssoc **oldhash) { int i; for (i = 0; i < CF_HASHTABLESIZE; i++) { newhash[i] = CopyAssoc(oldhash[i]); } } /******************************************************************/ static void EditHashValue(char *scopeid,char *lval,void *rval) { int found, slot = GetHash(lval); int i = slot; struct Scope *ptr = GetScope(scopeid); struct CfAssoc *ap; Debug("EditHashValue(%s,%s)\n",scopeid,lval); if (CompareVariable(lval,ptr->hashtable[slot]) != 0) { /* Recover from hash collision */ while (true) { i++; if (i >= CF_HASHTABLESIZE-1) { i = 0; } if (CompareVariable(lval,ptr->hashtable[i]) == 0) { found = true; break; } /* Removed autolookup in Unix environment variables - implement as getenv() fn instead */ if (i == slot) { found = false; break; } } if (!found) { Debug("No such variable found %s.%s\n",scopeid,lval); return; } } ap = ptr->hashtable[i]; ap->rval = rval; } /******************************************************************/ void DeleteHashes(struct CfAssoc **hashtable) { int i; if (hashtable) { for (i = 0; i < CF_HASHTABLESIZE; i++) { if (hashtable[i] != NULL) { DeleteAssoc(hashtable[i]); hashtable[i] = NULL; } } } } /*******************************************************************/ void PrintHashes(FILE *fp,struct CfAssoc **table,int html) { int i; if (html) { fprintf(fp,"\n"); fprintf (fp,"\n"); } for (i = 0; i < CF_HASHTABLESIZE; i++) { if (table[i] != NULL) { if (html) { fprintf (fp,"\n"); } else { fprintf (fp," %5d : %8s %c %s = ",i,CF_DATATYPES[table[i]->dtype],table[i]->rtype,table[i]->lval); ShowRval(fp,table[i]->rval,table[i]->rtype); fprintf(fp,"\n"); } } } if (html) { fprintf(fp,"
iddtypertypeidentifierRvalue
%5d %8s %c %s ",i,CF_DATATYPES[table[i]->dtype],table[i]->rtype,table[i]->lval); ShowRval(fp,table[i]->rval,table[i]->rtype); fprintf(fp,"
\n"); } } /*******************************************************************/ int GetHash(const char *name) { return OatHash(name); } /*******************************************************************/ bool HashInsertElement(CfAssoc **hashtable, const char *element, void *rval, char rtype, enum cfdatatype dtype) { int bucket = GetHash(element); int i = bucket; do { /* Collision -- this element already exists */ if (CompareVariable(element, hashtable[i]) == 0) { return false; } /* Free bucket is found */ if (hashtable[i] == NULL) { hashtable[i] = NewAssoc(element, rval, rtype, dtype); return true; } i = (i + 1) % CF_HASHTABLESIZE; } while (i != bucket); /* Hash table is full */ return false; } /*******************************************************************/ bool HashDeleteElement(CfAssoc **hashtable, const char *element) { int bucket = GetHash(element); int i = bucket; do { /* Element is found */ if (hashtable[i] && strcmp(element, hashtable[i]->lval) == 0) { DeleteAssoc(hashtable[i]); hashtable[i] = NULL; return true; } i = (i + 1) % CF_HASHTABLESIZE; } while (i != bucket); /* Looped through whole hashtable and did not find needed element */ return false; } /*******************************************************************/ CfAssoc *HashLookupElement(CfAssoc **hashtable, const char *element) { int bucket = GetHash(element); int i = bucket; do { /* Element is found */ if (CompareVariable(element, hashtable[i]) == 0) { return hashtable[i]; } i = (i + 1) % CF_HASHTABLESIZE; } while (i != bucket); /* Looped through whole hashtable and did not find needed element */ return NULL; } /*******************************************************************/ void HashClear(CfAssoc **hashtable) { int i; for (i = 0; i < CF_HASHTABLESIZE; i++) { if (hashtable[i] != NULL) { DeleteAssoc(hashtable[i]); hashtable[i] = NULL; } } } /*******************************************************************/ HashIterator HashIteratorInit(CfAssoc **hashtable) { return (HashIterator) { hashtable, 0 }; } /*******************************************************************/ CfAssoc *HashIteratorNext(HashIterator *i) { while (i->bucket < CF_HASHTABLESIZE && i->hash[i->bucket] == NULL) i->bucket++; if (i->bucket == CF_HASHTABLESIZE) { return NULL; } else { return i->hash[i->bucket++]; } } cfengine-3.2.4/src/files_editline.c0000644000175000017500000012737511715232734014155 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: files_edit_operators.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*****************************************************************************/ enum editlinetypesequence { elp_vars, elp_classes, elp_delete, elp_columns, elp_insert, elp_replace, elp_reports, elp_none }; char *EDITLINETYPESEQUENCE[] = { "vars", "classes", "delete_lines", "field_edits", "insert_lines", "replace_patterns", "reports", NULL }; static void KeepEditLinePromise(struct Promise *pp); static void VerifyLineDeletions(struct Promise *pp); static void VerifyColumnEdits(struct Promise *pp); static void VerifyPatterns(struct Promise *pp); static void VerifyLineInsertions(struct Promise *pp); static int InsertMissingLinesToRegion(struct Item **start,struct Item *begin_ptr,struct Item *end_ptr,struct Attributes a,struct Promise *pp); static int InsertMissingLinesAtLocation(struct Item **start,struct Item *begin_ptr,struct Item *end_ptr,struct Item *location,struct Item *prev,struct Attributes a,struct Promise *pp); static int DeletePromisedLinesMatching(struct Item **start,struct Item *begin,struct Item *end,struct Attributes a,struct Promise *pp); static int InsertMissingLineAtLocation(char *newline,struct Item **start,struct Item *location,struct Item *prev,struct Attributes a,struct Promise *pp); static int InsertCompoundLineAtLocation(char *newline,struct Item **start,struct Item *location,struct Item *prev,struct Attributes a,struct Promise *pp); static int ReplacePatterns(struct Item *start,struct Item *end,struct Attributes a,struct Promise *pp); static int EditColumns(struct Item *file_start,struct Item *file_end,struct Attributes a,struct Promise *pp); static int EditLineByColumn(struct Rlist **columns,struct Attributes a,struct Promise *pp); static int EditColumn(struct Rlist **columns,struct Attributes a,struct Promise *pp); static int SanityCheckInsertions(struct Attributes a); static int SanityCheckDeletions(struct Attributes a,struct Promise *pp); static int SelectLine(char *line,struct Attributes a,struct Promise *pp); static int NotAnchored(char *s); static void EditClassBanner(enum editlinetypesequence type); static int SelectRegion(struct Item *start,struct Item **begin_ptr,struct Item **end_ptr,struct Attributes a,struct Promise *pp); /*****************************************************************************/ /* Level */ /*****************************************************************************/ int ScheduleEditLineOperations(char *filename,struct Bundle *bp,struct Attributes a,struct Promise *parentp) { enum editlinetypesequence type; struct SubType *sp; struct Promise *pp; char lockname[CF_BUFSIZE]; char *bp_stack = THIS_BUNDLE; struct CfLock thislock; int pass; snprintf(lockname,CF_BUFSIZE-1,"masterfilelock-%s",filename); thislock = AcquireLock(lockname,VUQNAME,CFSTARTTIME,a,parentp,true); if (thislock.lock == NULL) { return false; } NewScope("edit"); NewScalar("edit","filename",filename,cf_str); /* Reset the done state for every call here, since bundle is reusable */ for (type = 0; EDITLINETYPESEQUENCE[type] != NULL; type++) { if ((sp = GetSubTypeForBundle(EDITLINETYPESEQUENCE[type],bp)) == NULL) { continue; } for (pp = sp->promiselist; pp != NULL; pp=pp->next) { pp->donep = false; } } for (pass = 1; pass < CF_DONEPASSES; pass++) { for (type = 0; EDITLINETYPESEQUENCE[type] != NULL; type++) { EditClassBanner(type); if ((sp = GetSubTypeForBundle(EDITLINETYPESEQUENCE[type],bp)) == NULL) { continue; } BannerSubSubType(bp->name,sp->name); THIS_BUNDLE = bp->name; SetScope(bp->name); for (pp = sp->promiselist; pp != NULL; pp=pp->next) { pp->edcontext = parentp->edcontext; pp->this_server = filename; pp->donep = &(pp->done); ExpandPromise(cf_agent,bp->name,pp,KeepEditLinePromise); if (Abort()) { THIS_BUNDLE = bp_stack; DeleteScope("edit"); YieldCurrentLock(thislock); return false; } } } } DeleteScope("edit"); SetScope(parentp->bundle); THIS_BUNDLE = bp_stack; YieldCurrentLock(thislock); return true; } /***************************************************************************/ /* Level */ /***************************************************************************/ static void EditClassBanner(enum editlinetypesequence type) { struct Item *ip; int i; if (type != elp_delete) /* Just parsed all local classes */ { return; } CfOut(cf_verbose,""," ?? Private class context\n"); for (i = 0; i < CF_ALPHABETSIZE; i++) { for (ip = VADDCLASSES.list[i]; ip != NULL; ip=ip->next) { CfOut(cf_verbose,""," ?? %s\n",ip->name); } } CfOut(cf_verbose,"","\n"); } /***************************************************************************/ static void KeepEditLinePromise(struct Promise *pp) { char *sp = NULL; if (!IsDefinedClass(pp->classes)) { CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,""," . . . . . . . . . . . . . . . \n"); CfOut(cf_verbose,""," Skipping whole next edit promise, as context %s is not relevant\n",pp->classes); CfOut(cf_verbose,""," . . . . . . . . . . . . . . . \n"); return; } if (pp->done) { // return; } if (VarClassExcluded(pp,&sp)) { CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,"",". . . . . . . . . . . . . . . . . . . . . . . . . . . . \n"); CfOut(cf_verbose,"","Skipping whole next edit promise (%s), as var-context %s is not relevant\n",pp->promiser,sp); CfOut(cf_verbose,"",". . . . . . . . . . . . . . . . . . . . . . . . . . . . \n"); return; } PromiseBanner(pp); if (strcmp("classes",pp->agentsubtype) == 0) { KeepClassContextPromise(pp); return; } if (strcmp("delete_lines",pp->agentsubtype) == 0) { VerifyLineDeletions(pp); return; } if (strcmp("field_edits",pp->agentsubtype) == 0) { VerifyColumnEdits(pp); return; } if (strcmp("insert_lines",pp->agentsubtype) == 0) { VerifyLineInsertions(pp); return; } if (strcmp("replace_patterns",pp->agentsubtype) == 0) { VerifyPatterns(pp); return; } if (strcmp("reports",pp->agentsubtype) == 0) { VerifyReportPromise(pp); return; } } /***************************************************************************/ /* Level */ /***************************************************************************/ static void VerifyLineDeletions(struct Promise *pp) { struct Item **start = &(pp->edcontext->file_start); struct Attributes a = {{0}}; struct Item *begin_ptr,*end_ptr; struct CfLock thislock; char lockname[CF_BUFSIZE]; /* *(pp->donep) = true; */ a = GetDeletionAttributes(pp); a.transaction.ifelapsed = CF_EDIT_IFELAPSED; if (!SanityCheckDeletions(a,pp)) { cfPS(cf_error,CF_INTERPT,"",pp,a," !! The promised line deletion (%s) is inconsistent",pp->promiser); return; } /* Are we working in a restricted region? */ if (!a.haveregion) { begin_ptr = CF_UNDEFINED_ITEM; end_ptr = CF_UNDEFINED_ITEM; } else if (!SelectRegion(*start,&begin_ptr,&end_ptr,a,pp)) { if (a.region.include_end || a.region.include_start) { cfPS(cf_verbose,CF_INTERPT,"",pp,a," !! The promised line deletion (%s) could not select an edit region in %s (this is a good thing, as policy suggests deleting the markers)",pp->promiser,pp->this_server); } else { cfPS(cf_inform,CF_INTERPT,"",pp,a," !! The promised line deletion (%s) could not select an edit region in %s (but the delimiters were expected in the file)",pp->promiser,pp->this_server); } return; } snprintf(lockname,CF_BUFSIZE-1,"deleteline-%s-%s",pp->promiser,pp->this_server); thislock = AcquireLock(lockname,VUQNAME,CFSTARTTIME,a,pp,true); if (thislock.lock == NULL) { return; } if (DeletePromisedLinesMatching(start,begin_ptr,end_ptr,a,pp)) { (pp->edcontext->num_edits)++; } YieldCurrentLock(thislock); } /***************************************************************************/ static void VerifyColumnEdits(struct Promise *pp) { struct Item **start = &(pp->edcontext->file_start); struct Attributes a = {{0}}; struct Item *begin_ptr,*end_ptr; struct CfLock thislock; char lockname[CF_BUFSIZE]; /* *(pp->donep) = true; */ a = GetColumnAttributes(pp); a.transaction.ifelapsed = CF_EDIT_IFELAPSED; if (a.column.column_separator == NULL) { cfPS(cf_error,CF_WARN,"",pp,a,"No field_separator in promise to edit by column for %s",pp->promiser); PromiseRef(cf_error,pp); return; } if (a.column.select_column <= 0) { cfPS(cf_error,CF_WARN,"",pp,a,"No select_field in promise to edit %s",pp->promiser); PromiseRef(cf_error,pp); return; } if (!a.column.column_value) { cfPS(cf_error,CF_WARN,"",pp,a,"No field_value is promised to column_edit %s",pp->promiser); PromiseRef(cf_error,pp); return; } /* Are we working in a restricted region? */ if (!a.haveregion) { begin_ptr = *start; end_ptr =NULL; // EndOfList(*start); } else if (!SelectRegion(*start,&begin_ptr,&end_ptr,a,pp)) { cfPS(cf_error,CF_INTERPT,"",pp,a," !! The promised column edit (%s) could not select an edit region in %s",pp->promiser,pp->this_server); return; } /* locate and split line */ snprintf(lockname,CF_BUFSIZE-1,"column-%s-%s",pp->promiser,pp->this_server); thislock = AcquireLock(lockname,VUQNAME,CFSTARTTIME,a,pp,true); if (thislock.lock == NULL) { return; } if (EditColumns(begin_ptr,end_ptr,a,pp)) { (pp->edcontext->num_edits)++; } YieldCurrentLock(thislock); } /***************************************************************************/ static void VerifyPatterns(struct Promise *pp) { struct Item **start = &(pp->edcontext->file_start); struct Attributes a = {{0}}; struct Item *begin_ptr,*end_ptr; struct CfLock thislock; char lockname[CF_BUFSIZE]; /* *(pp->donep) = true; */ CfOut(cf_verbose,""," -> Looking at pattern %s\n",pp->promiser); /* Are we working in a restricted region? */ a = GetReplaceAttributes(pp); a.transaction.ifelapsed = CF_EDIT_IFELAPSED; if (!a.replace.replace_value) { cfPS(cf_error,CF_INTERPT,"",pp,a," !! The promised pattern replace (%s) had no replacement string",pp->promiser); return; } if (!a.haveregion) { begin_ptr = *start; end_ptr = NULL; //EndOfList(*start); } else if (!SelectRegion(*start,&begin_ptr,&end_ptr,a,pp)) { cfPS(cf_error,CF_INTERPT,"",pp,a," !! The promised pattern replace (%s) could not select an edit region in %s",pp->promiser,pp->this_server); return; } snprintf(lockname,CF_BUFSIZE-1,"replace-%s-%s",pp->promiser,pp->this_server); thislock = AcquireLock(lockname,VUQNAME,CFSTARTTIME,a,pp,true); if (thislock.lock == NULL) { return; } /* Make sure back references are expanded */ if (ReplacePatterns(begin_ptr,end_ptr,a,pp)) { (pp->edcontext->num_edits)++; } DeleteScope("match"); // because this might pollute the parent promise in next iteration YieldCurrentLock(thislock); } /***************************************************************************/ static void VerifyLineInsertions(struct Promise *pp) { struct Item **start = &(pp->edcontext->file_start), *match, *prev; struct Item *begin_ptr,*end_ptr; struct Attributes a = {{0}}; struct CfLock thislock; char lockname[CF_BUFSIZE]; /* *(pp->donep) = true; */ a = GetInsertionAttributes(pp); a.transaction.ifelapsed = CF_EDIT_IFELAPSED; if (!SanityCheckInsertions(a)) { cfPS(cf_error,CF_INTERPT,"",pp,a," !! The promised line insertion (%s) breaks its own promises",pp->promiser); return; } /* Are we working in a restricted region? */ if (!a.haveregion) { begin_ptr = *start; end_ptr = NULL; //EndOfList(*start); } else if (!SelectRegion(*start,&begin_ptr,&end_ptr,a,pp)) { cfPS(cf_error,CF_INTERPT,"",pp,a," !! The promised line insertion (%s) could not select an edit region in %s",pp->promiser,pp->this_server); return; } snprintf(lockname,CF_BUFSIZE-1,"insertline-%s-%s",pp->promiser,pp->this_server); thislock = AcquireLock(lockname,VUQNAME,CFSTARTTIME,a,pp,true); if (thislock.lock == NULL) { return; } /* Are we looking for an anchored line inside the region? */ if (a.location.line_matching == NULL) { if (InsertMissingLinesToRegion(start,begin_ptr,end_ptr,a,pp)) { (pp->edcontext->num_edits)++; } } else { if (!SelectItemMatching(*start,a.location.line_matching,begin_ptr,end_ptr,&match,&prev,a.location.first_last)) { cfPS(cf_error,CF_INTERPT,"",pp,a," !! The promised line insertion (%s) could not select a locator matching regex \"%s\" in %s",pp->promiser,a.location.line_matching,pp->this_server); YieldCurrentLock(thislock); return; } if (InsertMissingLinesAtLocation(start,begin_ptr,end_ptr,match,prev,a,pp)) { (pp->edcontext->num_edits)++; } } YieldCurrentLock(thislock); } /***************************************************************************/ /* Level */ /***************************************************************************/ static int SelectRegion(struct Item *start,struct Item **begin_ptr,struct Item **end_ptr,struct Attributes a,struct Promise *pp) /* This should provide pointers to the first and last line of text that include the delimiters, since we need to include those in case they are being deleted, etc. It returns true if a match was identified, else false. If no such region matches, begin_ptr and end_ptr should point to CF_UNDEFINED_ITEM */ { struct Item *ip,*beg = CF_UNDEFINED_ITEM,*end = CF_UNDEFINED_ITEM; for (ip = start; ip != NULL; ip = ip->next) { if (a.region.select_start) { if (beg == CF_UNDEFINED_ITEM && FullTextMatch(a.region.select_start,ip->name)) { if (!a.region.include_start) { if (ip->next == NULL) { cfPS(cf_verbose,CF_INTERPT,"",pp,a," !! The promised start pattern (%s) found an empty region at the end of file %s",a.region.select_start,pp->this_server); return false; } } beg = ip; continue; } } if (a.region.select_end && beg != CF_UNDEFINED_ITEM) { if (end == CF_UNDEFINED_ITEM && FullTextMatch(a.region.select_end,ip->name)) { end = ip; break; } } if (beg != CF_UNDEFINED_ITEM && end != CF_UNDEFINED_ITEM) { break; } } *begin_ptr = beg; *end_ptr = end; if (beg == CF_UNDEFINED_ITEM && a.region.select_start) { cfPS(cf_verbose,CF_INTERPT,"",pp,a," !! The promised start pattern (%s) was not found when selecting edit region in %s",a.region.select_start,pp->this_server); return false; } /*if (end == CF_UNDEFINED_ITEM) { end = NULL; return false; } */ return true; } /***************************************************************************/ static int InsertMissingLinesToRegion(struct Item **start,struct Item *begin_ptr,struct Item *end_ptr,struct Attributes a,struct Promise *pp) { struct Item *ip, *prev = CF_UNDEFINED_ITEM; /* find prev for region */ if (IsItemInRegion(pp->promiser,begin_ptr,end_ptr,a,pp)) { cfPS(cf_verbose,CF_NOP,"",pp,a," -> Promised line \"%s\" exists within selected region of %s (promise kept)",pp->promiser,pp->this_server); return false; } if (*start == NULL) { return InsertMissingLinesAtLocation(start,begin_ptr,end_ptr,*start,prev,a,pp); } if (a.location.before_after == cfe_before) { for (ip = *start; ip != NULL; ip=ip->next) { if (ip == begin_ptr) { return InsertMissingLinesAtLocation(start,begin_ptr,end_ptr,ip,prev,a,pp); } prev = ip; } } if (a.location.before_after == cfe_after) { for (ip = *start; ip != NULL; ip=ip->next) { if (ip->next != NULL && ip->next == end_ptr) { return InsertMissingLinesAtLocation(start,begin_ptr,end_ptr,ip,prev,a,pp); } if (ip->next == NULL) { return InsertMissingLinesAtLocation(start,begin_ptr,end_ptr,ip,prev,a,pp); } prev = ip; } } return false; } /***************************************************************************/ static int InsertMissingLinesAtLocation(struct Item **start,struct Item *begin_ptr,struct Item *end_ptr,struct Item *location,struct Item *prev,struct Attributes a,struct Promise *pp) { FILE *fin; char buf[CF_BUFSIZE],exp[CF_EXPANDSIZE]; struct Item *loc = NULL; int retval = false; if (a.sourcetype && strcmp(a.sourcetype,"file") == 0) { if ((fin = fopen(pp->promiser,"r")) == NULL) { cfPS(cf_error,CF_INTERPT,"fopen",pp,a,"Could not read file %s",pp->promiser); return false; } loc = location; while (!feof(fin)) { buf[0] = '\0'; fgets(buf,CF_BUFSIZE,fin); StripTrailingNewline(buf); if (feof(fin) && strlen(buf) == 0) { break; } if (a.expandvars) { ExpandScalar(buf,exp); } else { strcpy(exp,buf); } if (!SelectLine(exp,a,pp)) { continue; } if (IsItemInRegion(exp,begin_ptr,end_ptr,a,pp)) { cfPS(cf_verbose,CF_NOP,"",pp,a," -> Promised file line \"%s\" exists within file %s (promise kept)",exp,pp->this_server); continue; } retval |= InsertCompoundLineAtLocation(exp,start,loc,prev,a,pp); if (prev && prev != CF_UNDEFINED_ITEM) { prev = prev->next; } if (loc) { loc = loc->next; } } fclose(fin); return retval; } else { int multiline = a.sourcetype && strcmp(a.sourcetype,"preserve_block") == 0; int need_insert = false; if (strchr(pp->promiser,'\n') != NULL) /* Multi-line string */ { char *sp; loc = location; for (sp = pp->promiser; sp <= pp->promiser+strlen(pp->promiser); sp++) { memset(buf,0,CF_BUFSIZE); sscanf(sp,"%[^\n]",buf); sp += strlen(buf); if (!SelectLine(buf,a,pp)) { continue; } if (IsItemInRegion(buf,begin_ptr,end_ptr,a,pp)) { cfPS(cf_verbose,CF_NOP,"",pp,a," -> Promised file line \"%s\" exists within file %s (promise kept)",buf,pp->this_server); continue; } if (!multiline) { retval |= InsertCompoundLineAtLocation(buf,start,loc,prev,a,pp); if (prev && prev != CF_UNDEFINED_ITEM) { prev = prev->next; } if (loc) { loc = loc->next; } } else { need_insert = true; } } if (need_insert) { for (sp = pp->promiser; sp <= pp->promiser+strlen(pp->promiser); sp++) { memset(buf,0,CF_BUFSIZE); sscanf(sp,"%[^\n]",buf); sp += strlen(buf); retval |= InsertCompoundLineAtLocation(buf,start,loc,prev,a,pp); if (prev && prev != CF_UNDEFINED_ITEM) { prev = prev->next; } if (loc) { loc = loc->next; } } } return retval; } else { return InsertCompoundLineAtLocation(pp->promiser,start,location,prev,a,pp); } } } /***************************************************************************/ static int DeletePromisedLinesMatching(struct Item **start,struct Item *begin,struct Item *end,struct Attributes a,struct Promise *pp) { struct Item *ip,*np = NULL,*lp,*initiator = begin,*terminator = NULL; int i,in_region = false, retval = false, matches, noedits = true; char *sp,buf[CF_BUFSIZE]; if (start == NULL) { return false; } // Get a pointer from before the region so we can patch the hole later if (begin == CF_UNDEFINED_ITEM) { initiator = *start; } else { if (a.region.include_start) { initiator = begin; } else { initiator = begin->next; } } if (end == CF_UNDEFINED_ITEM) { terminator = NULL; } else { if (a.region.include_end) { terminator = end->next; } else { terminator = end; } } // Now do the deletion for (ip = initiator; ip != terminator && ip != NULL; ip = np) { if (a.not_matching) { matches = !MatchRegion(pp->promiser,*start,ip,terminator); } else { matches = MatchRegion(pp->promiser,*start,ip,terminator); } if (matches) { CfOut(cf_verbose,""," -> Multi-line region (size %d) matched text in the file",matches); } else { CfOut(cf_verbose,""," -> Multi-line region didn't match text in the file"); } if (!SelectLine(ip->name,a,pp)) // Start search from location { np = ip->next; continue; } if (matches) { CfOut(cf_verbose,""," -> Delete chunk of %d lines\n",matches,ip->name); if (a.transaction.action == cfa_warn) { cfPS(cf_error,CF_WARN,"",pp,a," -> Need to delete line \"%s\" from %s - but only a warning was promised",ip->name,pp->this_server); np = ip->next; noedits = false; } else { for (i = 1; i <= matches; i++) { cfPS(cf_verbose,CF_CHG,"",pp,a," -> Deleting the promised line %d \"%s\" from %s",i,ip->name,pp->this_server); retval = true; noedits = false; if (ip->name != NULL) { free(ip->name); } np = ip->next; free((char *)ip); lp = ip; if (ip == *start) { if (initiator == *start) { initiator = np; } *start = np; } else { if (ip == initiator) { initiator = *start; } for (lp = initiator; lp->next != ip; lp=lp->next) { } lp->next = np; } (pp->edcontext->num_edits)++; ip = np; } } } else { np = ip->next; } } if (noedits) { cfPS(cf_verbose,CF_NOP,"",pp,a," -> No need to delete lines from %s, ok",pp->this_server); } return retval; } /********************************************************************/ static int ReplacePatterns(struct Item *file_start,struct Item *file_end,struct Attributes a,struct Promise *pp) { char replace[CF_EXPANDSIZE],line_buff[CF_EXPANDSIZE]; char before[CF_BUFSIZE],after[CF_BUFSIZE]; int match_len,start_off,end_off,once_only = false,retval = false; struct Item *ip; int notfound = true, cutoff = 1, replaced=false; if (a.replace.occurrences && (strcmp(a.replace.occurrences,"first") == 0)) { CfOut(cf_inform,"","WARNING! Setting replace-occurrences policy to \"first\" is not convergent"); once_only = true; } for (ip = file_start; ip != NULL && ip != file_end; ip=ip->next) { if (ip->name == NULL) { continue; } cutoff = 1; strncpy(line_buff,ip->name,CF_BUFSIZE); replaced = false; match_len = 0; while (BlockTextMatch(pp->promiser,line_buff,&start_off,&end_off)) { if (match_len == strlen(line_buff)) { CfOut(cf_verbose,""," -> Improper convergent expression matches defacto convergence, so accepting"); break; } if (cutoff++ > CF_MAX_REPLACE) { CfOut(cf_verbose,""," !! Too many replacements on this line"); break; } match_len = end_off - start_off; ExpandScalar(a.replace.replace_value,replace); CfOut(cf_verbose,""," -> Verifying replacement of \"%s\" with \"%s\" (%d)\n",pp->promiser,replace,cutoff); before[0] = after[0] = '\0'; // Model the partial substitution in line_buff to check convergence strncat(before,line_buff,start_off); strncat(after,line_buff+end_off,sizeof(after) - 1); snprintf(line_buff,CF_EXPANDSIZE-1,"%s%s",before,replace); notfound = false; replaced = true; // Model the full substitution in line_buff snprintf(line_buff,CF_EXPANDSIZE-1,"%s%s%s",before,replace,after); if (once_only) { CfOut(cf_verbose,""," -> Replace first occurrence only (warning, this is not a convergent policy)"); break; } } if (NotAnchored(pp->promiser) && BlockTextMatch(pp->promiser,line_buff,&start_off,&end_off)) { cfPS(cf_error,CF_INTERPT,"",pp,a," -> Promised replacement \"%s\" on line \"%s\" for pattern \"%s\" is not convergent while editing %s",line_buff,ip->name,pp->promiser,pp->this_server); CfOut(cf_error,"","Because the regular expression \"%s\" still matches the replacement string \"%s\"",pp->promiser,line_buff); PromiseRef(cf_error,pp); break; } if (a.transaction.action == cfa_warn) { cfPS(cf_verbose,CF_WARN,"",pp,a," -> Need to replace line \"%s\" in %s - but only a warning was promised",pp->promiser,pp->this_server); continue; } else if (replaced) { free(ip->name); ip->name = strdup(line_buff); cfPS(cf_verbose,CF_CHG,"",pp,a," -> Replaced pattern \"%s\" in %s",pp->promiser,pp->this_server); (pp->edcontext->num_edits)++; retval = true; CfOut(cf_verbose,""," -> << (%d)\"%s\"\n",cutoff,ip->name); CfOut(cf_verbose,""," -> >> (%d)\"%s\"\n",cutoff,line_buff); if (once_only) { CfOut(cf_verbose,""," -> Replace first occurrence only (warning, this is not a convergent policy)"); break; } if (BlockTextMatch(pp->promiser,ip->name,&start_off,&end_off)) { cfPS(cf_inform,CF_INTERPT,"",pp,a," -> Promised replacement \"%s\" for pattern \"%s\" is not properly convergent while editing %s",ip->name,pp->promiser,pp->this_server); CfOut(cf_inform,"","Because the regular expression \"%s\" still matches the end-state replacement string \"%s\"",pp->promiser,line_buff); PromiseRef(cf_inform,pp); } } } if (notfound) { cfPS(cf_verbose,CF_NOP,"",pp,a," -> No pattern \"%s\" in %s",pp->promiser,pp->this_server); } return retval; } /********************************************************************/ static int EditColumns(struct Item *file_start,struct Item *file_end,struct Attributes a,struct Promise *pp) { char separator[CF_MAXVARSIZE]; int s,e,retval = false; struct Item *ip; struct Rlist *columns = NULL; if (!ValidateRegEx(pp->promiser)) { return false; } for (ip = file_start; ip != file_end; ip=ip->next) { if (ip->name == NULL) { continue; } if (!FullTextMatch(pp->promiser,ip->name)) { continue; } else { CfOut(cf_verbose,""," - Matched line (%s)\n",ip->name); } if (!BlockTextMatch(a.column.column_separator,ip->name,&s,&e)) { cfPS(cf_verbose,CF_INTERPT,"",pp,a," ! Field edit - no fields found by promised pattern %s in %s",a.column.column_separator,pp->this_server); return false; } if (e-s > CF_MAXVARSIZE / 2) { CfOut(cf_error,""," !! Line split criterion matches a huge part of the line -- seems to be in error"); return false; } strncpy(separator,ip->name+s,e-s); separator[e-s]='\0'; columns = SplitRegexAsRList(ip->name,a.column.column_separator,CF_INFINITY,a.column.blanks_ok); retval = EditLineByColumn(&columns,a,pp); if (retval) { free(ip->name); ip->name = Rlist2String(columns,separator); } DeleteRlist(columns); } return retval; } /***************************************************************************/ static int SanityCheckInsertions(struct Attributes a) { long not = 0; long with = 0; long ok = true; struct Rlist *rp; enum insert_match opt; int exact = false, ignore_something = false; int multiline = a.sourcetype && strcmp(a.sourcetype,"preserve_block") == 0; if (a.line_select.startwith_from_list) { with++; } if (a.line_select.not_startwith_from_list) { not++; } if (a.line_select.match_from_list) { with++; } if (a.line_select.not_match_from_list) { not++; } if (a.line_select.contains_from_list) { with++; } if (a.line_select.not_contains_from_list) { not++; } if (not > 1) { CfOut(cf_error,""," !! Line insertion selection promise is meaningless - the alternatives are mutually exclusive (only one is allowed)"); ok = false; } if (with && not) { CfOut(cf_error,""," !! Line insertion selection promise is meaningless - cannot mix positive and negative constraints"); ok = false; } for (rp = a.insert_match; rp != NULL; rp=rp->next) { opt = String2InsertMatch(rp->item); switch (opt) { case cf_exact_match: exact = true; break; default: ignore_something = true; if (multiline) { CfOut(cf_error,""," !! Line insertion should not use whitespace policy with preserve_block"); ok = false; } break; } } if (exact && ignore_something) { CfOut(cf_error,""," !! Line insertion selection promise is meaningless - cannot mix exact_match with other ignore whitespace options"); ok = false; } return ok; } /***************************************************************************/ static int SanityCheckDeletions(struct Attributes a,struct Promise *pp) { if (strchr(pp->promiser,'\n') != NULL) /* Multi-line string */ { if (a.not_matching) { CfOut(cf_error,""," !! Makes no sense to promise multi-line delete with not_matching. Cannot be satisfied for all lines as a block."); } } return true; } /***************************************************************************/ /* Level */ /***************************************************************************/ static int InsertCompoundLineAtLocation(char *newline,struct Item **start,struct Item *location,struct Item *prev,struct Attributes a,struct Promise *pp) { int result = false; char buf[CF_EXPANDSIZE]; if (strchr(newline,'\n') != NULL) /* Multi-line string */ { char *sp; for (sp = newline; sp <= newline+strlen(newline); sp++) { memset(buf,0,CF_BUFSIZE); sscanf(sp,"%2048[^\n]",buf); sp += strlen(buf); if (!SelectLine(buf,a,pp)) { continue; } result |= InsertMissingLineAtLocation(buf,start,location,prev,a,pp); } } else { result |= InsertMissingLineAtLocation(newline,start,location,prev,a,pp); } return result; } /***************************************************************************/ static int InsertMissingLineAtLocation(char *newline,struct Item **start,struct Item *location,struct Item *prev,struct Attributes a,struct Promise *pp) /* Check line neighbourhood in whole file to avoid edge effects */ { if (prev == CF_UNDEFINED_ITEM) /* Insert at first line */ { if (a.location.before_after == cfe_before) { if (*start == NULL) { if (a.transaction.action == cfa_warn) { cfPS(cf_error,CF_WARN,"",pp,a," -> Need to insert the promised line \"%s\" in %s - but only a warning was promised",newline,pp->this_server); return true; } else { PrependItemList(start,newline); (pp->edcontext->num_edits)++; cfPS(cf_verbose,CF_CHG,"",pp,a," -> Inserting the promised line \"%s\" into %s",newline,pp->this_server); return true; } } if (strcmp((*start)->name,newline) != 0) { if (a.transaction.action == cfa_warn) { cfPS(cf_error,CF_WARN,"",pp,a," -> Need to prepend the promised line \"%s\" to %s - but only a warning was promised",newline,pp->this_server); return true; } else { PrependItemList(start,newline); (pp->edcontext->num_edits)++; cfPS(cf_verbose,CF_CHG,"",pp,a," -> Prepending the promised line \"%s\" to %s",newline,pp->this_server); return true; } } else { cfPS(cf_verbose,CF_NOP,"",pp,a," -> Promised line \"%s\" exists at start of file %s (promise kept)",newline,pp->this_server); return false; } } } if (a.location.before_after == cfe_before) { if (NeighbourItemMatches(*start,location,newline,cfe_before,a,pp)) { cfPS(cf_verbose,CF_NOP,"",pp,a," -> Promised line \"%s\" exists before locator in (promise kept)",newline); return false; } else { if (a.transaction.action == cfa_warn) { cfPS(cf_error,CF_WARN,"",pp,a," -> Need to insert line \"%s\" into %s but only a warning was promised",newline,pp->this_server); return true; } else { InsertAfter(start,prev,newline); (pp->edcontext->num_edits)++; cfPS(cf_verbose,CF_CHG,"",pp,a," -> Inserting the promised line \"%s\" into %s before locator",newline,pp->this_server); return true; } } } else { if (NeighbourItemMatches(*start,location,newline,cfe_after,a,pp)) { cfPS(cf_verbose,CF_NOP,"",pp,a," -> Promised line \"%s\" exists after locator (promise kept)",newline); return false; } else { if (a.transaction.action == cfa_warn) { cfPS(cf_error,CF_WARN,"",pp,a," -> Need to insert line \"%s\" in %s but only a warning was promised",newline,pp->this_server); return true; } else { InsertAfter(start,location,newline); cfPS(cf_verbose,CF_CHG,"",pp,a," -> Inserting the promised line \"%s\" into %s after locator",newline,pp->this_server); (pp->edcontext->num_edits)++; return true; } } } } /***************************************************************************/ static int EditLineByColumn(struct Rlist **columns,struct Attributes a,struct Promise *pp) { struct Rlist *rp,*this_column = NULL; char sep[CF_MAXVARSIZE]; int i,count = 0,retval = false; /* Now break up the line into a list - not we never remove an item/column */ for (rp = *columns; rp != NULL; rp=rp->next) { count++; if (count == a.column.select_column) { CfOut(cf_verbose,""," -> Stopped at field %d\n",count); break; } } if (a.column.select_column > count) { if (!a.column.extend_columns) { cfPS(cf_error,CF_INTERPT,"",pp,a," !! The file %s has only %d fields, but there is a promise for field %d",pp->this_server,count,a.column.select_column); return false; } else { for (i = 0; i < (a.column.select_column - count); i++) { AppendRScalar(columns,strdup(""),CF_SCALAR); } count = 0; for (rp = *columns; rp != NULL; rp=rp->next) { count++; if (count == a.column.select_column) { CfOut(cf_verbose,""," -> Stopped at column/field %d\n",count); break; } } } } if (a.column.value_separator != '\0') { /* internal separator, single char so split again */ if (strcmp(rp->item,a.column.column_value) == 0) { retval = false; } else { this_column = SplitStringAsRList(rp->item,a.column.value_separator); retval = EditColumn(&this_column,a,pp); } if (retval) { if (a.transaction.action == cfa_warn) { cfPS(cf_error,CF_WARN,"",pp,a," -> Need to edit field in %s but only warning promised",pp->this_server); retval = false; } else { cfPS(cf_inform,CF_CHG,"",pp,a," -> Edited field inside file object %s",pp->this_server); (pp->edcontext->num_edits)++; free(rp->item); sep[0] = a.column.value_separator; sep[1] = '\0'; rp->item = Rlist2String(this_column,sep); } } else { cfPS(cf_verbose,CF_NOP,"",pp,a," -> No need to edit field in %s",pp->this_server); } DeleteRlist(this_column); return retval; } else { /* No separator, so we set the whole field to the value */ if (a.column.column_operation && strcmp(a.column.column_operation,"delete") == 0) { if (a.transaction.action == cfa_warn) { cfPS(cf_error,CF_WARN,"",pp,a," -> Need to delete field field value %s in %s but only a warning was promised",rp->item,pp->this_server); return false; } else { cfPS(cf_inform,CF_CHG,"",pp,a," -> Deleting column field value %s in %s",rp->item,pp->this_server); (pp->edcontext->num_edits)++; free(rp->item); rp->item = strdup(""); return true; } } else { if (a.transaction.action == cfa_warn) { cfPS(cf_error,CF_WARN,"",pp,a," -> Need to set column field value %s to %s in %s but only a warning was promised",rp->item,a.column.column_value,pp->this_server); return false; } else { cfPS(cf_inform,CF_CHG,"",pp,a," -> Setting whole column field value %s to %s in %s",rp->item,a.column.column_value,pp->this_server); free(rp->item); rp->item = strdup(a.column.column_value); (pp->edcontext->num_edits)++; return true; } } } cfPS(cf_verbose,CF_NOP,"",pp,a," -> No need to edit column field value %s in %s",a.column.column_value,pp->this_server); return false; } /***************************************************************************/ static int SelectLine(char *line,struct Attributes a,struct Promise *pp) { struct Rlist *rp,*c; int s,e; char *selector; if ((c = a.line_select.startwith_from_list)) { for (rp = c; rp != NULL; rp=rp->next) { selector = (char *)(rp->item); if (strncmp(selector,line,strlen(selector)) == 0) { return true; } } return false; } if ((c = a.line_select.not_startwith_from_list)) { for (rp = c; rp != NULL; rp=rp->next) { selector = (char *)(rp->item); if (strncmp(selector,line,strlen(selector)) == 0) { return false; } } return true; } if ((c = a.line_select.match_from_list)) { for (rp = c; rp != NULL; rp=rp->next) { selector = (char *)(rp->item); if (FullTextMatch(selector,line)) { return true; } } return false; } if ((c = a.line_select.not_match_from_list)) { for (rp = c; rp != NULL; rp=rp->next) { selector = (char *)(rp->item); if (FullTextMatch(selector,line)) { return false; } } return true; } if ((c = a.line_select.contains_from_list)) { for (rp = c; rp != NULL; rp=rp->next) { selector = (char *)(rp->item); if (BlockTextMatch(selector,line,&s,&e)) { return true; } } return false; } if ((c = a.line_select.not_contains_from_list)) { for (rp = c; rp != NULL; rp=rp->next) { selector = (char *)(rp->item); if (BlockTextMatch(selector,line,&s,&e)) { return false; } } return true; } return true; } /***************************************************************************/ /* Level */ /***************************************************************************/ static int EditColumn(struct Rlist **columns,struct Attributes a,struct Promise *pp) { struct Rlist *rp, *found; int retval = false; if (a.column.column_operation && strcmp(a.column.column_operation,"delete") == 0) { if ((found = KeyInRlist(*columns,a.column.column_value))) { CfOut(cf_inform,""," -> Deleting column field sub-value %s in %s",a.column.column_value,pp->this_server); DeleteRlistEntry(columns,found); return true; } else { return false; } } if (a.column.column_operation && strcmp(a.column.column_operation,"set") == 0) { if (RlistLen(*columns) == 1) { if (strcmp((*columns)->item,a.column.column_value) == 0) { CfOut(cf_verbose,""," -> Field sub-value set as promised\n"); return false; } } CfOut(cf_inform,""," -> Setting field sub-value %s in %s",a.column.column_value,pp->this_server); DeleteRlist(*columns); *columns = NULL; IdempPrependRScalar(columns,a.column.column_value,CF_SCALAR); return true; } if (a.column.column_operation && strcmp(a.column.column_operation,"prepend") == 0) { if (IdempPrependRScalar(columns,a.column.column_value,CF_SCALAR)) { CfOut(cf_inform,""," -> Prepending field sub-value %s in %s",a.column.column_value,pp->this_server); return true; } else { return false; } } if (a.column.column_operation && strcmp(a.column.column_operation,"alphanum") == 0) { if (IdempPrependRScalar(columns,a.column.column_value,CF_SCALAR)) { retval = true; } rp = AlphaSortRListNames(*columns); *columns = rp; return retval; } /* default operation is append */ if (IdempAppendRScalar(columns,a.column.column_value,CF_SCALAR)) { return true; } else { return false; } return false; } /********************************************************************/ static int NotAnchored(char *s) { if (*s != '^') { return true; } if (*(s+strlen(s)-1) != '$') { return true; } return false; } cfengine-3.2.4/src/crypto.c0000644000175000017500000003774611715232734012520 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: crypto.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void MD5Random (unsigned char digest[EVP_MAX_MD_SIZE+1]); static char *KeyPrint(RSA *key); /**********************************************************************/ void RandomSeed() { static unsigned char digest[EVP_MAX_MD_SIZE+1]; struct stat statbuf; char vbuff[CF_BUFSIZE]; /* Use the system database as the entropy source for random numbers */ Debug("RandomSeed() work directory is %s\n",CFWORKDIR); snprintf(vbuff,CF_BUFSIZE,"%s%crandseed",CFWORKDIR,FILE_SEPARATOR); if (cfstat(vbuff,&statbuf) == -1) { snprintf(AVDB,CF_MAXVARSIZE-1,"%s%cstate%c%s",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR,CF_AVDB_FILE); } else { strncpy(AVDB,vbuff,CF_MAXVARSIZE-1); } CfOut(cf_verbose,"","Looking for a source of entropy in %s\n",AVDB); if (!RAND_load_file(AVDB,-1)) { CfOut(cf_verbose,"","Could not read sufficient randomness from %s\n",AVDB); } while (!RAND_status()) { MD5Random(digest); RAND_seed((void *)digest,16); } } /*****************************************************************************/ void KeepKeyPromises() { unsigned long err; RSA *pair; FILE *fp; struct stat statbuf; int fd; static char *passphrase = "Cfengine passphrase"; const EVP_CIPHER *cipher; char vbuff[CF_BUFSIZE]; NewScope("common"); cipher = EVP_des_ede3_cbc(); if (cfstat(CFPUBKEYFILE,&statbuf) != -1) { CfOut(cf_cmdout,"","A key file already exists at %s\n",CFPUBKEYFILE); return; } if (cfstat(CFPRIVKEYFILE,&statbuf) != -1) { CfOut(cf_cmdout,"","A key file already exists at %s\n",CFPRIVKEYFILE); return; } printf("Making a key pair for cfengine, please wait, this could take a minute...\n"); pair = RSA_generate_key(2048,35,NULL,NULL); if (pair == NULL) { err = ERR_get_error(); CfOut(cf_error,"","Unable to generate key: %s\n",ERR_reason_error_string(err)); return; } if (DEBUG) { RSA_print_fp(stdout,pair,0); } fd = open(CFPRIVKEYFILE,O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fd < 0) { CfOut(cf_error,"open","Open %s failed: %s.",CFPRIVKEYFILE,strerror(errno)); return; } if ((fp = fdopen(fd, "w")) == NULL ) { CfOut(cf_error,"fdopen","Couldn't open private key %s.",CFPRIVKEYFILE); close(fd); return; } CfOut(cf_verbose,"","Writing private key to %s\n",CFPRIVKEYFILE); if (!PEM_write_RSAPrivateKey(fp,pair,cipher,passphrase,strlen(passphrase),NULL,NULL)) { err = ERR_get_error(); CfOut(cf_error,"","Couldn't write private key: %s\n",ERR_reason_error_string(err)); return; } fclose(fp); fd = open(CFPUBKEYFILE,O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fd < 0) { CfOut(cf_error,"open","Unable to open public key %s.",CFPUBKEYFILE); return; } if ((fp = fdopen(fd, "w")) == NULL ) { CfOut(cf_error,"fdopen","Open %s failed.",CFPUBKEYFILE); close(fd); return; } CfOut(cf_verbose,"","Writing public key to %s\n",CFPUBKEYFILE); if (!PEM_write_RSAPublicKey(fp,pair)) { err = ERR_get_error(); CfOut(cf_error,"","Unable to write public key: %s\n",ERR_reason_error_string(err)); return; } fclose(fp); snprintf(vbuff,CF_BUFSIZE,"%s/randseed",CFWORKDIR); RAND_write_file(vbuff); cf_chmod(vbuff,0644); } /*********************************************************************/ void LoadSecretKeys() { FILE *fp; static char *passphrase = "Cfengine passphrase",name[CF_BUFSIZE],source[CF_BUFSIZE]; char guard[CF_MAXVARSIZE]; unsigned char digest[EVP_MAX_MD_SIZE+1]; unsigned long err; struct stat sb; if ((fp = fopen(CFPRIVKEYFILE,"r")) == NULL) { CfOut(cf_inform,"fopen","Couldn't find a private key (%s) - use cf-key to get one",CFPRIVKEYFILE); return; } if ((PRIVKEY = PEM_read_RSAPrivateKey(fp,(RSA **)NULL,NULL,passphrase)) == NULL) { err = ERR_get_error(); CfOut(cf_error,"PEM_read","Error reading Private Key = %s\n",ERR_reason_error_string(err)); PRIVKEY = NULL; fclose(fp); return; } fclose(fp); CfOut(cf_verbose,""," -> Loaded private key %s\n",CFPRIVKEYFILE); if ((fp = fopen(CFPUBKEYFILE,"r")) == NULL) { CfOut(cf_error,"fopen","Couldn't find a public key (%s) - use cf-key to get one",CFPUBKEYFILE); return; } if ((PUBKEY = PEM_read_RSAPublicKey(fp,NULL,NULL,passphrase)) == NULL) { err = ERR_get_error(); CfOut(cf_error,"PEM_read","Error reading Private Key = %s\n",ERR_reason_error_string(err)); PUBKEY = NULL; fclose(fp); return; } CfOut(cf_verbose,""," -> Loaded public key %s\n",CFPUBKEYFILE); fclose(fp); if (BN_num_bits(PUBKEY->e) < 2 || !BN_is_odd(PUBKEY->e)) { FatalError("RSA Exponent too small or not odd"); } if (EMPTY(POLICY_SERVER)) { snprintf(name,CF_MAXVARSIZE-1,"%s%cpolicy_server.dat",CFWORKDIR,FILE_SEPARATOR); if ((fp = fopen(name,"r")) != NULL) { fscanf(fp,"%4095s",POLICY_SERVER); fclose(fp); } } /* Check that we have our own SHA key form of the key in the IP on the hub */ HashPubKey(PUBKEY,digest,CF_DEFAULT_DIGEST); snprintf(name,CF_MAXVARSIZE,"%s/ppkeys/%s-%s.pub",CFWORKDIR,"root",HashPrint(CF_DEFAULT_DIGEST,digest)); MapName(name); snprintf(source,CF_MAXVARSIZE,"%s/ppkeys/localhost.pub",CFWORKDIR); MapName(source); // During bootstrap we need the pre-registered IP/hash pair on the hub snprintf(guard,sizeof(guard),"%s/state/am_policy_hub",CFWORKDIR); MapName(guard); // need to use cf_stat if (stat(name,&sb) == -1 && stat(guard,&sb) != -1) // copy localhost.pub to root-HASH.pub on policy server { LastSaw("root",POLICY_SERVER,digest,cf_connect); if (!LinkOrCopy(source,name,false)) { CfOut(cf_error,""," -> Unable to clone server's key file as %s\n",name); } } } /*********************************************************************/ RSA *HavePublicKeyByIP(char *username,char *ipaddress) { char hash[CF_MAXVARSIZE]; IPString2KeyDigest(ipaddress,hash); return HavePublicKey(username,ipaddress,hash); } /*********************************************************************/ RSA *HavePublicKey(char *username,char *ipaddress,char *digest) { char keyname[CF_MAXVARSIZE],newname[CF_BUFSIZE],oldname[CF_BUFSIZE]; struct stat statbuf; static char *passphrase = "public"; unsigned long err; FILE *fp; RSA *newkey = NULL; snprintf(keyname,CF_MAXVARSIZE,"%s-%s",username,digest); Debug("HavePublickey(%s)\n",keyname); snprintf(newname,CF_BUFSIZE,"%s/ppkeys/%s.pub",CFWORKDIR,keyname); MapName(newname); if (cfstat(newname,&statbuf) == -1) { CfOut(cf_verbose,""," -> Did not find new key format %s",newname); snprintf(oldname,CF_BUFSIZE,"%s/ppkeys/%s-%s.pub",CFWORKDIR,username,ipaddress); MapName(oldname); CfOut(cf_verbose,""," -> Trying old style %s",oldname); if (cfstat(oldname,&statbuf) == -1) { Debug("Did not have old-style key %s\n",oldname); return NULL; } if (strlen(digest) > 0) { CfOut(cf_inform,""," -> Renaming old key from %s to %s",oldname,newname); if (rename(oldname,newname) != 0) { CfOut(cf_error, "rename", "!! Could not rename from old key format (%s) to new (%s)",oldname,newname); } } else // we don't know the digest (e.g. because we are a client and // have no lastseen-map and/or root-SHA...pub of the server's key // yet) Just using old file format (root-IP.pub) without renaming for now. { CfOut(cf_verbose, "", " -> Could not map key file to new format - we have no digest yet (using %s)", oldname); snprintf(newname,sizeof(newname),"%s",oldname); } } if ((fp = fopen(newname,"r")) == NULL) { CfOut(cf_error,"fopen","Couldn't find a public key (%s)",newname); return NULL; } if ((newkey = PEM_read_RSAPublicKey(fp,NULL,NULL,passphrase)) == NULL) { err = ERR_get_error(); CfOut(cf_error,"PEM_read","Error reading Private Key = %s\n",ERR_reason_error_string(err)); fclose(fp); return NULL; } fclose(fp); if (BN_num_bits(newkey->e) < 2 || !BN_is_odd(newkey->e)) { FatalError("RSA Exponent too small or not odd"); } return newkey; } /*********************************************************************/ void SavePublicKey(char *user,char *ipaddress,char *digest,RSA *key) { char keyname[CF_MAXVARSIZE],filename[CF_BUFSIZE]; struct stat statbuf; FILE *fp; int err; Debug("SavePublicKey %s\n",ipaddress); snprintf(keyname,CF_MAXVARSIZE,"%s-%s",user,digest); snprintf(filename,CF_BUFSIZE,"%s/ppkeys/%s.pub",CFWORKDIR,keyname); MapName(filename); if (cfstat(filename,&statbuf) != -1) { return; } CfOut(cf_verbose,"","Saving public key %s\n",filename); if ((fp = fopen(filename, "w")) == NULL ) { CfOut(cf_error,"fopen","Unable to write a public key %s",filename); return; } ThreadLock(cft_system); if (!PEM_write_RSAPublicKey(fp,key)) { err = ERR_get_error(); CfOut(cf_error,"PEM_write","Error saving public key %s = %s\n",filename,ERR_reason_error_string(err)); } ThreadUnlock(cft_system); fclose(fp); } /*********************************************************************/ /* * Returns: * amount of keys removed * -1 if there was an error */ static int RemovePublicKey(const char *id) { char keysdir[CF_BUFSIZE]; snprintf(keysdir, CF_BUFSIZE, "%s/ppkeys", CFWORKDIR); MapName(keysdir); CFDIR *dirh; const struct dirent *dirp; char suffix[CF_BUFSIZE]; int removed = 0; if ((dirh = OpenDirLocal(keysdir)) == NULL) { if (errno == ENOENT) { return 0; } else { CfOut(cf_error, "opendir", "Unable to open keys directory"); return -1; } } snprintf(suffix, CF_BUFSIZE, "-%s.pub", id); while ((dirp = ReadDir(dirh)) != NULL) { char *c = strstr(dirp->d_name, suffix); if (c && c[strlen(suffix)] == '\0') /* dirp->d_name ends with suffix */ { char keyfilename[CF_BUFSIZE]; snprintf(keyfilename, CF_BUFSIZE, "%s/%s", keysdir, dirp->d_name); MapName(keyfilename); if (unlink(keyfilename) < 0) { if (errno != ENOENT) { CfOut(cf_error, "unlink", "Unable to remove key file %s", dirp->d_name); CloseDir(dirh); return -1; } } else { removed++; } } } if (errno) { CfOut(cf_error, "ReadDir", "Unable to enumerate files in keys directory"); CloseDir(dirh); return -1; } CloseDir(dirh); return removed; } /*********************************************************************/ /* * Returns number of keys removed, -1 in case of error */ int RemovePublicKeys(const char *hostname) { char ip[CF_BUFSIZE]; char digest[CF_BUFSIZE]; int removed_by_digest, removed_by_ip; strcpy(ip, Hostname2IPString(hostname)); IPString2KeyDigest(ip, digest); removed_by_digest = RemovePublicKey(digest); removed_by_ip = RemovePublicKey(ip); if (removed_by_digest >= 0 && removed_by_ip >= 0) { return removed_by_digest + removed_by_ip; } else { return -1; } } /*********************************************************************/ static void MD5Random(unsigned char digest[EVP_MAX_MD_SIZE+1]) /* Make a decent random number by crunching some system states & garbage through MD5. We can use this as a seed for pseudo random generator */ { unsigned char buffer[CF_BUFSIZE]; char pscomm[CF_BUFSIZE]; char uninitbuffer[100]; int md_len; const EVP_MD *md; EVP_MD_CTX context; FILE *pp; CfOut(cf_verbose,"","Looking for a random number seed...\n"); #ifdef HAVE_NOVA md = EVP_get_digestbyname("sha256"); #else md = EVP_get_digestbyname("md5"); #endif EVP_DigestInit(&context,md); CfOut(cf_verbose,"","...\n"); snprintf(buffer,CF_BUFSIZE,"%d%d%25s",(int)CFSTARTTIME,(int)*digest,VFQNAME); EVP_DigestUpdate(&context,buffer,CF_BUFSIZE); snprintf(pscomm,CF_BUFSIZE,"%s %s",VPSCOMM[VSYSTEMHARDCLASS],VPSOPTS[VSYSTEMHARDCLASS]); if ((pp = cf_popen(pscomm,"r")) != NULL) { CfOut(cf_error,"cf_popen","Couldn't open the process list with command %s\n",pscomm); while (!feof(pp)) { CfReadLine(buffer,CF_BUFSIZE,pp); EVP_DigestUpdate(&context,buffer,CF_BUFSIZE); } } uninitbuffer[99] = '\0'; snprintf(buffer,CF_BUFSIZE-1,"%ld %s",time(NULL),uninitbuffer); EVP_DigestUpdate(&context,buffer,CF_BUFSIZE); cf_pclose(pp); EVP_DigestFinal(&context,digest,&md_len); } /*********************************************************************/ int EncryptString(char type,char *in,char *out,unsigned char *key,int plainlen) { int cipherlen = 0, tmplen; unsigned char iv[32] = {1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8}; EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX_init(&ctx); EVP_EncryptInit_ex(&ctx,CfengineCipher(type),NULL,key,iv); if (!EVP_EncryptUpdate(&ctx,out,&cipherlen,in,plainlen)) { EVP_CIPHER_CTX_cleanup(&ctx); return -1; } if (!EVP_EncryptFinal_ex(&ctx,out+cipherlen,&tmplen)) { EVP_CIPHER_CTX_cleanup(&ctx); return -1; } cipherlen += tmplen; EVP_CIPHER_CTX_cleanup(&ctx); return cipherlen; } /*********************************************************************/ int DecryptString(char type,char *in,char *out,unsigned char *key,int cipherlen) { int plainlen = 0, tmplen; unsigned char iv[32] = {1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8}; EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX_init(&ctx); EVP_DecryptInit_ex(&ctx,CfengineCipher(type),NULL,key,iv); if (!EVP_DecryptUpdate(&ctx,out,&plainlen,in,cipherlen)) { CfOut(cf_error, "", "!! Decrypt FAILED"); EVP_CIPHER_CTX_cleanup(&ctx); return -1; } if (!EVP_DecryptFinal_ex(&ctx,out+plainlen,&tmplen)) { unsigned long err = ERR_get_error(); CfOut(cf_error,"","decryption FAILED at final of %d: %s\n",cipherlen,ERR_error_string(err,NULL)); EVP_CIPHER_CTX_cleanup(&ctx); return -1; } plainlen += tmplen; EVP_CIPHER_CTX_cleanup(&ctx); return plainlen; } /*********************************************************************/ void DebugBinOut(char *buffer,int len,char *comment) { unsigned char *sp; char buf[CF_BUFSIZE]; char hexStr[3]; // one byte as hex if (len >= (sizeof(buf) / 2)) // hex uses two chars per byte { Debug("Debug binary print is too large (len=%d)", len); return; } memset(buf, 0, sizeof(buf)); for (sp = buffer; sp < (unsigned char *)(buffer+len); sp++) { snprintf(hexStr, sizeof(hexStr), "%2.2x", (int)*sp); strcat(buf, hexStr); } CfOut(cf_verbose, "", "BinaryBuffer(%d bytes => %s) -> [%s]",len,comment,buf); } /*********************************************************************/ static char *KeyPrint(RSA *pubkey) { unsigned char digest[EVP_MAX_MD_SIZE+1]; int i; for (i = 0; i < EVP_MAX_MD_SIZE+1; i++) { digest[i] = 0; } HashString((char *)pubkey,sizeof(BIGNUM)-4,digest,CF_DEFAULT_DIGEST); return HashPrint(CF_DEFAULT_DIGEST,digest); } cfengine-3.2.4/src/cf3.extern.h0000644000175000017500000002203711715232734013147 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: cf3.extern.h */ /* */ /* Created: Thu Aug 2 12:51:18 2007 */ /* */ /*****************************************************************************/ #ifndef CFENGINE_CF3_EXTERN_H #define CFENGINE_CF3_EXTERN_H /* See variables in cf3globals.c and syntax.c */ extern struct Topic *TOPICHASH[CF_HASHTABLESIZE]; extern struct PromiseParser P; extern int REQUIRE_COMMENTS; extern int FIPS_MODE; extern char POLICY_SERVER[CF_BUFSIZE]; extern int ALWAYS_VALIDATE; extern int LICENSES; extern int AM_NOVA; extern int AM_CONSTELLATION; extern char EXPIRY[32]; extern char LICENSE_COMPANY[CF_SMALLBUF]; extern int IGNORE_MISSING_INPUTS; extern int IGNORE_MISSING_BUNDLES; extern char WEBDRIVER[CF_MAXVARSIZE]; extern char DOCROOT[CF_MAXVARSIZE]; extern char BANNER[2*CF_BUFSIZE]; extern char FOOTER[CF_BUFSIZE]; extern char STYLESHEET[CF_BUFSIZE]; extern int CF_TOPICS; extern int CF_OCCUR; extern int CF_EDGES; extern int KEYTTL; extern struct Rlist *SERVER_KEYSEEN; extern enum cfhashes CF_DEFAULT_DIGEST; extern int CF_DEFAULT_DIGEST_LEN; extern struct Item *EDIT_ANCHORS; extern struct Bundle *BUNDLES; extern struct Body *BODIES; extern struct Scope *VSCOPE; extern struct Audit *AUDITPTR; extern struct Audit *VAUDIT; extern struct Rlist *VINPUTLIST; extern struct Rlist *BODYPARTS; extern struct Rlist *SUBBUNDLES; extern struct Rlist *SINGLE_COPY_LIST; extern struct Rlist *AUTO_DEFINE_LIST; extern struct Rlist *SINGLE_COPY_CACHE; extern struct Rlist *ACCESSLIST; extern struct PromiseIdent *PROMISE_ID_LIST; extern struct Item *DONELIST; extern struct Rlist *CBUNDLESEQUENCE; extern char *CBUNDLESEQUENCE_STR; extern struct Item *ROTATED; extern double FORGETRATE; extern struct Rlist *GOALS; extern struct Rlist *GOALCATEGORIES; extern struct Rlist *CF_STCK; extern int EDIT_MODEL; extern int CF_STCKFRAME; extern int CFA_BACKGROUND; extern int CFA_BACKGROUND_LIMIT; extern int AM_BACKGROUND_PROCESS; extern int CF_PERSISTENCE; extern int LOOKUP; extern int BOOTSTRAP; extern int XML; extern FILE *FREPORT_HTML; extern FILE *FREPORT_TXT; extern FILE *FKNOW; extern struct FnCallStatus FNCALL_STATUS; extern int CSV; extern struct SubTypeSyntax CF_NOSTYPE; extern char *CF_DATATYPES[]; extern char *CF_AGENTTYPES[]; extern char HASHDB[CF_BUFSIZE]; extern int FSTAB_EDITS; extern char GRAPHDIR[CF_BUFSIZE]; extern int CFA_MAXTHREADS; extern char *THIS_BUNDLE; extern char THIS_AGENT[CF_MAXVARSIZE]; extern enum cfagenttype THIS_AGENT_TYPE; extern int INSTALL_SKIP; extern int SHOWREPORTS; extern char SYSLOGHOST[CF_MAXVARSIZE]; extern unsigned short SYSLOGPORT; extern time_t PROMISETIME; extern time_t CF_LOCKHORIZON; extern int ABORTBUNDLE; extern struct Item *ABORTBUNDLEHEAP; extern int LASTSEENEXPIREAFTER; extern char *DEFAULT_COPYTYPE; extern struct Rlist *SERVERLIST; extern struct Item *PROCESSTABLE; extern struct Item *PROCESSREFRESH; extern struct Item *FSTABLIST; extern struct Rlist *MOUNTEDFSLIST; extern int CF_MOUNTALL; extern int CF_SAVEFSTAB; extern const char *DAY_TEXT[]; extern const char *MONTH_TEXT[]; extern const char *SHIFT_TEXT[]; #if defined(NT) && !defined(__CYGWIN__) # define FILE_SEPARATOR '\\' # define FILE_SEPARATOR_STR "\\" # else # define FILE_SEPARATOR '/' # define FILE_SEPARATOR_STR "/" #endif extern char *BASIC_REPORTS[cfrep_unknown][2]; extern char *CDP_REPORTS[cdp_unknown][2]; extern char SQL_DATABASE[CF_MAXVARSIZE]; extern char SQL_OWNER[CF_MAXVARSIZE]; extern char SQL_PASSWD[CF_MAXVARSIZE]; extern char SQL_SERVER[CF_MAXVARSIZE]; extern char SQL_CONNECT_NAME[CF_MAXVARSIZE]; extern enum cfdbtype SQL_TYPE; extern double VAL_KEPT; extern double VAL_REPAIRED; extern double VAL_NOTKEPT; extern double METER_KEPT[meter_endmark]; extern double METER_REPAIRED[meter_endmark]; extern double Q_MEAN; extern double Q_SIGMA; /***********************************************************/ /* SYNTAX MODULES */ /***********************************************************/ #ifndef CF3_MOD_COMMON extern struct SubTypeSyntax CF_COMMON_SUBTYPES[]; extern struct BodySyntax CF_BODY_TRANSACTION[]; extern struct BodySyntax CF_VARBODY[]; extern struct BodySyntax CF_CLASSBODY[]; extern struct BodySyntax CFG_CONTROLBODY[]; extern struct BodySyntax CFH_CONTROLBODY[]; extern struct BodySyntax CFA_CONTROLBODY[]; extern struct BodySyntax CFS_CONTROLBODY[]; extern struct BodySyntax CFE_CONTROLBODY[]; extern struct BodySyntax CFR_CONTROLBODY[]; extern struct BodySyntax CFK_CONTROLBODY[]; extern struct BodySyntax CFEX_CONTROLBODY[]; extern struct BodySyntax CF_TRIGGER_BODY[]; extern struct BodySyntax CF_TRANSACTION_BODY[]; extern struct BodySyntax CF_DEFINECLASS_BODY[]; extern struct BodySyntax CF_COMMON_BODIES[]; extern struct SubTypeSyntax *CF_ALL_SUBTYPES[]; extern struct SubTypeSyntax CF_ALL_BODIES[]; #endif #ifndef CF3_MOD_ENVIRON extern struct BodySyntax CF_RESOURCE_BODY[]; extern struct BodySyntax CF_DESIGNATION_BODY[]; extern struct BodySyntax CF_ENVIRON_BODIES[]; extern struct SubTypeSyntax CF_ENVIRONMENT_SUBTYPES[]; #endif #ifndef CF3_MOD_OUTPUTS extern struct BodySyntax CF_OUTPUTS_BODIES[]; extern struct SubTypeSyntax CF_OUTPUTS_SUBTYPES[]; #endif #ifndef CF3_MOD_FUNCTIONS extern struct FnCallType CF_FNCALL_TYPES[]; #endif #ifndef CF3_MOD_ACCESS extern struct BodySyntax CF_REMACCESS_BODIES[]; extern struct SubTypeSyntax CF_REMACCESS_SUBTYPES[]; #endif #ifndef CF_MOD_INTERFACES extern struct BodySyntax CF_TCPIP_BODY[]; extern struct BodySyntax CF_INTERFACES_BODIES[]; extern struct SubTypeSyntax CF_INTERFACES_SUBTYPES[]; #endif #ifndef CF3_MOD_STORAGE extern struct BodySyntax CF_STORAGE_BODIES[]; extern struct SubTypeSyntax CF_STORAGE_SUBTYPES[]; extern struct BodySyntax CF_MOUNT_BODY[]; extern struct BodySyntax CF_CHECKVOL_BODY[]; #endif #ifndef CF3_MOD_DATABASES extern struct BodySyntax CF_DATABASES_BODIES[]; extern struct SubTypeSyntax CF_DATABASES_SUBTYPES[]; extern struct BodySyntax CF_SQLSERVER_BODY[]; #endif #ifndef CF3_MOD_KNOWLEGDE extern struct SubTypeSyntax CF_KNOWLEDGE_SUBTYPES[]; extern struct BodySyntax CF_TOPICS_BODIES[]; extern struct BodySyntax CF_OCCUR_BODIES[]; extern struct BodySyntax CF_INFER_BODIES[]; extern struct BodySyntax CF_INFERENCE_BODY[]; extern struct BodySyntax CF_RELATE_BODY[]; #endif #ifndef CF3_MOD_PACKAGES extern struct SubTypeSyntax CF_PACKAGES_SUBTYPES[]; extern struct BodySyntax CF_PACKAGES_BODIES[]; extern struct BodySyntax CF_EXISTS_BODY[]; #endif #ifndef CF3_MOD_REPORT extern struct SubTypeSyntax CF_REPORT_SUBTYPES[]; extern struct BodySyntax CF_REPORT_BODIES[]; extern struct BodySyntax CF_PRINTFILE_BODY[]; #endif #ifndef CF3_MOD_FILES extern struct BodySyntax CF_COMMON_EDITBODIES[]; extern struct SubTypeSyntax CF_FILES_SUBTYPES[]; extern struct BodySyntax CF_APPEND_REPL_BODIES[]; extern struct BodySyntax CF_FILES_BODIES[]; extern struct BodySyntax CF_COPYFROM_BODY[]; extern struct BodySyntax CF_LINKTO_BODY[]; extern struct BodySyntax CF_FILEFILTER_BODY[]; extern struct BodySyntax CF_CHANGEMGT_BODY[]; extern struct BodySyntax CF_TIDY_BODY[]; extern struct BodySyntax CF_RENAME_BODY[]; extern struct BodySyntax CF_RECURSION_BODY[]; #endif #ifndef CF3_MOD_EXEC extern struct SubTypeSyntax CF_EXEC_SUBTYPES[]; #endif #ifndef CF3_MOD_METHODS extern struct SubTypeSyntax CF_METHOD_SUBTYPES[]; #endif #ifndef CF3_MOD_PROCESS extern struct SubTypeSyntax CF_PROCESS_SUBTYPES[]; extern struct BodySyntax CF_MATCHCLASS_BODY[]; extern struct BodySyntax CF_PROCFILTER_BODY[]; extern struct BodySyntax CF_PROCESS_BODIES[]; #endif #ifndef CF3_MOD_PROCESS extern struct SubTypeSyntax CF_MEASUREMENT_SUBTYPES[]; extern struct BodySyntax CF_MEASURE_BODIES[]; #endif #ifndef CF3_MOD_SERVICES extern struct SubTypeSyntax CF_SERVICES_SUBTYPES[]; extern struct BodySyntax CF_SERVMETHOD_BODY[]; extern struct BodySyntax CF_SERVICES_BODIES[]; #endif #endif cfengine-3.2.4/src/mod_methods.c0000644000175000017500000000406111715232734013462 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_methods.c */ /* */ /*****************************************************************************/ #define CF3_MOD_METHODS #include "cf3.defs.h" #include "cf3.extern.h" /***************************************************************/ /* This is the primary set of constraints for a methods object */ struct BodySyntax CF_METHOD_BODIES[] = { {"usebundle",cf_bundle,CF_BUNDLE,"Specify the name of a bundle to run as a parameterized method"}, {NULL,cf_notype,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_METHOD_SUBTYPES[] = { {"agent","methods",CF_METHOD_BODIES}, {NULL,NULL,NULL}, }; cfengine-3.2.4/src/mod_packages.c0000644000175000017500000001346011715232734013600 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_interfaces.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*****************************************************************************/ #define CF3_MOD_PACKAGES struct BodySyntax CF_PKGMETHOD_BODY[] = { {"package_add_command",cf_str,CF_ABSPATHRANGE,"Command to install a package to the system"}, {"package_arch_regex",cf_str,"","Regular expression with one backreference to extract package architecture string" }, {"package_changes",cf_opts,"individual,bulk","Menu option - whether to group packages into a single aggregate command"}, {"package_delete_command",cf_str,CF_ABSPATHRANGE,"Command to remove a package from the system"}, {"package_delete_convention",cf_str,"","This is how the package manager expects the package to be referred to in the deletion part of a package update, e.g. $(name)"}, {"package_file_repositories",cf_slist,"","A list of machine-local directories to search for packages"}, {"package_installed_regex",cf_str,"","Regular expression which matches packages that are already installed"}, {"package_list_arch_regex",cf_str,"","Regular expression with one backreference to extract package architecture string" }, {"package_list_command",cf_str,CF_ABSPATHRANGE,"Command to obtain a list of available packages"}, {"package_list_name_regex",cf_str,"","Regular expression with one backreference to extract package name string" }, {"package_list_update_command",cf_str,"","Command to update the list of available packages (if any)" }, {"package_list_update_ifelapsed",cf_int,CF_INTRANGE,"The ifelapsed locking time in between updates of the package list" }, {"package_list_version_regex",cf_str,"","Regular expression with one backreference to extract package version string" }, {"package_name_convention",cf_str,"","This is how the package manager expects the package to be referred to, e.g. $(name).$(arch)"}, {"package_name_regex",cf_str,"","Regular expression with one backreference to extract package name string" }, {"package_noverify_regex",cf_str,"","Regular expression to match verification failure output"}, {"package_noverify_returncode",cf_int,CF_INTRANGE,"Integer return code indicating package verification failure"}, {"package_patch_arch_regex",cf_str,"","Regular expression with one backreference to extract update architecture string" }, {"package_patch_command",cf_str,CF_ABSPATHRANGE,"Command to update to the latest patch release of an installed package"}, {"package_patch_installed_regex",cf_str,"","Regular expression which matches packages that are already installed"}, {"package_patch_list_command",cf_str,CF_ABSPATHRANGE,"Command to obtain a list of available patches or updates"}, {"package_patch_name_regex",cf_str,"","Regular expression with one backreference to extract update name string" }, {"package_patch_version_regex",cf_str,"","Regular expression with one backreference to extract update version string" }, {"package_update_command",cf_str,CF_ABSPATHRANGE,"Command to update to the latest version a currently installed package"}, {"package_verify_command",cf_str,CF_ABSPATHRANGE,"Command to verify the correctness of an installed package"}, {"package_version_regex",cf_str,"","Regular expression with one backreference to extract package version string" }, {"package_multiline_start",cf_str,"","Regular expression which matches the start of a new package in multiline output" }, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the primary set of constraints for an interfaces object */ struct BodySyntax CF_PACKAGES_BODIES[] = { {"package_architectures",cf_slist,"","Select the architecture for package selection"}, {"package_method",cf_body,CF_PKGMETHOD_BODY,"Criteria for installation and verification"}, {"package_policy",cf_opts,"add,delete,reinstall,update,addupdate,patch,verify","Criteria for package installation/upgrade on the current system"}, {"package_select",cf_opts,">,<,==,!=,>=,<=","A criterion for first acceptable match relative to \"package_version\""}, {"package_version",cf_str,"","Version reference point for determining promised version"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_PACKAGES_SUBTYPES[] = { {"agent","packages",CF_PACKAGES_BODIES}, {NULL,NULL,NULL}, }; cfengine-3.2.4/src/fncall.c0000644000175000017500000001734611715232734012431 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: fncall.c */ /* */ /* Created: Wed Aug 8 14:45:53 2007 */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void PrintFunctions(void); static void ClearFnCallStatus(void); /*******************************************************************/ int IsBuiltinFnCall(void *rval,char rtype) { int i; struct FnCall *fp; if (rtype != CF_FNCALL) { return false; } fp = (struct FnCall *)rval; if (FindFunction(fp->name)) { Debug("%s is a builtin function\n",fp->name); return true; } else { return false; } } /*******************************************************************/ struct FnCall *NewFnCall(char *name, struct Rlist *args) { struct FnCall *fp; char *sp = NULL; Debug("Installing Function Call %s\n",name); if ((fp = (struct FnCall *)malloc(sizeof(struct FnCall))) == NULL) { CfOut(cf_error,"malloc","Unable to allocate FnCall"); FatalError(""); } if ((sp = strdup(name)) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Promise"); FatalError(""); } fp->name = sp; fp->args = args; fp->argc = RlistLen(args); Debug("Installed "); if (DEBUG) { ShowFnCall(stdout,fp); } Debug("\n\n"); return fp; } /*******************************************************************/ struct FnCall *CopyFnCall(struct FnCall *f) { Debug("CopyFnCall()\n"); return NewFnCall(f->name,CopyRlist(f->args)); } /*******************************************************************/ void DeleteFnCall(struct FnCall *fp) { if (fp->name) { free(fp->name); } if (fp->args) { DeleteRlist(fp->args); } free(fp); } /*********************************************************************/ struct FnCall *ExpandFnCall(char *contextid,struct FnCall *f,int expandnaked) { Debug("ExpandFnCall()\n"); //return NewFnCall(f->name,ExpandList(contextid,f->args,expandnaked)); return NewFnCall(f->name,ExpandList(contextid,f->args,false)); } /*******************************************************************/ static void PrintFunctions(void) { int i; for (i = 0; i < 3; i++) { if (P.currentfncall[i] != NULL) { printf("(%d) =========================\n|",i); ShowFnCall(stdout,P.currentfncall[i]); printf("|\n==============================\n"); } } } /*******************************************************************/ int PrintFnCall(char *buffer, int bufsize,struct FnCall *fp) { struct Rlist *rp; char work[CF_MAXVARSIZE]; snprintf(buffer,bufsize,"%s(",fp->name); for (rp = fp->args; rp != NULL; rp=rp->next) { switch (rp->type) { case CF_SCALAR: Join(buffer,(char *)rp->item,bufsize); break; case CF_FNCALL: PrintFnCall(work,CF_MAXVARSIZE,(struct FnCall *)rp->item); Join(buffer,work,bufsize); break; default: break; } if (rp->next != NULL) { strcat(buffer,","); } } strcat(buffer, ")"); return strlen(buffer); } /*******************************************************************/ void ShowFnCall(FILE *fout,struct FnCall *fp) { struct Rlist *rp; if (XML) { fprintf(fout,"%s(",fp->name); } else { fprintf(fout,"%s(",fp->name); } for (rp = fp->args; rp != NULL; rp=rp->next) { switch (rp->type) { case CF_SCALAR: fprintf(fout,"%s,",(char *)rp->item); break; case CF_FNCALL: ShowFnCall(fout,(struct FnCall *)rp->item); break; default: fprintf(fout,"(** Unknown argument **)\n"); break; } } if (XML) { fprintf(fout,")"); } else { fprintf(fout,")"); } } /*******************************************************************/ enum cfdatatype FunctionReturnType(const char *name) { FnCallType *fn = FindFunction(name); return fn ? fn->dtype : cf_notype; } /*******************************************************************/ struct Rval EvaluateFunctionCall(struct FnCall *fp,struct Promise *pp) { struct Rlist *expargs; struct Rval rval; FnCallType *this = FindFunction(fp->name); rval.item = NULL; rval.rtype = CF_NOPROMISEE; if (this) { if (DEBUG) { printf("EVALUATE FN CALL %s\n",fp->name); ShowFnCall(stdout,fp); printf("\n"); } } else { if (pp) { CfOut(cf_error,"","No such FnCall \"%s()\" in promise @ %s near line %d\n",fp->name,pp->audit->filename,pp->lineno); } else { CfOut(cf_error,"","No such FnCall \"%s()\" - context info unavailable\n",fp->name); } return rval; } /* If the container classes seem not to be defined at this stage, then don't try to expand the function */ if ((pp != NULL) && !IsDefinedClass(pp->classes)) { return rval; } ClearFnCallStatus(); expargs = NewExpArgs(fp,pp); if (UnresolvedArgs(expargs)) { FNCALL_STATUS.status = FNCALL_FAILURE; rval.item = CopyFnCall(fp); rval.rtype = CF_FNCALL; DeleteExpArgs(expargs); return rval; } if (this) { rval = CallFunction(this, fp, expargs); } else { CfOut(cf_error,"","Un-registered function call"); PromiseRef(cf_error,pp); } if (FNCALL_STATUS.status == FNCALL_FAILURE) { /* We do not assign variables to failed function calls */ rval.item = CopyFnCall(fp); rval.rtype = CF_FNCALL; } DeleteExpArgs(expargs); return rval; } /*******************************************************************/ FnCallType *FindFunction(const char *name) { int i; for (i = 0; CF_FNCALL_TYPES[i].name != NULL; i++) { if (strcmp(CF_FNCALL_TYPES[i].name,name) == 0) { return CF_FNCALL_TYPES + i; } } return NULL; } /*****************************************************************************/ static void ClearFnCallStatus(void) { FNCALL_STATUS.status = CF_NOP; FNCALL_STATUS.message[0] = '\0'; FNCALL_STATUS.fncall_classes[0] = '\0'; } /*****************************************************************************/ void SetFnCallReturnStatus(char *name,int status,char *message,char *fncall_classes) { FNCALL_STATUS.status = status; if (message && strlen(message) > 0) { strncpy(FNCALL_STATUS.message,message,CF_BUFSIZE-1); } if (fncall_classes && strlen(fncall_classes)) { strncpy(FNCALL_STATUS.fncall_classes,fncall_classes,CF_BUFSIZE-1); AddPrefixedClasses(name,fncall_classes); } } cfengine-3.2.4/src/verify_reports.c0000644000175000017500000004246411715232734014253 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: verify_reports.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void FriendStatus(struct Attributes a,struct Promise *pp); static void VerifyFriendReliability(struct Attributes a,struct Promise *pp); static void VerifyFriendConnections(int hours,struct Attributes a,struct Promise *pp); static void ShowState(char *type,struct Attributes a,struct Promise *pp); static void PrintFile(struct Attributes a,struct Promise *pp); /*******************************************************************/ /* Agent reporting */ /*******************************************************************/ void VerifyReportPromise(struct Promise *pp) { struct Attributes a = {{0}}; struct CfLock thislock; struct Rlist *rp; char unique_name[CF_EXPANDSIZE]; a = GetReportsAttributes(pp); if (strcmp(pp->classes,"any") == 0) { CfOut(cf_verbose,""," --> Reports promises may not be in class \"any\""); return; } snprintf(unique_name,CF_EXPANDSIZE-1,"%s_%d",pp->promiser,pp->lineno); thislock = AcquireLock(unique_name,VUQNAME,CFSTARTTIME,a,pp,false); if (thislock.lock == NULL) { return; } PromiseBanner(pp); cfPS(cf_verbose,CF_CHG,"",pp,a,"Report: %s", pp->promiser); if (a.report.to_file) { CfFOut(a.report.to_file,cf_error,"","%s",pp->promiser); } else { CfOut(cf_reporting,"","R: %s",pp->promiser); } if (a.report.haveprintfile) { PrintFile(a,pp); } if (a.report.showstate) { for (rp = a.report.showstate; rp != NULL; rp=rp->next) { ShowState(rp->item,a,pp); } } if (a.report.havelastseen) { FriendStatus(a,pp); } YieldCurrentLock(thislock); } /*******************************************************************/ /* Level */ /*******************************************************************/ static void PrintFile(struct Attributes a,struct Promise *pp) { FILE *fp; char buffer[CF_BUFSIZE]; int lines = 0; if (a.report.filename == NULL) { CfOut(cf_verbose,"","Printfile promise was incomplete, with no filename.\n"); return; } if ((fp = fopen(a.report.filename,"r")) == NULL) { cfPS(cf_error,CF_INTERPT,"fopen",pp,a," !! Printing of file %s was not possible.\n",a.report.filename); return; } while (!feof(fp) && (lines < a.report.numlines)) { buffer[0] = '\0'; fgets(buffer,CF_BUFSIZE,fp); CfOut(cf_error,"","R: %s",buffer); lines++; } fclose(fp); } /*********************************************************************/ static void ShowState(char *type,struct Attributes a,struct Promise *pp) { struct stat statbuf; char buffer[CF_BUFSIZE],vbuff[CF_BUFSIZE],assemble[CF_BUFSIZE]; struct Item *addresses = NULL,*saddresses = NULL,*ip; int i = 0, tot=0, min_signal_diversity = 1,conns=1; int maxlen = 0,count; double *dist = NULL, S = 0.0; char *offset = NULL; FILE *fp; Debug("ShowState(%s)\n",type); snprintf(buffer,CF_BUFSIZE-1,"%s/state/cf_%s",CFWORKDIR,type); if (cfstat(buffer,&statbuf) == 0) { if ((fp = fopen(buffer,"r")) == NULL) { CfOut(cf_inform,"fopen","Could not open state memory %s\n",buffer); return; } while(!feof(fp)) { char local[CF_BUFSIZE],remote[CF_BUFSIZE]; buffer[0] = local[0] = remote[0] = '\0'; memset(vbuff,0,CF_BUFSIZE); fgets(buffer,CF_BUFSIZE,fp); if (strlen(buffer) > 0) { CfOut(cf_verbose,"","(%2d) %s",conns,buffer); if (IsSocketType(type)) { if (strncmp(type,"incoming",8) == 0 || strncmp(type,"outgoing",8) == 0) { if (strncmp(buffer,"tcp",3) == 0) { sscanf(buffer,"%*s %*s %*s %s %s",local,remote); /* linux-like */ } else { sscanf(buffer,"%s %s",local,remote); /* solaris-like */ } strncpy(vbuff,remote,CF_BUFSIZE-1); DePort(vbuff); } } else if (IsTCPType(type)) { count = 1; sscanf(buffer,"%d %[^\n]",&count,remote); AppendItem(&addresses,remote,""); SetItemListCounter(addresses,remote,count); conns += count; continue; } else { /* If we get here this is a process thing */ if (offset == NULL) { if ((offset = strstr(buffer,"CMD"))) { } else if ((offset = strstr(buffer,"COMMAND"))) { } if (offset == NULL) { continue; } } strncpy(vbuff,offset,CF_BUFSIZE-1); Chop(vbuff); } if (!IsItemIn(addresses,vbuff)) { conns++; AppendItem(&addresses,vbuff,""); IncrementItemListCounter(addresses,vbuff); } else { conns++; IncrementItemListCounter(addresses,vbuff); } } } fclose(fp); conns--; CfOut(cf_error,"","\n"); CfOut(cf_error,"","R: The peak measured state was q = %d:\n",conns); if (IsSocketType(type)||IsTCPType(type)) { if (addresses != NULL) { cfPS(cf_error,CF_CHG,"",pp,a," {\n"); } for (ip = addresses; ip != NULL; ip=ip->next) { tot+=ip->counter; buffer[0] = '\0'; sscanf(ip->name,"%s",buffer); if (!IsIPV4Address(buffer) && !IsIPV6Address(buffer)) { CfOut(cf_verbose,"","Rejecting address %s\n",ip->name); continue; } CfOut(cf_error,"","R: DNS key: %s = %s (%d/%d)\n",buffer,IPString2Hostname(buffer),ip->counter,conns); if (strlen(ip->name) > maxlen) { maxlen = strlen(ip->name); } } if (addresses != NULL) { printf("R: -\n"); } } else { for (ip = addresses; ip != NULL; ip=ip->next) { tot+=ip->counter; } } saddresses = SortItemListCounters(addresses); for (ip = saddresses; ip != NULL; ip=ip->next) { int s; if (maxlen > 17) /* ipv6 */ { snprintf(assemble,CF_BUFSIZE,"Frequency: %-40s|",ip->name); } else { snprintf(assemble,CF_BUFSIZE,"Frequency: %-17s|",ip->name); } for (s = 0; (s < ip->counter) && (s < 50); s++) { if (s < 48) { strcat(assemble,"*"); } else { strcat(assemble,"+"); } } CfOut(cf_error,"","R: %s \t(%d/%d)\n",assemble,ip->counter,conns); } dist = (double *) malloc((tot+1)*sizeof(double)); if (conns > min_signal_diversity) { for (i = 0,ip = addresses; ip != NULL; i++,ip=ip->next) { dist[i] = ((double)(ip->counter))/((double)tot); S -= dist[i]*log(dist[i]); } CfOut(cf_error,"","R: Variability/entropy of addresses = %.1f %%\n",S/log((double)tot)*100.0); CfOut(cf_error,"","R: (Entropy = 0 for single source, 100 for flatly distributed source)\n -\n"); } CfOut(cf_error,"","\n"); CfOut(cf_error,"","R: State of %s peaked at %s\n",type,cf_ctime(&statbuf.st_mtime)); } else { CfOut(cf_inform,"","R: State parameter %s is not known or recorded\n",type); } DeleteItemList(addresses); if (dist) { free((char *)dist); } } /*********************************************************************/ static void FriendStatus(struct Attributes a,struct Promise *pp) { VerifyFriendConnections(a.report.lastseen,a,pp); VerifyFriendReliability(a,pp); } /*********************************************************************/ /* Level */ /*********************************************************************/ static void VerifyFriendConnections(int hours,struct Attributes a,struct Promise *pp) /* Go through the database of recent connections and check for Long Time No See ...*/ { CF_DB *dbp; CF_DBC *dbcp; char *key; void *value; int ksize,vsize; int secs = SECONDS_PER_HOUR*hours, criterion, overdue; time_t now = time(NULL),lsea = (time_t)CF_WEEK, tthen, then; char name[CF_BUFSIZE],hostname[CF_BUFSIZE],datebuf[CF_MAXVARSIZE]; char addr[CF_BUFSIZE],type[CF_BUFSIZE],output[CF_BUFSIZE]; struct QPoint entry; double average = 0.0, var = 0.0, ticksperminute = 60.0; double ticksperhour = (double)SECONDS_PER_HOUR; CfOut(cf_verbose,"","CheckFriendConnections(%d)\n",hours); snprintf(name,CF_BUFSIZE-1,"%s/lastseen/%s",CFWORKDIR,CF_LASTDB_FILE); MapName(name); if (!OpenDB(name,&dbp)) { return; } /* Acquire a cursor for the database. */ if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan friend db"); return; } /* Walk through the database and print out the key/data pairs. */ while(NextDB(dbp,dbcp,&key,&ksize,&value,&vsize)) { memset(&entry, 0, sizeof(entry)); strncpy(hostname,(char *)key,ksize); if (value != NULL) { memcpy(&entry,value,sizeof(entry)); then = (time_t)entry.q; average = (double)entry.expect; var = (double)entry.var; } else { continue; } if (then == 0) { continue; // No data } /* Got data, now get expiry criterion */ if (secs == 0) { /* Twice the average delta is significant */ criterion = (now - then > (int)(average+2.0*sqrt(var)+0.5)); overdue = now - then - (int)(average); } else { criterion = (now - then > secs); overdue = (now - then - secs); } if (LASTSEENEXPIREAFTER < 0) { lsea = (time_t)CF_WEEK; } else { lsea = LASTSEENEXPIREAFTER; } if (a.report.friend_pattern) { if (FullTextMatch(a.report.friend_pattern,IPString2Hostname(hostname+1))) { CfOut(cf_verbose,"","Not judging friend %s\n",hostname); criterion = false; lsea = CF_INFINITY; } } tthen = (time_t)then; snprintf(datebuf,CF_MAXVARSIZE-1,"%s",cf_ctime(&tthen)); datebuf[strlen(datebuf)-9] = '\0'; /* Chop off second and year */ snprintf(addr,15,"%s",hostname+1); switch(*hostname) { case '+': snprintf(type,CF_BUFSIZE,"last responded to hails"); break; case'-': snprintf(type,CF_BUFSIZE,"last hailed us"); break; } snprintf(output,CF_BUFSIZE,"Host %s i.e. %s %s @ [%s] (overdue by %d mins)", IPString2Hostname(hostname+1), addr, type, datebuf, overdue/(int)ticksperminute); if (criterion) { CfOut(cf_error,"",output); } else { CfOut(cf_verbose,"",output); } snprintf(output,CF_BUFSIZE,"i.e. (%.2f) hrs ago, Av %.2f +/- %.2f hrs\n", ((double)(now-then))/ticksperhour, average/ticksperhour, sqrt(var)/ticksperhour); if (criterion) { CfOut(cf_error,"",output); } else { CfOut(cf_verbose,"",output); } if (now - then > lsea) { CfOut(cf_error,"","Giving up on host %s -- %d hours since last seen",IPString2Hostname(hostname+1),hours); DeleteDB(dbp,hostname); } memset(&value,0,sizeof(value)); memset(&key,0,sizeof(key)); } DeleteDBCursor(dbp,dbcp); CloseDB(dbp); } /***************************************************************/ static void VerifyFriendReliability(struct Attributes a,struct Promise *pp) { CF_DB *dbp; CF_DBC *dbcp; int i,ksize,vsize; char *key; void *value; double n[CF_RELIABLE_CLASSES],n_av[CF_RELIABLE_CLASSES],total; double p[CF_RELIABLE_CLASSES],p_av[CF_RELIABLE_CLASSES]; char name[CF_BUFSIZE],hostname[CF_BUFSIZE],timekey[CF_MAXVARSIZE]; struct QPoint entry; struct Item *ip, *hostlist = NULL; double average,var,sum,sum_av,expect,actual; time_t now = time(NULL), then, lastseen = CF_WEEK; CfOut(cf_verbose,"","CheckFriendReliability()\n"); snprintf(name,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,CF_LASTDB_FILE); average = (double) CF_HOUR; /* It will take a week for a host to be deemed reliable */ var = 0; if (!OpenDB(name,&dbp)) { return; } if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan last-seen db"); return; } while(NextDB(dbp,dbcp,&key,&ksize,&value,&vsize)) { strcpy(hostname,IPString2Hostname((char *)key+1)); if (!IsItemIn(hostlist,hostname)) { /* Check hostname not recorded twice with +/- */ AppendItem(&hostlist,hostname,NULL); CfOut(cf_verbose,""," Measuring reliability of %s\n",hostname); } } DeleteDBCursor(dbp,dbcp); CloseDB(dbp); /* Now go through each host and recompute entropy */ for (ip = hostlist; ip != NULL; ip=ip->next) { snprintf(name,CF_BUFSIZE-1,"%s/%s.%s",CFWORKDIR,CF_LASTDB_FILE,ip->name); MapName(name); if (!OpenDB(name,&dbp)) { return; } for (i = 0; i < CF_RELIABLE_CLASSES; i++) { n[i] = n_av[i] = 0.0; } total = 0.0; for (now = CF_MONDAY_MORNING; now < CF_MONDAY_MORNING+CF_WEEK; now += CF_MEASURE_INTERVAL) { strcpy(timekey,GenTimeKey(now)); if (ReadDB(dbp,timekey,&value,sizeof(entry))) { memcpy(&entry,value,sizeof(entry)); then = (time_t)entry.q; lastseen = now - then; if (lastseen < 0) { lastseen = 0; /* Never seen before, so pretend */ } average = (double)entry.expect; var = (double)entry.var; Debug("%s => then = %ld, lastseen = %ld, average=%.2f\n",hostname,then,lastseen,average); } else { /* If we have no data, it means no contact for whatever reason. It could be unable to respond unwilling to respond, policy etc. Assume for argument that we expect regular responses ... */ lastseen += CF_MEASURE_INTERVAL; /* infer based on no data */ } for (i = 0; i < CF_RELIABLE_CLASSES; i++) { if (lastseen >= i*CF_HOUR && lastseen < (i+1)*CF_HOUR) { n[i]++; } if (average >= (double)(i*CF_HOUR) && average < (double)((i+1)*CF_HOUR)) { n_av[i]++; } } total++; } sum = sum_av = 0.0; for (i = 0; i < CF_RELIABLE_CLASSES; i++) { p[i] = n[i]/total; p_av[i] = n_av[i]/total; sum += p[i]; sum_av += p_av[i]; } Debug("Reliabilities sum to %.2f av %.2f\n\n",sum,sum_av); sum = sum_av = 0.0; for (i = 0; i < CF_RELIABLE_CLASSES; i++) { if (p[i] == 0.0) { continue; } sum -= p[i] * log(p[i]); } for (i = 0; i < CF_RELIABLE_CLASSES; i++) { if (p_av[i] == 0.0) { continue; } sum_av -= p_av[i] * log(p_av[i]); } actual = sum/log((double)CF_RELIABLE_CLASSES)*100.0; expect = sum_av/log((double)CF_RELIABLE_CLASSES)*100.0; CfOut(cf_verbose,"","Scaled entropy for %s = %.1f %%\n",ip->name,actual); CfOut(cf_verbose,"","Expected entropy for %s = %.1f %%\n\n",ip->name,expect); if (actual > expect) { CfOut(cf_inform,""," !! The reliability of %s deteriorated\n",ip->name); } if (actual > 50.0) { CfOut(cf_error,"","FriendStatus reports the intermittency of %s above 50%% (SEUs)\n",ip->name); } if (expect > actual) { CfOut(cf_inform,"","The reliability of %s is improved\n",ip->name); } CloseDB(dbp); } DeleteItemList(hostlist); } cfengine-3.2.4/src/verify_storage.c0000644000175000017500000002752311715232734014220 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: verify_storage.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void FindStoragePromiserObjects(struct Promise *pp); static int VerifyFileSystem(char *name,struct Attributes a,struct Promise *pp); static int VerifyFreeSpace(char *file,struct Attributes a,struct Promise *pp); static void VolumeScanArrivals(char *file,struct Attributes a,struct Promise *pp); static int FileSystemMountedCorrectly(struct Rlist *list,char *name,char *options,struct Attributes a,struct Promise *pp); static int IsForeignFileSystem (struct stat *childstat,char *dir); #ifndef MINGW static int VerifyMountPromise(char *file,struct Attributes a,struct Promise *pp); #endif /* NOT MINGW */ /*****************************************************************************/ void *FindAndVerifyStoragePromises(struct Promise *pp) { PromiseBanner(pp); FindStoragePromiserObjects(pp); return (void *)NULL; } /*****************************************************************************/ static void FindStoragePromiserObjects(struct Promise *pp) { /* Check if we are searching over a regular expression */ LocateFilePromiserGroup(pp->promiser,pp,VerifyStoragePromise); } /*****************************************************************************/ void VerifyStoragePromise(char *path,struct Promise *pp) { struct Attributes a = {{0}}; struct CfLock thislock; a = GetStorageAttributes(pp); CF_OCCUR++; #ifdef MINGW if(!a.havemount) { CfOut(cf_verbose, "", "storage.mount is not supported on Windows"); } #endif /* No parameter conflicts here */ if (a.mount.unmount) { if (a.mount.mount_source || a.mount.mount_server) { CfOut(cf_verbose,""," !! An unmount promise indicates a mount-source information - probably in error\n"); } } else if (a.havemount) { if (a.mount.mount_source == NULL || a.mount.mount_server == NULL) { CfOut(cf_error,""," !! Insufficient specification in mount promise - need source and server\n"); return; } } thislock = AcquireLock(path,VUQNAME,CFSTARTTIME,a,pp,false); if (thislock.lock == NULL) { return; } /* Do mounts first */ #ifndef MINGW if (!MOUNTEDFSLIST && !LoadMountInfo(&MOUNTEDFSLIST)) { CfOut(cf_error,"","Couldn't obtain a list of mounted filesystems - aborting\n"); YieldCurrentLock(thislock); return; } if (a.havemount) { VerifyMountPromise(path,a,pp); } #endif /* NOT MINGW */ /* Then check file system */ if (a.havevolume) { VerifyFileSystem(path,a,pp); if (a.volume.freespace != CF_NOINT) { VerifyFreeSpace(path,a,pp); } if (a.volume.scan_arrivals) { VolumeScanArrivals(path,a,pp); } } YieldCurrentLock(thislock); } /*******************************************************************/ /** Level */ /*******************************************************************/ static int VerifyFileSystem(char *name,struct Attributes a,struct Promise *pp) { struct stat statbuf, localstat; CFDIR *dirh; const struct dirent *dirp; off_t sizeinbytes = 0; long filecount = 0; char buff[CF_BUFSIZE]; CfOut(cf_verbose,""," -> Checking required filesystem %s\n",name); if (cfstat(name,&statbuf) == -1) { return(false); } if (S_ISLNK(statbuf.st_mode)) { KillGhostLink(name,a,pp); return(true); } if (S_ISDIR(statbuf.st_mode)) { if ((dirh = OpenDirLocal(name)) == NULL) { CfOut(cf_error,"opendir","Can't open directory %s which checking required/disk\n",name); return false; } for (dirp = ReadDir(dirh); dirp != NULL; dirp = ReadDir(dirh)) { if (!ConsiderFile(dirp->d_name,name,a,pp)) { continue; } filecount++; strcpy(buff,name); if (buff[strlen(buff)] != FILE_SEPARATOR) { strcat(buff,FILE_SEPARATOR_STR); } strcat(buff,dirp->d_name); if (lstat(buff,&localstat) == -1) { if (S_ISLNK(localstat.st_mode)) { KillGhostLink(buff,a,pp); continue; } CfOut(cf_error,"lstat","Can't stat volume %s\n",buff); continue; } sizeinbytes += localstat.st_size; } CloseDir(dirh); if (sizeinbytes < 0) { CfOut(cf_verbose,"","Internal error: count of byte size was less than zero!\n"); return true; } if (sizeinbytes < a.volume.sensible_size) { cfPS(cf_error,CF_INTERPT,"",pp,a," !! File system %s is suspiciously small! (%d bytes)\n",name,sizeinbytes); return(false); } if (filecount < a.volume.sensible_count) { cfPS(cf_error,CF_INTERPT,"",pp,a," !! Filesystem %s has only %d files/directories.\n",name,filecount); return(false); } } cfPS(cf_inform,CF_NOP,"",pp,a," -> Filesystem %s's content seems to be sensible as promised\n",name); return(true); } /*******************************************************************/ static int VerifyFreeSpace(char *file,struct Attributes a,struct Promise *pp) { struct stat statbuf; long kilobytes; #ifdef MINGW if (!a.volume.check_foreign) { CfOut(cf_verbose, "", "storage.volume.check_foreign is not supported on Windows (checking every mount)"); } #endif /* MINGW */ if (cfstat(file,&statbuf) == -1) { CfOut(cf_error,"stat","Couldn't stat %s checking diskspace\n",file); return true; } #ifndef MINGW if (!a.volume.check_foreign) { if (IsForeignFileSystem(&statbuf,file)) { CfOut(cf_inform,"","Filesystem %s is mounted from a foreign system, so skipping it",file); return true; } } #endif /* NOT MINGW */ kilobytes = a.volume.freespace; if (kilobytes < 0) { int free = (int)GetDiskUsage(file,cfpercent); kilobytes = -1 * kilobytes; if (free < (int)kilobytes) { cfPS(cf_error,CF_FAIL,"",pp,a," !! Free disk space is under %ld%% for volume containing %s (%d%% free)\n",kilobytes,file,free); return false; } } else { off_t free = GetDiskUsage(file, cfabs); kilobytes = kilobytes / 1024; if (free < kilobytes) { cfPS(cf_error,CF_FAIL,"",pp,a," !! Disk space under %ld kB for volume containing %s (%lld kB free)\n",kilobytes,file,(long long)free); return false; } } return true; } /*******************************************************************/ static void VolumeScanArrivals(char *file,struct Attributes a,struct Promise *pp) { CfOut(cf_verbose,"","Scan arrival sequence . not yet implemented\n"); } /*******************************************************************/ static int FileSystemMountedCorrectly(struct Rlist *list,char *name,char *options,struct Attributes a,struct Promise *pp) { struct Rlist *rp; struct CfMount *mp; int found = false; for (rp = list; rp != NULL; rp=rp->next) { mp = (struct CfMount *)rp->item; if (mp == NULL) { continue; } /* Give primacy to the promised / affected object */ if (strcmp(name,mp->mounton) == 0) { /* We have found something mounted on the promiser dir */ found = true; if (a.mount.mount_source && (strcmp(mp->source,a.mount.mount_source) != 0)) { CfOut(cf_inform,"","A different file system (%s:%s) is mounted on %s than what is promised\n",mp->host,mp->source,name); return false; } else { CfOut(cf_verbose,""," -> File system %s seems to be mounted correctly\n",mp->source); break; } } } if (!found) { if (! a.mount.unmount) { CfOut(cf_verbose,""," !! File system %s seems not to be mounted correctly\n",name); CF_MOUNTALL = true; } } return found; } /*********************************************************************/ /* Mounting */ /*********************************************************************/ static int IsForeignFileSystem (struct stat *childstat,char *dir) /* Is FS NFS mounted ? */ { struct stat parentstat; char vbuff[CF_BUFSIZE]; strncpy(vbuff,dir,CF_BUFSIZE-1); if (vbuff[strlen(vbuff)-1] == FILE_SEPARATOR) { strcat(vbuff,".."); } else { strcat(vbuff,FILE_SEPARATOR_STR); strcat(vbuff,".."); } if (cfstat(vbuff,&parentstat) == -1) { CfOut(cf_verbose,"stat"," !! Unable to stat %s",vbuff); return(false); } if (childstat->st_dev != parentstat.st_dev) { struct Rlist *rp; struct CfMount *entry; Debug("[%s is on a different file system, not descending]\n",dir); for (rp = MOUNTEDFSLIST; rp != NULL; rp=rp->next) { entry = (struct CfMount *)rp->item; if (!strcmp(entry->mounton, dir)) { if (entry->options && strstr(entry->options,"nfs")) { return (true); } } } } Debug("NotMountedFileSystem\n"); return(false); } /*********************************************************************/ /* Unix-specific implementations */ /*********************************************************************/ #ifndef MINGW static int VerifyMountPromise(char *name,struct Attributes a,struct Promise *pp) { char *options; char dir[CF_BUFSIZE]; int changes = 0; CfOut(cf_verbose,""," -> Verifying mounted file systems on %s\n",name); snprintf(dir,CF_BUFSIZE,"%s/.",name); if (!IsPrivileged()) { cfPS(cf_error,CF_INTERPT,"",pp,a,"Only root can mount filesystems.\n",""); return false; } options = Rlist2String(a.mount.mount_options,","); if (!FileSystemMountedCorrectly(MOUNTEDFSLIST,name,options,a,pp)) { if (!a.mount.unmount) { if (!MakeParentDirectory(dir,a.move_obstructions)) { } if (a.mount.editfstab) { changes += VerifyInFstab(name,a,pp); } else { cfPS(cf_inform,CF_FAIL,"",pp,a," -> Filesystem %s was not mounted as promised, and no edits were promised in %s\n",name,VFSTAB[VSYSTEMHARDCLASS]); // Mount explicitly VerifyMount(name,a,pp); } } else { if (a.mount.editfstab) { changes += VerifyNotInFstab(name,a,pp); } } if (changes) { CF_MOUNTALL = true; } } else { if (a.mount.unmount) { VerifyUnmount(name,a,pp); if (a.mount.editfstab) { VerifyNotInFstab(name,a,pp); } } else { cfPS(cf_inform,CF_NOP,"",pp,a," -> Filesystem %s seems to be mounted as promised\n",name); } } free(options); return true; } #endif /* NOT MINGW */ cfengine-3.2.4/src/recursion.c0000644000175000017500000001701211715232734013171 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: recursion.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int PushDirState(char *name,struct stat *sb); static void PopDirState(int goback,char * name,struct stat *sb,struct Recursion r); static void CheckLinkSecurity(struct stat *sb,char *name); /*********************************************************************/ /* Depth searches */ /*********************************************************************/ int DepthSearch(char *name,struct stat *sb,int rlevel,struct Attributes attr,struct Promise *pp) { CFDIR *dirh; int goback; const struct dirent *dirp; char path[CF_BUFSIZE]; struct stat lsb; if (!attr.havedepthsearch) /* if the search is trivial, make sure that we are in the parent dir of the leaf */ { char basedir[CF_BUFSIZE]; Debug(" -> Direct file reference %s, no search implied\n",name); snprintf(basedir, sizeof(basedir), "%s", name); ChopLastNode(basedir); chdir(basedir); return VerifyFileLeaf(name,sb,attr,pp); } if (rlevel > CF_RECURSION_LIMIT) { CfOut(cf_error,"","WARNING: Very deep nesting of directories (>%d deep): %s (Aborting files)",rlevel,name); return false; } if (rlevel > CF_RECURSION_LIMIT) { CfOut(cf_error,"","WARNING: Very deep nesting of directories (>%d deep): %s (Aborting files)",rlevel,name); return false; } memset(path,0,CF_BUFSIZE); Debug("To iterate is Human, to recurse is Divine...(%s)\n",name); if (!PushDirState(name,sb)) { return false; } if ((dirh = OpenDirLocal(".")) == NULL) { CfOut(cf_inform,"opendir","Could not open existing directory %s\n",name); return false; } for (dirp = ReadDir(dirh); dirp != NULL; dirp = ReadDir(dirh)) { if (!ConsiderFile(dirp->d_name,name,attr,pp)) { continue; } strcpy(path,name); AddSlash(path); if (!JoinPath(path,dirp->d_name)) { CloseDir(dirh); return true; } if (lstat(dirp->d_name,&lsb) == -1) { CfOut(cf_verbose,"lstat","Recurse was looking at %s when an error occurred:\n",path); continue; } if (S_ISLNK(lsb.st_mode)) /* should we ignore links? */ { if (!KillGhostLink(path,attr,pp)) { VerifyFileLeaf(path,&lsb,attr,pp); } else { continue; } } /* See if we are supposed to treat links to dirs as dirs and descend */ if (attr.recursion.travlinks && S_ISLNK(lsb.st_mode)) { if (lsb.st_uid != 0 && lsb.st_uid != getuid()) { CfOut(cf_inform,"","File %s is an untrusted link: cfengine will not follow it with a destructive operation",path); continue; } /* if so, hide the difference by replacing with actual object */ if (cfstat(dirp->d_name,&lsb) == -1) { CfOut(cf_error,"stat","Recurse was working on %s when this failed:\n",path); continue; } } if (attr.recursion.xdev && DeviceBoundary(&lsb,pp)) { CfOut(cf_verbose,"","Skipping %s on different device - use xdev option to change this\n",path); continue; } if (S_ISDIR(lsb.st_mode)) { if (SkipDirLinks(path,dirp->d_name,attr.recursion)) { continue; } if (attr.recursion.depth > 1 && rlevel <= attr.recursion.depth) { CfOut(cf_verbose,""," ->> Entering %s (%d)\n",path,rlevel); goback = DepthSearch(path,&lsb,rlevel+1,attr,pp); PopDirState(goback,name,sb,attr.recursion); VerifyFileLeaf(path,&lsb,attr,pp); } else { VerifyFileLeaf(path,&lsb,attr,pp); } } else { VerifyFileLeaf(path,&lsb,attr,pp); } } CloseDir(dirh); return true; } /*******************************************************************/ /* Level */ /*******************************************************************/ static int PushDirState(char *name,struct stat *sb) { if (chdir(name) == -1) { CfOut(cf_inform,"chdir","Could not change to directory %s, mode %o in tidy",name,sb->st_mode & 07777); return false; } else { Debug("Changed directory to %s\n",name); } CheckLinkSecurity(sb,name); return true; } /**********************************************************************/ static void PopDirState(int goback,char *name,struct stat *sb,struct Recursion r) { if (goback && r.travlinks) { if (chdir(name) == -1) { CfOut(cf_error,"chdir","Error in backing out of recursive travlink descent securely to %s",name); HandleSignals(SIGTERM); } CheckLinkSecurity(sb,name); } else if (goback) { if (chdir("..") == -1) { CfOut(cf_error,"chdir","Error in backing out of recursive descent securely to %s",name); HandleSignals(SIGTERM); } } } /**********************************************************************/ int SkipDirLinks(char *path,const char *lastnode,struct Recursion r) { Debug("SkipDirLinks(%s,%s)\n",path,lastnode); if (r.exclude_dirs) { if (MatchRlistItem(r.exclude_dirs,path) || MatchRlistItem(r.exclude_dirs,lastnode)) { CfOut(cf_verbose,"","Skipping matched excluded directory %s\n",path); return true; } } if (r.include_dirs) { if (!(MatchRlistItem(r.include_dirs,path) || MatchRlistItem(r.include_dirs,lastnode))) { CfOut(cf_verbose,"","Skipping matched non-included directory %s\n",path); return true; } } return false; } /**********************************************************************/ static void CheckLinkSecurity(struct stat *sb,char *name) { struct stat security; Debug("Checking the inode and device to make sure we are where we think we are...\n"); if (cfstat(".",&security) == -1) { CfOut(cf_error,"stat","Could not stat directory %s after entering!",name); return; } if ((sb->st_dev != security.st_dev) || (sb->st_ino != security.st_ino)) { CfOut(cf_error,"","SERIOUS SECURITY ALERT: path race exploited in recursion to/from %s. Not safe for agent to continue - aborting",name); HandleSignals(SIGTERM); /* Exits */ } } cfengine-3.2.4/src/client_protocol.c0000644000175000017500000003706511715232734014371 00000000000000 /* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: client_protocol.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void CheckServerVersion(struct cfagent_connection *conn,struct Attributes attr, struct Promise *pp); static void FreeRSAKey(RSA *key); /*********************************************************************/ static void SetSessionKey(struct cfagent_connection *conn); /*********************************************************************/ int IdentifyAgent(int sd,char *localip,int family) { char uname[CF_BUFSIZE], sendbuff[CF_BUFSIZE],dnsname[CF_BUFSIZE]; int len,err; #if defined(HAVE_GETADDRINFO) char myaddr[256]; /* Compilation trick for systems that don't know ipv6 */ #else struct sockaddr_in myaddr; struct in_addr *iaddr; struct hostent *hp; #endif memset(sendbuff,0,CF_BUFSIZE); memset(dnsname,0,CF_BUFSIZE); if (!SKIPIDENTIFY && (strcmp(VDOMAIN,CF_START_DOMAIN) == 0)) { CfOut(cf_error,"","Undefined domain name"); return false; } if (!SKIPIDENTIFY) { /* First we need to find out the IP address and DNS name of the socket we are sending from. This is not necessarily the same as VFQNAME if the machine has a different uname from its IP name (!) This can happen on poorly set up machines or on hosts with multiple interfaces, with different names on each interface ... */ switch (family) { case AF_INET: len = sizeof(struct sockaddr_in); break; #if defined(HAVE_GETADDRINFO) case AF_INET6: len = sizeof(struct sockaddr_in6); break; #endif default: CfOut(cf_error,"","Software error in IdentifyForVerification"); } if (getsockname(sd,(struct sockaddr *)&myaddr,&len) == -1) { CfOut(cf_error,"getsockname","Couldn't get socket address\n"); return false; } snprintf(localip,CF_MAX_IP_LEN-1,"%s",sockaddr_ntop((struct sockaddr *)&myaddr)); Debug("Identifying this agent as %s i.e. %s, with signature %d\n",localip,VFQNAME,CFSIGNATURE); #if defined(HAVE_GETADDRINFO) if ((err=getnameinfo((struct sockaddr *)&myaddr,len,dnsname,CF_MAXVARSIZE,NULL,0,0)) != 0) { CfOut(cf_error,"","Couldn't look up address v6 for %s: %s\n",dnsname,gai_strerror(err)); return false; } #else iaddr = &(myaddr.sin_addr); hp = gethostbyaddr((void *)iaddr,sizeof(myaddr.sin_addr),family); if ((hp == NULL) || (hp->h_name == NULL)) { CfOut(cf_error,"gethostbyaddr","Couldn't lookup IP address\n"); return false; } strncpy(dnsname,hp->h_name,CF_MAXVARSIZE); if ((strstr(hp->h_name,".") == 0) && (strlen(VDOMAIN) > 0)) { strcat(dnsname,"."); strcat(dnsname,VDOMAIN); } #endif } else { strcpy(localip,VIPADDRESS); if (strlen(VFQNAME) > 0) { CfOut(cf_verbose,"","skipidentify was promised, so we are trusting and simply announcing the identity as (%s) for this host\n",VFQNAME); strcat(dnsname,VFQNAME); } else { strcat(dnsname,"skipident"); } } /* client always identifies as root on windows */ #ifdef MINGW snprintf(uname, sizeof(uname), "%s", "root"); #else GetCurrentUserName(uname, sizeof(uname)); #endif /* Some resolvers will not return FQNAME and missing PTR will give numerical result */ if ((strlen(VDOMAIN) > 0) && !IsIPV6Address(dnsname) && !strchr(dnsname,'.')) { Debug("Appending domain %s to %s\n",VDOMAIN,dnsname); strcat(dnsname,"."); strncat(dnsname,VDOMAIN,CF_MAXVARSIZE/2); } if (strncmp(dnsname,localip,strlen(localip)) == 0) { /* Seems to be a bug in some resolvers that adds garbage, when it just returns the input */ strcpy(dnsname,localip); } if (strlen(dnsname) == 0) { strcpy(dnsname,localip); } snprintf(sendbuff,CF_BUFSIZE-1,"CAUTH %s %s %s %d",localip,dnsname,uname,CFSIGNATURE); Debug("SENT:::%s\n",sendbuff); SendTransaction(sd,sendbuff,0,CF_DONE); return true; } /*********************************************************************/ int AuthenticateAgent(struct cfagent_connection *conn,struct Attributes attr,struct Promise *pp) { char sendbuffer[CF_EXPANDSIZE],in[CF_BUFSIZE],*out,*decrypted_cchall; BIGNUM *nonce_challenge, *bn = NULL; unsigned long err; unsigned char digest[EVP_MAX_MD_SIZE]; int encrypted_len,nonce_len = 0,len,session_size; char dont_implicitly_trust_server,enterprise_field = 'c'; RSA *server_pubkey = NULL; if (PUBKEY == NULL || PRIVKEY == NULL) { CfOut(cf_error,"","No public/private key pair found\n"); return false; } enterprise_field = CfEnterpriseOptions(); session_size = CfSessionKeySize(enterprise_field); /* Generate a random challenge to authenticate the server */ nonce_challenge = BN_new(); BN_rand(nonce_challenge,CF_NONCELEN,0,0); nonce_len = BN_bn2mpi(nonce_challenge,in); if (FIPS_MODE) { HashString(in,nonce_len,digest,CF_DEFAULT_DIGEST); } else { HashString(in,nonce_len,digest,cf_md5); } /* We assume that the server bound to the remote socket is the official one i.e. = root's */ if ((server_pubkey = HavePublicKeyByIP(conn->username,conn->remoteip))) { dont_implicitly_trust_server = 'y'; encrypted_len = RSA_size(server_pubkey); } else { dont_implicitly_trust_server = 'n'; /* have to trust server, since we can't verify id */ encrypted_len = nonce_len; } // Server pubkey is what we want to has as a unique ID snprintf(sendbuffer,sizeof(sendbuffer),"SAUTH %c %d %d %c",dont_implicitly_trust_server,encrypted_len,nonce_len,enterprise_field); if ((out = malloc(encrypted_len)) == NULL) { FatalError("memory failure"); } if (server_pubkey != NULL) { if (RSA_public_encrypt(nonce_len,in,out,server_pubkey,RSA_PKCS1_PADDING) <= 0) { err = ERR_get_error(); cfPS(cf_error,CF_FAIL,"",pp,attr,"Public encryption failed = %s\n",ERR_reason_error_string(err)); free(out); FreeRSAKey(server_pubkey); return false; } memcpy(sendbuffer+CF_RSA_PROTO_OFFSET,out,encrypted_len); } else { memcpy(sendbuffer+CF_RSA_PROTO_OFFSET,in,nonce_len); } /* proposition C1 - Send challenge / nonce */ SendTransaction(conn->sd,sendbuffer,CF_RSA_PROTO_OFFSET+encrypted_len,CF_DONE); BN_free(bn); BN_free(nonce_challenge); free(out); if (DEBUG||D2) { RSA_print_fp(stdout,PUBKEY,0); } /*Send the public key - we don't know if server has it */ /* proposition C2 */ memset(sendbuffer,0,CF_EXPANDSIZE); len = BN_bn2mpi(PUBKEY->n,sendbuffer); SendTransaction(conn->sd,sendbuffer,len,CF_DONE); /* No need to encrypt the public key ... */ /* proposition C3 */ memset(sendbuffer,0,CF_EXPANDSIZE); len = BN_bn2mpi(PUBKEY->e,sendbuffer); SendTransaction(conn->sd,sendbuffer,len,CF_DONE); /* check reply about public key - server can break connection here */ /* proposition S1 */ memset(in,0,CF_BUFSIZE); if (ReceiveTransaction(conn->sd,in,NULL) == -1) { cfPS(cf_error,CF_INTERPT,"recv",pp,attr,"Protocol transaction broken off (1)"); FreeRSAKey(server_pubkey); return false; } if (BadProtoReply(in)) { CfOut(cf_error,"",in); FreeRSAKey(server_pubkey); return false; } /* Get challenge response - should be CF_DEFAULT_DIGEST of challenge */ /* proposition S2 */ memset(in,0,CF_BUFSIZE); if (ReceiveTransaction(conn->sd,in,NULL) == -1) { cfPS(cf_error,CF_INTERPT,"recv",pp,attr,"Protocol transaction broken off (2)"); FreeRSAKey(server_pubkey); return false; } if (HashesMatch(digest,in,CF_DEFAULT_DIGEST) || HashesMatch(digest,in,cf_md5)) // Legacy { if (dont_implicitly_trust_server == 'y') /* challenge reply was correct */ { CfOut(cf_verbose,"",".....................[.h.a.i.l.].................................\n"); CfOut(cf_verbose,"","Strong authentication of server=%s connection confirmed\n",pp->this_server); } else { if (attr.copy.trustkey) { CfOut(cf_verbose,""," -> Trusting server identity, promise to accept key from %s=%s",pp->this_server,conn->remoteip); } else { CfOut(cf_error,""," !! Not authorized to trust the server=%s's public key (trustkey=false)\n",pp->this_server); PromiseRef(cf_verbose,pp); FreeRSAKey(server_pubkey); return false; } } } else { cfPS(cf_error,CF_INTERPT,"",pp,attr,"Challenge response from server %s/%s was incorrect!",pp->this_server,conn->remoteip); FreeRSAKey(server_pubkey); return false; } /* Receive counter challenge from server */ Debug("Receive counter challenge from server\n"); /* proposition S3 */ memset(in,0,CF_BUFSIZE); encrypted_len = ReceiveTransaction(conn->sd,in,NULL); if (encrypted_len <= 0) { CfOut(cf_error,"","Protocol transaction sent illegal cipher length"); FreeRSAKey(server_pubkey); return false; } if ((decrypted_cchall = malloc(encrypted_len)) == NULL) { FatalError("memory failure"); } if (RSA_private_decrypt(encrypted_len,in,decrypted_cchall,PRIVKEY,RSA_PKCS1_PADDING) <= 0) { err = ERR_get_error(); cfPS(cf_error,CF_INTERPT,"",pp,attr,"Private decrypt failed = %s, abandoning\n",ERR_reason_error_string(err)); FreeRSAKey(server_pubkey); return false; } /* proposition C4 */ if (FIPS_MODE) { HashString(decrypted_cchall,nonce_len,digest,CF_DEFAULT_DIGEST); } else { HashString(decrypted_cchall,nonce_len,digest,cf_md5); } Debug("Replying to counter challenge with hash\n"); if (FIPS_MODE) { SendTransaction(conn->sd,digest,CF_DEFAULT_DIGEST_LEN,CF_DONE); } else { SendTransaction(conn->sd,digest,CF_MD5_LEN,CF_DONE); } free(decrypted_cchall); /* If we don't have the server's public key, it will be sent */ if (server_pubkey == NULL) { RSA *newkey = RSA_new(); CfOut(cf_verbose,""," -> Collecting public key from server!\n"); /* proposition S4 - conditional */ if ((len = ReceiveTransaction(conn->sd,in,NULL)) <= 0) { CfOut(cf_error,"","Protocol error in RSA authentation from IP %s\n",pp->this_server); return false; } if ((newkey->n = BN_mpi2bn(in,len,NULL)) == NULL) { err = ERR_get_error(); cfPS(cf_error,CF_INTERPT,"",pp,attr,"Private key decrypt failed = %s\n",ERR_reason_error_string(err)); FreeRSAKey(newkey); return false; } /* proposition S5 - conditional */ if ((len=ReceiveTransaction(conn->sd,in,NULL)) <= 0) { cfPS(cf_inform,CF_INTERPT,"",pp,attr,"Protocol error in RSA authentation from IP %s\n",pp->this_server); FreeRSAKey(newkey); return false; } if ((newkey->e = BN_mpi2bn(in,len,NULL)) == NULL) { err = ERR_get_error(); cfPS(cf_error,CF_INTERPT,"",pp,attr,"Public key decrypt failed = %s\n",ERR_reason_error_string(err)); FreeRSAKey(newkey); return false; } server_pubkey = RSAPublicKey_dup(newkey); FreeRSAKey(newkey); } /* proposition C5 */ SetSessionKey(conn); if (conn->session_key == NULL) { CfOut(cf_error,"","A random session key could not be established"); FreeRSAKey(server_pubkey); return false; } encrypted_len = RSA_size(server_pubkey); Debug("Encrypt %d bytes of session key into %d RSA bytes\n",session_size,encrypted_len); if ((out = malloc(encrypted_len)) == NULL) { FatalError("memory failure"); } if (RSA_public_encrypt(session_size,conn->session_key,out,server_pubkey,RSA_PKCS1_PADDING) <= 0) { err = ERR_get_error(); cfPS(cf_error,CF_INTERPT,"",pp,attr,"Public encryption failed = %s\n",ERR_reason_error_string(err)); free(out); FreeRSAKey(server_pubkey); return false; } SendTransaction(conn->sd,out,encrypted_len,CF_DONE); if (server_pubkey != NULL) { HashPubKey(server_pubkey,conn->digest,CF_DEFAULT_DIGEST); CfOut(cf_verbose,""," -> Public key identity of host \"%s\" is \"%s\"",conn->remoteip,HashPrint(CF_DEFAULT_DIGEST,conn->digest)); SavePublicKey(conn->username,conn->remoteip,HashPrint(CF_DEFAULT_DIGEST,conn->digest),server_pubkey); // FIXME: username is local LastSaw(conn->username,conn->remoteip,conn->digest,cf_connect); } free(out); FreeRSAKey(server_pubkey); return true; } /*********************************************************************/ static void FreeRSAKey(RSA *key) /* Maybe not needed - RSA_free(NULL) seems to work, but who knows * with older OpenSSL versions */ { if(key == NULL) { return; } RSA_free(key); } /*********************************************************************/ static void CheckServerVersion(struct cfagent_connection *conn,struct Attributes attr, struct Promise *pp) { char sendbuffer[CF_BUFSIZE]; char recvbuffer[CF_BUFSIZE]; int tosend; Debug("CheckRemoteVersion\n"); snprintf(sendbuffer,CF_BUFSIZE,"VERSION"); tosend = strlen(sendbuffer); if (SendTransaction(conn->sd,sendbuffer,tosend,CF_DONE) == -1) { cfPS(cf_inform,CF_INTERPT,"send",pp,attr,"Transmission failed while checking version"); return; } if (ReceiveTransaction(conn->sd,recvbuffer,NULL) == -1) { cfPS(cf_inform,CF_INTERPT,"send",pp,attr,"Reply failed while checking version"); conn->protoversion = 0; return; } if (BadProtoReply(recvbuffer)) { conn->protoversion = 0; return; } else { conn->protoversion = 1; return; } } /*********************************************************************/ /* Level */ /*********************************************************************/ static void SetSessionKey(struct cfagent_connection *conn) { BIGNUM *bp; int session_size = CfSessionKeySize(conn->encryption_type); bp = BN_new(); if(bp == NULL) { FatalError("Could not allocate session key"); } // session_size is in bytes if(!BN_rand(bp,session_size*8,-1,0)) { FatalError("Can't generate cryptographic key"); } //BN_print_fp(stdout,bp); conn->session_key = (unsigned char *)bp->d; } /*********************************************************************/ int BadProtoReply(char *buf) { Debug("Protoreply: (%s)\n",buf); return (strncmp(buf,"BAD:",4) == 0); } /*********************************************************************/ int OKProtoReply(char *buf) { return(strncmp(buf,"OK:",3) == 0); } /*********************************************************************/ int FailedProtoReply(char *buf) { return(strncmp(buf,CF_FAILEDSTR,strlen(CF_FAILEDSTR)) == 0); } cfengine-3.2.4/src/granules.c0000644000175000017500000001116311715232734013001 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: granules.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #include static char *PrintTimeSlot(int slot); /*****************************************************************************/ char *ConvTimeKey(char *str) { int i; char buf1[10],buf2[10],buf3[10],buf4[10],buf5[10],buf[10],out[10]; static char timekey[64]; sscanf(str,"%s %s %s %s %s",buf1,buf2,buf3,buf4,buf5); timekey[0] = '\0'; /* Day */ sprintf(timekey,"%s:",buf1); /* Hours */ sscanf(buf4,"%[^:]",buf); sprintf(out,"Hr%s",buf); strcat(timekey,out); /* Minutes */ sscanf(buf4,"%*[^:]:%[^:]",buf); sprintf(out,"Min%s",buf); strcat(timekey,":"); sscanf(buf,"%d",&i); switch ((i / 5)) { case 0: strcat(timekey,"Min00_05"); break; case 1: strcat(timekey,"Min05_10"); break; case 2: strcat(timekey,"Min10_15"); break; case 3: strcat(timekey,"Min15_20"); break; case 4: strcat(timekey,"Min20_25"); break; case 5: strcat(timekey,"Min25_30"); break; case 6: strcat(timekey,"Min30_35"); break; case 7: strcat(timekey,"Min35_40"); break; case 8: strcat(timekey,"Min40_45"); break; case 9: strcat(timekey,"Min45_50"); break; case 10: strcat(timekey,"Min50_55"); break; case 11: strcat(timekey,"Min55_00"); break; } return timekey; } /*****************************************************************************/ char *GenTimeKey(time_t now) { static char str[64]; char timebuf[26]; snprintf(str,sizeof(str),"%s",cf_strtimestamp_utc(now,timebuf)); return ConvTimeKey(str); } /*****************************************************************************/ int GetTimeSlot(time_t here_and_now) { time_t now; int slot = 0; char timekey[CF_MAXVARSIZE]; strcpy(timekey,GenTimeKey(here_and_now)); for (now = CF_MONDAY_MORNING; now < CF_MONDAY_MORNING+CF_WEEK; now += CF_MEASURE_INTERVAL,slot++) { if (strcmp(timekey,GenTimeKey(now)) == 0) { return slot; } } return -1; } /*****************************************************************************/ static char *PrintTimeSlot(int slot) { time_t now,i; for (now = CF_MONDAY_MORNING, i = 0; now < CF_MONDAY_MORNING+CF_WEEK; now += CF_MEASURE_INTERVAL,i++) { if (i == slot) { return GenTimeKey(now); } } return "UNKNOWN"; } /*****************************************************************************/ int GetShiftSlot(time_t here_and_now) { time_t now = time(NULL); int slot = 0, chour = -1; char cstr[64]; char str[64]; char buf[10],cbuf[10]; int hour = -1; char timebuf[26]; snprintf(cstr,sizeof(str),"%s",cf_strtimestamp_utc(here_and_now,timebuf)); sscanf(cstr,"%s %*s %*s %d",cbuf,&chour); // Format Tue Sep 28 14:58:27 CEST 2010 for (now = CF_MONDAY_MORNING; now < CF_MONDAY_MORNING+CF_WEEK; now += CF_SHIFT_INTERVAL,slot++) { snprintf(str,sizeof(str),"%s",cf_strtimestamp_utc(now,timebuf)); sscanf(str,"%s %*s %*s %d",buf,&hour); if ((hour/6 == chour/6) && (strcmp(cbuf,buf) == 0)) { return slot; } } return -1; } /*****************************************************************************/ time_t GetShiftSlotStart(time_t t) { return (t - (t % SECONDS_PER_SHIFT)); } cfengine-3.2.4/src/verify_methods.c0000644000175000017500000000742211715232734014213 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: verify_methods.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*****************************************************************************/ void VerifyMethodsPromise(struct Promise *pp) { struct Attributes a = {{0}}; a = GetMethodAttributes(pp); VerifyMethod(a,pp); DeleteScalar("this","promiser"); } /*****************************************************************************/ int VerifyMethod(struct Attributes a,struct Promise *pp) { struct Bundle *bp; void *vp; struct FnCall *fp; char method_name[CF_EXPANDSIZE]; struct Rlist *params = NULL; int retval = false; struct CfLock thislock; char lockname[CF_BUFSIZE]; if (a.havebundle) { if ((vp = GetConstraint("usebundle",pp,CF_FNCALL))) { fp = (struct FnCall *)vp; ExpandScalar(fp->name,method_name); params = fp->args; } else if ((vp = GetConstraint("usebundle",pp,CF_SCALAR))) { ExpandScalar((char *)vp,method_name); params = NULL; } else { return false; } } GetLockName(lockname,"method",pp->promiser,params); thislock = AcquireLock(lockname,VUQNAME,CFSTARTTIME,a,pp,false); if (thislock.lock == NULL) { return false; } PromiseBanner(pp); if ((bp = GetBundle(method_name,"agent"))) { char *bp_stack = THIS_BUNDLE; BannerSubBundle(bp,params); DeleteScope(bp->name); NewScope(bp->name); HashVariables(bp->name); AugmentScope(bp->name,bp->args,params); THIS_BUNDLE = bp->name; PushPrivateClassContext(); retval = ScheduleAgentOperations(bp); PopPrivateClassContext(); THIS_BUNDLE = bp_stack; if (retval) { cfPS(cf_verbose,CF_NOP,"",pp,a," -> Method invoked successfully\n"); } else { cfPS(cf_inform,CF_FAIL,"",pp,a," !! Method could not be invoked successfully\n"); } DeleteFromScope(bp->name,bp->args); } else { if (IsCf3VarString(method_name)) { CfOut(cf_error,""," !! A variable seems to have been used for the name of the method. In this case, the promiser also needs to contain the uique name of the method"); } if (bp && bp->name) { cfPS(cf_error,CF_FAIL,"",pp,a," !! Method \"%s\" was used but was not defined!\n",bp->name); } else { cfPS(cf_error,CF_FAIL,"",pp,a," !! A method attempted to use a bundle \"%s\" that was apparently not defined!\n",method_name); } } YieldCurrentLock(thislock); return retval; } cfengine-3.2.4/src/cf3.defs.h0000644000175000017500000013075011715232734012565 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: cf3.defs.h */ /* */ /*****************************************************************************/ #ifndef CFENGINE_CF3_DEFS_H #define CFENGINE_CF3_DEFS_H /* These files are hard links to the cfengine 2 sources */ #include "cf.defs.h" #include "cf.extern.h" #undef VERSION #undef Verbose #include "conf.h" #ifndef NGROUPS # define NGROUPS 20 #endif /*************************************************************************/ /* Fundamental (meta) types */ /*************************************************************************/ #define CF3COPYRIGHT "Copyright (C) CFEngine AS 2008,2010-" #define CF_SCALAR 's' #define CF_LIST 'l' #define CF_FNCALL 'f' #define CF_STACK 'k' #define CF_NOPROMISEE 'X' #define CF_UNDEFINED -1 #define CF_NODOUBLE -123.45 #define CF_NOINT -678L #define CF_ANYUSER (uid_t)-1 #define CF_ANYGROUP (gid_t)-1 #define CF_UNDEFINED_ITEM (void *)0x1234 #define CF_VARARGS 99 #define CF_UNKNOWN_IP "location unknown" #define CF_INBODY 1 #define CF_INBUNDLE 2 #define CF_MAX_NESTING 10 #define CF_MAX_REPLACE 20 #define CF_DONEPASSES 4 #define CF_TIME_SIZE 32 #define CF_FIPS_SIZE 32 #define CFPULSETIME 60 /*************************************************************************/ /** Design criteria */ /*************************************************************************/ #define CF_DUNBAR_INTIMATE 6 #define CF_DUNBAR_WORK 30 #define CF_DUNBAR_KNOW 120 /*************************************************************************/ /* Parsing and syntax tree structures */ /*************************************************************************/ #define CF_DEFINECLASSES "classes" #define CF_TRANSACTION "action" #define CF3_MODULES 15 /* This value needs to be incremented when adding modules */ /*************************************************************************/ struct PromiseParser { char *block; /* body/bundle */ char blocktype[CF_MAXVARSIZE]; char blockid[CF_MAXVARSIZE]; char filename[CF_MAXVARSIZE]; int line_pos; int line_no; int arg_nesting; int list_nesting; char lval[CF_MAXVARSIZE]; void *rval; char rtype; int isbody; char *promiser; void *promisee; char currentid[CF_MAXVARSIZE]; char currenttype[CF_MAXVARSIZE]; char *currentstring; char *currentclasses; struct Bundle *currentbundle; struct Body *currentbody; struct Promise *currentpromise; struct SubType *currentstype; struct Rlist *useargs; struct RList *currentRlist; char *currentfnid[CF_MAX_NESTING]; struct Rlist *giveargs[CF_MAX_NESTING]; struct FnCall *currentfncall[CF_MAX_NESTING]; }; /*************************************************************************/ /* Abstract datatypes */ /*************************************************************************/ enum cfdatatype { cf_str, cf_int, cf_real, cf_slist, cf_ilist, cf_rlist, cf_opts, cf_olist, cf_body, cf_bundle, cf_class, cf_clist, cf_irange, cf_rrange, cf_counter, cf_notype }; enum cfx_formatindex { cfb, cfe, }; enum cfx_format { cfx_head, cfx_bundle, cfx_block, cfx_blockheader, cfx_blockid, cfx_blocktype, cfx_args, cfx_promise, cfx_class, cfx_subtype, cfx_object, cfx_lval, cfx_rval, cfx_qstring, cfx_rlist, cfx_function, cfx_line, }; /*************************************************************************/ #define CF_COMMONC "common" #define CF_AGENTC "agent" #define CF_SERVERC "server" #define CF_MONITORC "monitor" #define CF_EXECC "executor" #define CF_KNOWC "knowledge" #define CF_RUNC "runagent" #define CF_REPORTC "reporter" #define CF_KEYGEN "keygenerator" #define CF_HUBC "hub" enum cfagenttype { cf_common, cf_agent, cf_server, cf_monitor, cf_executor, cf_runagent, cf_know, cf_report, cf_keygen, cf_hub, cf_noagent }; /*************************************************************************/ enum cfgcontrol { cfg_bundlesequence, cfg_goalcategories, cfg_goalpatterns, cfg_ignore_missing_bundles, cfg_ignore_missing_inputs, cfg_inputs, cfg_version, cfg_lastseenexpireafter, cfg_output_prefix, cfg_domain, cfg_require_comments, cfg_licenses, cfg_site_classes, cfg_syslog_host, cfg_syslog_port, cfg_fips_mode, cfg_noagent }; /*************************************************************************/ enum cfacontrol { cfa_abortclasses, cfa_abortbundleclasses, cfa_addclasses, cfa_agentaccess, cfa_agentfacility, cfa_alwaysvalidate, cfa_auditing, cfa_binarypaddingchar, cfa_bindtointerface, cfa_hashupdates, cfa_childlibpath, cfa_checksum_alert_time, cfa_defaultcopytype, cfa_dryrun, cfa_editbinaryfilesize, cfa_editfilesize, cfa_environment, cfa_exclamation, cfa_expireafter, cfa_fsinglecopy, cfa_fautodefine, cfa_hostnamekeys, cfa_ifelapsed, cfa_inform, cfa_intermittency, cfa_max_children, cfa_maxconnections, cfa_mountfilesystems, cfa_nonalphanumfiles, cfa_repchar, cfa_refresh_processes, cfa_repository, cfa_secureinput, cfa_sensiblecount, cfa_sensiblesize, cfa_skipidentify, cfa_suspiciousnames, cfa_syslog, cfa_track_value, cfa_timezone, cfa_timeout, cfa_verbose, cfa_notype, }; /*************************************************************************/ enum cfexcontrol { cfex_splaytime, cfex_mailfrom, cfex_mailto, cfex_smtpserver, cfex_mailmaxlines, cfex_schedule, cfex_executorfacility, cfex_execcommand, cfex_notype, }; /*************************************************************************/ enum cfmcontrol { cfm_forgetrate, cfm_monitorfacility, cfm_histograms, cfm_tcpdump, cfm_notype, }; /*************************************************************************/ enum cfrcontrol { cfr_hosts, cfr_portnumber, cfr_force_ipv4, cfr_trustkey, cfr_encrypt, cfr_background, cfr_maxchild, cfr_output_to_file, cfr_output_directory, cfr_timeout, cfr_notype }; /*************************************************************************/ enum cfscontrol { cfs_allowallconnects, cfs_allowconnects, cfs_allowusers, cfs_auditing, cfs_bindtointerface, cfs_cfruncommand, cfs_denybadclocks, cfs_denyconnects, cfs_dynamicaddresses, cfs_hostnamekeys, cfs_keyttl, cfs_logallconnections, cfs_logencryptedtransfers, cfs_maxconnections, cfs_portnumber, cfs_serverfacility, cfs_skipverify, cfs_trustkeysfrom, cfs_notype, }; /*************************************************************************/ enum cfkcontrol { cfk_builddir, cfk_docroot, cfk_genman, cfk_graph_dir, cfk_graph_output, cfk_htmlbanner, cfk_htmlfooter, cfk_tm_prefix, cfk_mandir, cfk_query_engine, cfk_query_output, cfk_sql_type, cfk_sql_database, cfk_sql_owner, cfk_sql_passwd, cfk_sql_server, cfk_sql_connect_db, cfk_stylesheet, cfk_views, cfk_view_projection, cfk_notype }; /*************************************************************************/ enum cfrecontrol { cfre_aggregation_point, cfre_autoscale, cfre_builddir, cfre_csv, cfre_errorbars, cfre_htmlbanner, cfre_html_embed, cfre_htmlfooter, cfre_query_engine, cfre_reports, cfre_report_output, cfre_stylesheet, cfre_timestamps, cfre_notype }; /*************************************************************************/ enum cfhcontrol { cfh_export_zenoss, cfh_federation, cfh_exclude_hosts, cfh_schedule, cfh_port, cfh_notype }; /*************************************************************************/ enum cfsbundle { cfs_access, cfs_nobtype }; enum cfsrole { cfs_authorize, cfs_nortype }; enum cfspromises { cfs_admit, cfs_deny, cfs_maproot, cfs_encrypted, cfs_noptype }; enum cfreport { cf_inform, cf_verbose, cf_error, cf_log, cf_reporting, cf_cmdout, cf_noreport }; enum cfeditorder { cfe_before, cfe_after }; /*************************************************************************/ /* Syntax module range/pattern constants for type validation */ /*************************************************************************/ #define CF_BUNDLE (void*)1234 /* any non-null value, not used */ #define CF_HIGHINIT 99999L #define CF_LOWINIT -999999L #define CF_SIGNALRANGE "hup,int,trap,kill,pipe,cont,abrt,stop,quit,term,child,usr1,usr2,bus,segv" #define CF_BOOL "true,false,yes,no,on,off" #define CF_LINKRANGE "symlink,hardlink,relative,absolute" #define CF_TIMERANGE "0,2147483647" #define CF_VALRANGE "0,99999999999" #define CF_INTRANGE "-99999999999,9999999999" #define CF_INTLISTRANGE "[-0-9_$(){}\\[\\].]+" #define CF_REALRANGE "-9.99999E100,9.99999E100" #define CF_CHARRANGE "^.$" #define CF_NULL_VALUE "cf_null" #define CF_MODERANGE "[0-7augorwxst,+-]+" #define CF_BSDFLAGRANGE "[+-]*[(arch|archived|nodump|opaque|sappnd|sappend|schg|schange|simmutable|sunlnk|sunlink|uappnd|uappend|uchg|uchange|uimmutable|uunlnk|uunlink)]+" #define CF_CLASSRANGE "[a-zA-Z0-9_!&@@$|.()\\[\\]{}]+" #define CF_IDRANGE "[a-zA-Z0-9_$(){}\\[\\].]+" #define CF_USERRANGE "[a-zA-Z0-9_$.-]+" #define CF_IPRANGE "[a-zA-Z0-9_$(){}.:-]+" #define CF_FNCALLRANGE "[a-zA-Z0-9_(){}.$@]+" #define CF_NAKEDLRANGE "@[(][a-zA-Z0-9]+[)]" #define CF_ANYSTRING ".*" #ifndef MINGW #define CF_ABSPATHRANGE "\042?(/.*)" #else // can start with e.g. c:\... or "c:\... | unix (for Cygwin-style paths) #define CF_ABSPATHRANGE "\042?(([a-zA-Z]:\\\\.*)|(/.*))" #endif /* Any non-empty string can be an absolute path under Unix */ #define CF_PATHRANGE ".+" #define CF_LOGRANGE "stdout|udp_syslog|(\042?[a-zA-Z]:\\\\.*)|(/.*)" #define CF_FACILITY "LOG_USER,LOG_DAEMON,LOG_LOCAL0,LOG_LOCAL1,LOG_LOCAL2,LOG_LOCAL3,LOG_LOCAL4,LOG_LOCAL5,LOG_LOCAL6,LOG_LOCAL7" // Put this here now for caching efficiency #define SOFTWARE_PACKAGES_CACHE "software_packages.csv" /***************************************************************************/ /* Knowledge relationships */ /***************************************************************************/ enum storytype { cfi_cause, cfi_connect, cfi_part, cfi_access, cfi_none }; #define KM_AFFECTS_CERT_F "affects" #define KM_AFFECTS_CERT_B "is affected by" #define KM_CAUSE_CERT_F "causes" #define KM_CAUSE_CERT_B "is caused by" #define KM_PARTOF_CERT_F "is/are a part of" #define KM_PARTOF_CERT_B "has/have a part" #define KM_DETERMINES_CERT_F "determine(s)" #define KM_DETERMINES_CERT_B "is/are determined by" #define KM_CONTRIBUTES_CERT_F "contibutes to" #define KM_CONTRIBUTES_CERT_B "is contibuted to by" #define KM_USES_CERT_F "use(s)" #define KM_USES_CERT_B "is/are used by" #define KM_PROVIDES_CERT_F "provide(s)" #define KM_PROVIDES_CERT_B "is/are provided by" #define KM_BELONGS_CERT_F "belongs to" #define KM_BELONGS_CERT_B "owns" #define KM_CONNECTS_CERT_F "connects to" #define KM_CONNECTS_CERT_B "connects to" #define KM_NEEDS_CERT_F "need(s)" #define KM_NEEDS_CERT_B "is needed by" #define KM_EQUIV_CERT_F "is equivalent to" #define KM_EQUIV_CERT_B "is equivalent to" #define KM_SHIELD_CERT_F "denies access from" #define KM_SHIELD_CERT_B "is not allowed access to" #define KM_ACCESS_CERT_F "grants access to" #define KM_ACCESS_CERT_B "is allowed to access" #define KM_MONITOR_CERT_F "monitor(s)" #define KM_MONITOR_CERT_B "is/are monitored by" #define KM_LOCATED_CERT_F "is located in" #define KM_LOCATED_CERT_B "situates" #define KM_REPAIR_CERT_F "repairs" #define KM_REPAIR_CERT_B "is repaired by" #define KM_CAUSE_POSS_F "can cause" #define KM_CAUSE_POSS_B "can be caused by" #define KM_PARTOF_POSS_F "can be a part of" #define KM_PARTOF_POSS_B "can have a part" #define KM_DETERMINES_POSS_F "can determine" #define KM_DETERMINES_POSS_B "can be determined by" #define KM_CONTRIBUTES_POSS_F "can contibute to" #define KM_CONTRIBUTES_POSS_B "can be contibuted to by" #define KM_USES_POSS_F "can use" #define KM_USES_POSS_B "can be used by" #define KM_PROVIDES_POSS_F "can provide" #define KM_PROVIDES_POSS_B "can be provided by" #define KM_BELONGS_POSS_F "can belong to" #define KM_BELONGS_POSS_B "can own" #define KM_AFFECTS_POSS_F "can affect" #define KM_AFFECTS_POSS_B "can be affected by" #define KM_CONNECTS_POSS_F "can connect to" #define KM_CONNECTS_POSS_B "can connect to" #define KM_NEEDS_POSS_F "can need" #define KM_NEEDS_POSS_B "can be needed by" #define KM_EQUIV_POSS_F "can be equivalent to" #define KM_EQUIV_POSS_B "can be equivalent to" #define KM_MONITOR_POSS_F "can monitor" #define KM_MONITOR_POSS_B "can be monitored by" #define KM_ACCESS_POSS_F "can access to" #define KM_ACCESS_POSS_B "can be allowed to access" #define KM_LOCATED_POSS_F "can be located in" #define KM_LOCATED_POSS_B "can situate" #define KM_REPAIR_POSS_F "can repair" #define KM_REPAIR_POSS_B "can be repaired by" #define KM_CAUSE_UNCERT_F "might cause" #define KM_CAUSE_UNCERT_B "might be caused by" #define KM_PARTOF_UNCERT_F "might be a part of" #define KM_PARTOF_UNCERT_B "might have a part" #define KM_DETERMINES_UNCERT_F "might determine" #define KM_DETERMINES_UNCERT_B "might be determined by" #define KM_CONTRIBUTES_UNCERT_F "might contibute to" #define KM_CONTRIBUTES_UNCERT_B "might be contibuted to by" #define KM_USES_UNCERT_F "might use" #define KM_USES_UNCERT_B "might be used by" #define KM_PROVIDES_UNCERT_F "might provide" #define KM_PROVIDES_UNCERT_B "might be provided by" #define KM_BELONGS_UNCERT_F "might belong to" #define KM_BELONGS_UNCERT_B "might own" #define KM_AFFECTS_UNCERT_F "might affect" #define KM_AFFECTS_UNCERT_B "might be affected by" #define KM_CONNECTS_UNCERT_F "might connect to" #define KM_CONNECTS_UNCERT_B "might connect to" #define KM_NEEDS_UNCERT_F "might need" #define KM_NEEDS_UNCERT_B "might be needed by" #define KM_EQUIV_UNCERT_F "might be equivalent to" #define KM_EQUIV_UNCERT_B "might be equivalent to" #define KM_SHIELD_UNCERT_F "might deny access from" #define KM_SHIELD_UNCERT_B "might not be allowed access to" #define KM_MONITOR_UNCERT_F "might monitor" #define KM_MONITOR_UNCERT_B "might be monitored by" #define KM_ACCESS_UNCERT_F "might grant access to" #define KM_ACCESS_UNCERT_B "might be allowed to access" #define KM_LOCATED_UNCERT_F "might be located in" #define KM_LOCATED_UNCERT_B "might situate" #define KM_REPAIR_UNCERT_F "might repair" #define KM_REPAIR_UNCERT_B "might be repaired by" #define KM_GENERALIZES_F "is a generalization of" #define KM_GENERALIZES_B "is a special case of" #define KM_SYNONYM "is a synonym for" enum knowledgecertainty { cfk_certain, cfk_uncertain, cfk_possible }; /*************************************************************************/ struct BodySyntax { char *lval; enum cfdatatype dtype; void *range; /* either char or struct BodySyntax **/ char *description; }; struct BodyDefault { char *lval; char *rval; }; /*************************************************************************/ struct SubTypeSyntax { char *btype; char *subtype; struct BodySyntax *bs; }; /*************************************************************************/ struct FnCall; typedef struct FnCallType { char *name; enum cfdatatype dtype; int numargs; struct FnCallArg *args; struct Rval (*impl)(struct FnCall *, struct Rlist *); char *description; } FnCallType; struct FnCallArg { char *pattern; enum cfdatatype dtype; char *description; }; /*************************************************************************/ #define UNKNOWN_FUNCTION -1 /*************************************************************************/ struct Bundle { char *type; char *name; struct Rlist *args; struct SubType *subtypes; struct Bundle *next; }; /*************************************************************************/ struct Body { char *type; char *name; struct Rlist *args; struct Constraint *conlist; struct Body *next; }; /*************************************************************************/ struct SubType { char *name; struct Promise *promiselist; struct SubType *next; }; /*************************************************************************/ struct edit_context { char *filename; struct Item *file_start; struct Item *file_classes; int num_edits; int empty_first; }; /*************************************************************************/ struct Promise { char *classes; char *ref; /* comment */ char ref_alloc; char *promiser; void *promisee; /* Can be a general rval */ char petype; /* rtype of promisee - list or scalar recipient? */ int lineno; char *bundle; struct Audit *audit; struct Constraint *conlist; struct Promise *next; /* Runtime bus for private flags and work space */ char *agentsubtype; /* cache the promise subtype */ char *bundletype; /* cache the agent type */ int done; /* this needs to be preserved across runs */ int *donep; /* used by locks to mark as done */ int makeholes; char *this_server; struct cfstat *cache; struct cfagent_connection *conn; struct CompressedArray *inode_cache; struct edit_context *edcontext; dev_t rootdevice; /* for caching during work*/ }; /*************************************************************************/ struct PromiseIdent { char *handle; char *filename; char *classes; int lineno; struct PromiseIdent *next; }; /*************************************************************************/ struct Constraint { char *lval; void *rval; /* should point to either string, Rlist or FnCall */ char type; /* scalar, list, or function */ char *classes; /* only used within bodies */ int lineno; int isbody; struct Audit *audit; struct Constraint *next; }; /*************************************************************************/ /* Rvalues and lists - basic workhorse structure */ /*************************************************************************/ /* In an OO language one would probably think of Rval as a parent class and CF_SCALAR, CF_LIST and CF_FNCALL as children. There is more or less a sub-type polymorphism going on in the code around these structures, but it is not a proper inheritance relationship as lists could contain functions which return lists or scalars etc.. */ /*************************************************************************/ struct Rval { void *item; /* (char *), (struct Rlist *), or (struct FnCall) */ char rtype; /* Points to CF_SCALAR, CF_LIST, CF_FNCALL usually */ }; /*************************************************************************/ struct Rlist { void *item; char type; struct Rlist *state_ptr; /* Points to "current" state/element of sub-list */ struct Rlist *next; }; /*************************************************************************/ struct FnCall { char *name; struct Rlist *args; int argc; }; /*******************************************************************/ /* Variable processing */ /*******************************************************************/ struct Scope /* $(bundlevar) $(scope.name) */ { char *scope; /* Name of scope */ struct CfAssoc *hashtable[CF_HASHTABLESIZE]; /* Variable heap */ struct Scope *next; }; /*******************************************************************/ typedef struct CfAssoc /* variable reference linkage , with metatype*/ { char *lval; void *rval; char rtype; enum cfdatatype dtype; } CfAssoc; /*******************************************************************/ /* * Disposable iterator over hash table. Does not require deinitialization. */ typedef struct HashIterator { CfAssoc **hash; int bucket; } HashIterator; /*******************************************************************/ /* Return value signalling */ /*******************************************************************/ #define FNCALL_NOP -1 #define FNCALL_SUCCESS 0 #define FNCALL_FAILURE 1 #define FNCALL_ALERT 2 struct FnCallStatus /* from builtin functions */ { int status; char message[CF_BUFSIZE]; char fncall_classes[CF_BUFSIZE]; /* set by functions in the form fncall_CLASS */ }; /*******************************************************************/ /* Return value signalling */ /*******************************************************************/ enum cfinterval { cfa_hourly, cfa_daily, cfa_nointerval }; enum cfdatetemplate { cfa_year, cfa_month, cfa_day, cfa_hour, cfa_min, cfa_sec }; enum cfcomparison { cfa_atime, cfa_mtime, cfa_ctime, cfa_checksum, cfa_hash, cfa_binary, cfa_exists, cfa_nocomparison }; enum cflinktype { cfa_symlink, cfa_hardlink, cfa_relative, cfa_absolute, cfa_notlinked }; enum cfopaction { cfa_fix, cfa_warn, }; enum cfbackupoptions { cfa_backup, cfa_nobackup, cfa_timestamp, cfa_repos_store/* for internal use only */ }; enum cftidylinks { cfa_linkdelete, cfa_linkkeep }; enum cfhashes { cf_md5, cf_sha224, cf_sha256, cf_sha384, cf_sha512, cf_sha1, cf_sha, cf_besthash, cf_crypt, cf_nohash }; enum cfnofile { cfa_force, cfa_delete, cfa_skip }; enum cflinkchildren { cfa_override, cfa_onlynonexisting }; enum cfchanges { cfa_noreport, cfa_contentchange, cfa_statschange, cfa_allchanges }; enum signalnames { cfa_hup, cfa_int, cfa_trap, cfa_kill, cfa_pipe, cfa_cont, cfa_abrt, cfa_stop, cfa_quit, cfa_term, cfa_child, cfa_usr1, cfa_usr2, cfa_bus, cfa_segv }; enum representations { cfk_url, cfk_web, cfk_file, cfk_db, cfk_literal, cfk_image, cfk_portal, cfk_none }; enum package_actions { cfa_addpack, cfa_deletepack, cfa_reinstall, cfa_update, cfa_addupdate, cfa_patch, cfa_verifypack, cfa_pa_none }; enum version_cmp { cfa_eq, cfa_neq, cfa_gt, cfa_lt, cfa_ge, cfa_le, cfa_cmp_none }; enum action_policy { cfa_individual, cfa_bulk, cfa_no_ppolicy }; enum cf_thread_mutex /* Adding: *) Add enum here *) Add mutex in cf3globals.c and cf.extern.h *) Add enum -> mutex in NameToThreadMutex() */ { cft_system, cft_count, cft_getaddr, cft_lock, cft_output, cft_dbhandle, cft_policy, // protects structs for refreshing policy files cft_db_lastseen, // lastseen dbs (in cf-serverd) cft_no_tpolicy, cft_report, cft_vscope, // protects VSCOPE cft_server_keyseen, // protects SERVER_KEYSEEN cft_server_children, }; enum cf_status { cfn_repaired, cfn_notkept, cfn_kept, cfn_nop }; /************************************************************************************/ enum cf_acl_method { cfacl_append, cfacl_overwrite, cfacl_nomethod }; enum cf_acl_type { cfacl_generic, cfacl_posix, cfacl_ntfs, cfacl_notype }; enum cf_acl_inherit { cfacl_nochange, cfacl_specify, cfacl_parent, cfacl_clear, cfacl_noinherit, }; struct CfACL { enum cf_acl_method acl_method; enum cf_acl_type acl_type; enum cf_acl_inherit acl_directory_inherit; struct Rlist *acl_entries; struct Rlist *acl_inherit_entries; }; typedef enum { INHERIT_ACCESS_ONLY, INHERIT_DEFAULT_ONLY, INHERIT_ACCESS_AND_DEFAULT } inherit_t; enum insert_match { cf_ignore_leading, cf_ignore_trailing, cf_ignore_embedded, cf_exact_match }; enum monitord_rep { mon_rep_mag, mon_rep_week, mon_rep_yr }; enum software_rep { sw_rep_installed, sw_rep_patch_avail, sw_rep_patch_installed }; enum promiselog_rep { plog_repaired, plog_notkept }; enum time_window { time_hour, time_day, time_week }; /*************************************************************************/ enum cfd_menu { cfd_menu_delta, cfd_menu_full, cfd_menu_relay, cfd_menu_error }; /*************************************************************************/ /* Runtime constraint structures */ /*************************************************************************/ #define OVECCOUNT 30 /*******************************************************************/ struct CfKeyBinding { char *name; RSA *key; char *address; time_t timestamp; }; /*************************************************************************/ struct CfKeyHostSeen { char address[CF_ADDRSIZE]; struct QPoint Q; }; /*************************************************************************/ struct CfLock { char *last; char *lock; char *log; }; /*************************************************************************/ struct CfMount { char *host; char *source; char *mounton; char *options; int unmount; }; /*************************************************************************/ struct Recursion { int travlinks; int rmdeadlinks; int depth; int xdev; int include_basedir; struct Rlist *include_dirs; struct Rlist *exclude_dirs; }; /*************************************************************************/ struct TransactionContext { enum cfopaction action; int ifelapsed; int expireafter; int background; char *log_string; char *log_kept; char *log_repaired; char *log_failed; int log_priority; char *measure_id; double value_kept; double value_notkept; double value_repaired; int audit; enum cfreport report_level; enum cfreport log_level; }; /*************************************************************************/ struct DefineClasses { struct Rlist *change; struct Rlist *failure; struct Rlist *denied; struct Rlist *timeout; struct Rlist *kept; struct Rlist *interrupt; int persist; enum statepolicy timer; struct Rlist *del_change; struct Rlist *del_kept; struct Rlist *del_notkept; struct Rlist *retcode_kept; struct Rlist *retcode_repaired; struct Rlist *retcode_failed; }; /*************************************************************************/ /* Ontology */ /*************************************************************************/ struct Topic { int id; char *topic_context; char *topic_name; double evc; struct TopicAssociation *associations; struct Topic *next; }; struct TopicAssociation { char *fwd_context; char *fwd_name; char *bwd_name; struct Item *associates; char *bwd_context; struct TopicAssociation *next; }; struct Occurrence { char *occurrence_context; char *locator; /* Promiser */ enum representations rep_type; struct Rlist *represents; /* subtype represented by promiser */ struct Occurrence *next; }; struct Inference { char *inference; // Promiser char *precedent; char *qualifier; struct Inference *next; }; /*************************************************************************/ /* SQL Database connectors */ /*************************************************************************/ enum cfdbtype { cfd_mysql, cfd_postgres, cfd_notype }; typedef struct { int connected; int result; int row; unsigned int maxcolumns; unsigned int maxrows; int column; char **rowdata; char *blank; enum cfdbtype type; void *data; /* Generic pointer to RDBMS-specific data */ } CfdbConn; /*************************************************************************/ /* Threading container */ /*************************************************************************/ struct PromiseThread { enum cfagenttype agent; char *scopeid; struct Promise *pp; void *fnptr; }; /*************************************************************************/ /* Package promises */ /*************************************************************************/ struct CfPackageManager { char *manager; enum package_actions action; enum action_policy policy; struct CfPackageItem *pack_list; struct CfPackageItem *patch_list; struct CfPackageItem *patch_avail; struct CfPackageManager *next; }; /*************************************************************************/ struct CfPackageItem { char *name; char *version; char *arch; struct Promise *pp; struct CfPackageItem *next; }; /*************************************************************************/ /* Files */ /*************************************************************************/ struct FileCopy { char *source; char *destination; enum cfcomparison compare; enum cflinktype link_type; struct Rlist *servers; struct Rlist *link_instead; struct Rlist *copy_links; enum cfbackupoptions backup; int stealth; int preserve; int collapse; int check_root; int type_check; int force_update; int force_ipv4; size_t min_size; /* Safety margin not search criterion */ size_t max_size; int trustkey; int encrypt; int verify; int purge; short portnumber; short timeout; }; struct ServerItem { char *server; struct cfagent_connection *conn; int busy; }; /*************************************************************************/ struct CfState { unsigned int expires; enum statepolicy policy; }; /*************************************************************************/ struct FilePerms { mode_t plus; mode_t minus; struct UidList *owners; struct GidList *groups; char *findertype; u_long plus_flags; /* for *BSD chflags */ u_long minus_flags; /* for *BSD chflags */ int rxdirs; }; /*************************************************************************/ struct FileSelect { struct Rlist *name; struct Rlist *path; struct Rlist *perms; struct Rlist *bsdflags; struct Rlist *owners; struct Rlist *groups; long max_size; long min_size; time_t max_ctime; time_t min_ctime; time_t max_mtime; time_t min_mtime; time_t max_atime; time_t min_atime; char *exec_regex; char *exec_program; struct Rlist *filetypes; struct Rlist *issymlinkto; char *result; }; /*************************************************************************/ struct FileDelete { enum cftidylinks dirlinks; int rmdirs; }; /*************************************************************************/ struct FileRename { char *newname; char *disable_suffix; int disable; int rotate; mode_t plus; mode_t minus; }; /*************************************************************************/ struct FileChange { enum cfhashes hash; enum cfchanges report_changes; int report_diffs; int update; }; /*************************************************************************/ struct FileLink { char *source; enum cflinktype link_type; struct Rlist *copy_patterns; enum cfnofile when_no_file; enum cflinkchildren when_linking_children; int link_children; }; /*************************************************************************/ struct ExecContain { int useshell; mode_t umask; uid_t owner; gid_t group; char *chdir; char *chroot; int preview; int nooutput; int timeout; }; /*************************************************************************/ struct ProcessCount { long min_range; long max_range; struct Rlist *in_range_define; struct Rlist *out_of_range_define; }; /*************************************************************************/ struct ProcessSelect { struct Rlist *owner; long min_pid; long max_pid; long min_ppid; long max_ppid; long min_pgid; long max_pgid; long min_rsize; long max_rsize; long min_vsize; long max_vsize; time_t min_ttime; time_t max_ttime; time_t min_stime; time_t max_stime; long min_pri; long max_pri; long min_thread; long max_thread; char *status; char *command; char *tty; char *process_result; }; /*************************************************************************/ struct Context { struct Constraint *expression; int broken; }; /*************************************************************************/ struct EditDefaults { enum cfbackupoptions backup; int empty_before_use; int maxfilesize; int joinlines; }; /*************************************************************************/ struct LineSelect { struct Rlist *startwith_from_list; struct Rlist *not_startwith_from_list; struct Rlist *match_from_list; struct Rlist *not_match_from_list; struct Rlist *contains_from_list; struct Rlist *not_contains_from_list; }; struct EditLocation { char *line_matching; enum cfeditorder before_after; char *first_last; }; struct EditRegion { char *select_start; char *select_end; int include_start; int include_end; }; struct EditColumn { char *column_separator; int select_column; char value_separator; char *column_value; char *column_operation; int extend_columns; int blanks_ok; }; struct EditReplace { char *replace_value; char *occurrences; }; /*************************************************************************/ struct StorageMount { char *mount_type; char *mount_source; char *mount_server; struct Rlist *mount_options; int editfstab; int unmount; }; struct StorageVolume { int check_foreign; long freespace; int sensible_size; int sensible_count; int scan_arrivals; }; /*************************************************************************/ struct Report { int haveprintfile; int havelastseen; int lastseen; double intermittency; char *friend_pattern; char *filename; char *to_file; int numlines; struct Rlist *showstate; }; /*************************************************************************/ struct Packages { enum package_actions package_policy; int have_package_methods; char *package_version; struct Rlist *package_architectures; enum version_cmp package_select; enum action_policy package_changes; struct Rlist *package_file_repositories; char *package_list_command; char *package_list_version_regex; char *package_list_name_regex; char *package_list_arch_regex; char *package_patch_list_command; char *package_patch_version_regex; char *package_patch_name_regex; char *package_patch_arch_regex; char *package_patch_installed_regex; char *package_list_update_command; int package_list_update_ifelapsed; char *package_version_regex; char *package_name_regex; char *package_arch_regex; char *package_installed_regex; char *package_add_command; char *package_delete_command; char *package_update_command; char *package_patch_command; char *package_verify_command; char *package_noverify_regex; char *package_name_convention; char *package_delete_convention; char *package_multiline_start; int package_noverify_returncode; }; /*************************************************************************/ struct Measurement { char *stream_type; enum cfdatatype data_type; char *history_type; char *select_line_matching; int select_line_number; char *extraction_regex; char *units; int growing; }; /*************************************************************************/ struct CfTcpIp { char *ipv4_address; char *ipv4_netmask; }; /*************************************************************************/ struct CfDatabase { char *db_server_owner; char *db_server_password; char *db_server_host; char *db_connect_db; enum cfdbtype db_server_type; char *server; char *type; char *operation; struct Rlist *columns; struct Rlist *rows; struct Rlist *exclude; }; /*************************************************************************/ enum cf_srv_policy { cfsrv_start, cfsrv_stop, cfsrv_disable, cfsrv_nostatus }; struct CfServices { struct Rlist *service_depend; char *service_type; char *service_args; enum cf_srv_policy service_policy; char *service_autostart_policy; char *service_depend_chain; }; /*************************************************************************/ struct Outputs { char *level; char *promiser_type; }; /*************************************************************************/ enum cfhypervisors { cfv_virt_xen, cfv_virt_kvm, cfv_virt_esx, cfv_virt_test, cfv_virt_xen_net, cfv_virt_kvm_net, cfv_virt_esx_net, cfv_virt_test_net, cfv_zone, cfv_ec2, cfv_eucalyptus, cfv_none }; enum cfenvironment_state { cfvs_create, cfvs_delete, cfvs_running, cfvs_suspended, cfvs_down, cfvs_none }; struct CfEnvironments { int cpus; int memory; int disk; char *baseline; char *specfile; struct Rlist *addresses; char *name; char *host; char *type; enum cfenvironment_state state; }; /*************************************************************************/ /* This is huge, but the simplification of logic is huge too so we leave it to the compiler to optimize */ struct Attributes { struct Outputs output; struct FileSelect select; struct FilePerms perms; struct FileCopy copy; struct FileDelete delete; struct FileRename rename; struct FileChange change; struct FileLink link; struct EditDefaults edits; struct Packages packages; struct Context context; struct Measurement measure; struct CfACL acl; struct CfDatabase database; struct CfServices service; struct CfEnvironments env; char *transformer; char *pathtype; char *repository; int touch; int create; int move_obstructions; struct Recursion recursion; struct TransactionContext transaction; struct DefineClasses classes; struct ExecContain contain; char *args; int module; struct Rlist *signals; char *process_stop; char *restart_class; struct ProcessCount process_count; struct ProcessSelect process_select; struct Report report; struct StorageMount mount; struct StorageVolume volume; struct CfTcpIp tcpip; int havedepthsearch; int haveselect; int haverename; int havedelete; int haveperms; int havechange; int havecopy; int havelink; int haveeditline; int haveeditxml; int haveedit; int havecontain; int haveclasses; int havetrans; int haveprocess_count; int havemount; int havevolume; int havebundle; int havetcpip; int havepackages; /* editline */ struct EditRegion region; struct EditLocation location; struct EditColumn column; struct EditReplace replace; int haveregion; int havelocation; int havecolumn; int havereplace; int haveinsertselect; int havedeleteselect; struct LineSelect line_select; char *sourcetype; int expandvars; int not_matching; struct Rlist *insert_match; /* knowledge */ char *fwd_name; char *bwd_name; struct Rlist *precedents; struct Rlist *qualifiers; struct Rlist *associates; struct Rlist *represents; struct Rlist *synonyms; struct Rlist *general; char *rep_type; char *path_root; char *web_root; }; enum cf_meter { meter_compliance_week, meter_compliance_day, meter_compliance_hour, meter_perf_day, meter_other_day, meter_comms_hour, meter_anomalies_day, meter_endmark }; /*************************************************************************/ /* definitions for reporting */ /*************************************************************************/ typedef enum cdp_report { cdp_acls, cdp_commands, cdp_filechanges, cdp_filediffs, cdp_registry, cdp_services, cdp_unknown } cdp_t; typedef enum basic_reports { cfrep_bundle, cfrep_business, cfrep_classes, cfrep_promise_compliance, cfrep_total_compliance, cfrep_change, cfrep_diff, cfrep_lastseen, cfrep_patch_avail, cfrep_patch_status, cfrep_performance, cfrep_repaired, cfrep_repair_summary, cfrep_notkept, cfrep_notkept_summary, cfrep_setuid, cfrep_software_installed, cfrep_variables, cfrep_unknown } cfrep_t; /*************************************************************************/ /* definitions for test suite */ /*************************************************************************/ // Classes: 601 - 650 #define CF_CLASS_ALL 0 #define CF_CLASS_REPORT 2 #define CF_CLASS_VARS 4 #define CF_CLASS_SLIST 8 #define CF_CLASS_STRING 16 #define CF_CLASS_PROCESS 32 #define CF_CLASS_FILE 64 #define CF_CLASS_DIR 128 #define CF_CLASS_CMD 256 #define CF_CLASS_OTHER 512 #define CF_CLASS_TOP10 1024 /*************************************************************************/ /* common macros */ /*************************************************************************/ #define EMPTY(str) ((str == NULL) || (str[0] == '\0')) #define BEGINSWITH(str,start) (strncmp(str,start,strlen(start)) == 0) #define CFSTRDUP(str) ((str != NULL) ? strdup(str) : NULL) #define CFFREE(ptr) if(ptr) free(ptr) // classes not interesting in reports #define IGNORECLASS(c) \ (strncmp(c,"Min",3) == 0 || strncmp(c,"Hr",2) == 0 || strcmp(c,"Q1") == 0 \ || strcmp(c,"Q2") == 0 || strcmp(c,"Q3") == 0 || strcmp(c,"Q4") == 0 \ || strncmp(c,"GMT_Hr",6) == 0 || strncmp(c,"Yr",2) == 0 \ || strncmp(c,"Day",3) == 0 || strcmp(c,"license_expired") == 0 \ || strcmp(c,"any") == 0 || strcmp(c,"from_cfexecd") == 0 \ || IsStrIn(c,MONTH_TEXT) || IsStrIn(c,DAY_TEXT) \ || IsStrIn(c,SHIFT_TEXT)) // Date time classes #define ISCLASS_DATETIME(c) \ (strncmp(c,"Min",3) == 0 || strncmp(c,"Hr",2) == 0 || strcmp(c,"Q1") == 0 \ || strcmp(c,"Q2") == 0 || strcmp(c,"Q3") == 0 || strcmp(c,"Q4") == 0 \ || strncmp(c,"GMT_Hr",6) == 0 || strncmp(c,"Yr",2) == 0 \ || strncmp(c,"Day",3) == 0 || IsStrIn(c,MONTH_TEXT) \ || IsStrIn(c,DAY_TEXT) || IsStrIn(c,SHIFT_TEXT) \ || strncmp(c,"Lcycle",6) == 0) #include "prototypes3.h" #ifdef HAVE_NOVA #include #endif #endif cfengine-3.2.4/src/rlist.c0000644000175000017500000006526611715232734012333 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: rlist.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int IsRegexIn(struct Rlist *list,char *s); static int CompareRlist(struct Rlist *list1, struct Rlist *list2); static void DeleteRlistNoRef(struct Rlist *list); static void ShowRlistState(FILE *fp,struct Rlist *list); /*******************************************************************/ struct Rlist *KeyInRlist(struct Rlist *list,char *key) { struct Rlist *rp; for (rp = list; rp != NULL; rp = rp->next) { if (rp->type != CF_SCALAR) { continue; } if (strcmp((char *)rp->item,key) == 0) { return rp; } } return NULL; } /*******************************************************************/ int IsStringIn(struct Rlist *list,char *s) { struct Rlist *rp; if (s == NULL || list == NULL) { return false; } for (rp = list; rp != NULL; rp=rp->next) { if (rp->type != CF_SCALAR) { continue; } if (strcmp(s,rp->item) == 0) { return true; } } return false; } /*******************************************************************/ int IsIntIn(struct Rlist *list,int i) { struct Rlist *rp; char s[CF_SMALLBUF]; snprintf(s,CF_SMALLBUF-1,"%d",i); if (list == NULL) { return false; } for (rp = list; rp != NULL; rp=rp->next) { if (rp->type != CF_SCALAR) { continue; } if (strcmp(s,rp->item) == 0) { return true; } } return false; } /*******************************************************************/ static int IsRegexIn(struct Rlist *list,char *regex) { struct Rlist *rp; if (regex == NULL || list == NULL) { return false; } for (rp = list; rp != NULL; rp=rp->next) { if (rp->type != CF_SCALAR) { continue; } if (FullTextMatch(regex,rp->item)) { return true; } } return false; } /*******************************************************************/ int IsInListOfRegex(struct Rlist *list,char *str) { struct Rlist *rp; if (str == NULL || list == NULL) { return false; } for (rp = list; rp != NULL; rp=rp->next) { if (rp->type != CF_SCALAR) { continue; } if (FullTextMatch(rp->item,str)) { return true; } } return false; } /*******************************************************************/ void *CopyRvalItem(void *item, char type) { struct Rlist *rp,*srp,*start = NULL; struct FnCall *fp; void *new,*rval; char rtype = CF_SCALAR; char naked[CF_BUFSIZE]; Debug("CopyRvalItem(%c)\n",type); if (item == NULL) { switch (type) { case CF_SCALAR: return strdup(""); case CF_LIST: return NULL; } } naked[0] = '\0'; switch(type) { case CF_SCALAR: /* the rval is just a string */ if ((new = strdup((char *)item)) == NULL) { CfOut(cf_error,"strdup","Memory allocation"); FatalError("CopyRvalItem"); } return new; case CF_FNCALL: /* the rval is a fncall */ fp = (struct FnCall *)item; return CopyFnCall(fp); case CF_LIST: /* The rval is an embedded rlist (2d) */ for (rp = (struct Rlist *)item; rp != NULL; rp=rp->next) { if (IsNakedVar(rp->item,'@')) { GetNaked(naked,rp->item); if (GetVariable(CONTEXTID,naked,&rval,&rtype) != cf_notype) { switch (rtype) { case CF_LIST: for (srp = (struct Rlist *)rval; srp != NULL; srp=srp->next) { AppendRlist(&start,srp->item,srp->type); } break; default: AppendRlist(&start,rp->item,rp->type); break; } } else { AppendRlist(&start,rp->item,rp->type); } } else { AppendRlist(&start,rp->item,rp->type); } } return start; } //snprintf(output,CF_BUFSIZE,"Unknown type %c in CopyRvalItem - should not happen",type); //FatalError(output); return NULL; } /*******************************************************************/ int CompareRval(void *rval1, char rtype1, void *rval2, char rtype2) { if (rtype1 != rtype2) { return -1; } switch (rtype1) { case CF_SCALAR: if (IsCf3VarString((char *)rval1) || IsCf3VarString((char *)rval2)) { return -1; // inconclusive } if (strcmp(rval1,rval2) != 0) { return false; } break; case CF_LIST: return CompareRlist(rval1,rval2); case CF_FNCALL: return -1; } return true; } /*******************************************************************/ static int CompareRlist(struct Rlist *list1, struct Rlist *list2) { struct Rlist *rp1,*rp2; for (rp1 = list1, rp2 = list2; rp1 != NULL && rp2!= NULL; rp1=rp1->next,rp2=rp2->next) { if (rp1->item && rp2->item) { struct Rlist *rc1,*rc2; if (rp1->type == CF_FNCALL || rp2->type == CF_FNCALL) { return -1; // inconclusive } rc1 = rp1; rc2 = rp2; // Check for list nesting with { fncall(), "x" ... } if (rp1->type == CF_LIST) { rc1 = rp1->item; } if (rp2->type == CF_LIST) { rc2 = rp2->item; } if (IsCf3VarString(rc1->item) || IsCf3VarString(rp2->item)) { return -1; // inconclusive } if (strcmp(rc1->item,rc2->item) != 0) { return false; } } else { return false; } } return true; } /*******************************************************************/ struct Rlist *CopyRlist(struct Rlist *list) { struct Rlist *rp,*start = NULL; Debug("CopyRlist()\n"); if (list == NULL) { return NULL; } for (rp = list; rp != NULL; rp = rp->next) { AppendRlist(&start,rp->item,rp->type); // allocates memory for objects } return start; } /*******************************************************************/ void DeleteRlist(struct Rlist *list) /* Delete an rlist and all its references */ { struct Rlist *rl, *next; if (list != NULL) { for(rl = list; rl != NULL; rl = next) { next = rl->next; if (rl->item != NULL) { DeleteRvalItem(rl->item,rl->type); } free(rl); } } } /*******************************************************************/ static void DeleteRlistNoRef(struct Rlist *list) /* Delete a rlist, but not its references */ { struct Rlist *rl, *next; if(list != NULL) { for(rl = list; rl != NULL; rl = next) { next = rl->next; free(rl); } } } /*******************************************************************/ struct Rlist *IdempAppendRScalar(struct Rlist **start,void *item, char type) { char *scalar = item; if (type != CF_SCALAR) { FatalError("Cannot append non-scalars to lists"); } if (!KeyInRlist(*start,(char *)item)) { return AppendRlist(start,scalar,type); } else { return NULL; } } /*******************************************************************/ struct Rlist *IdempPrependRScalar(struct Rlist **start,void *item, char type) { char *scalar = item; if (type != CF_SCALAR) { FatalError("Cannot append non-scalars to lists"); } if (!KeyInRlist(*start,(char *)item)) { return PrependRlist(start,scalar,type); } else { return NULL; } } /*******************************************************************/ struct Rlist *IdempAppendRlist(struct Rlist **start,void *item, char type) { char *scalar; struct Rlist *rp,*ins = NULL; if (type == CF_LIST) { for (rp = (struct Rlist *)item; rp != NULL; rp=rp->next) { ins = IdempAppendRlist(start,rp->item,rp->type); } return ins; } scalar = strdup((char *)item); if (!KeyInRlist(*start,(char *)item)) { return AppendRlist(start,scalar,type); } else { return NULL; } } /*******************************************************************/ struct Rlist *AppendRScalar(struct Rlist **start,void *item, char type) { char *scalar = item; if (type != CF_SCALAR) { FatalError("Cannot append non-scalars to lists"); } return AppendRlist(start,scalar,type); } /*******************************************************************/ struct Rlist *PrependRScalar(struct Rlist **start,void *item, char type) { char *scalar = item; if (type != CF_SCALAR) { FatalError("Cannot append non-scalars to lists"); } return PrependRlist(start,scalar,type); } /*******************************************************************/ struct Rlist *AppendRlist(struct Rlist **start,void *item, char type) /* Allocates new memory for objects - careful, could leak! */ { struct Rlist *rp,*lp = *start; struct FnCall *fp; switch(type) { case CF_SCALAR: Debug("Appending scalar to rval-list [%s]\n",(char *)item); break; case CF_FNCALL: Debug("Appending function to rval-list function call: "); fp = (struct FnCall *)item; if (DEBUG) { ShowFnCall(stdout,fp); } Debug("\n"); break; case CF_LIST: Debug("Expanding and appending list object\n"); for (rp = (struct Rlist *)item; rp != NULL; rp=rp->next) { lp = AppendRlist(start,rp->item,rp->type); } return lp; default: Debug("Cannot append %c to rval-list [%s]\n",type,(char *)item); return NULL; } if ((rp = (struct Rlist *)malloc(sizeof(struct Rlist))) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Rlist"); FatalError(""); } if (*start == NULL) { *start = rp; } else { for (lp = *start; lp->next != NULL; lp=lp->next) { } lp->next = rp; } rp->item = CopyRvalItem(item,type); rp->type = type; /* scalar, builtin function */ ThreadLock(cft_lock); if (type == CF_LIST) { rp->state_ptr = rp->item; } else { rp->state_ptr = NULL; } rp->next = NULL; ThreadUnlock(cft_lock); return rp; } /*******************************************************************/ struct Rlist *PrependRlist(struct Rlist **start,void *item, char type) /* heap memory for item must have already been allocated */ { struct Rlist *rp,*lp = *start; struct FnCall *fp; switch(type) { case CF_SCALAR: Debug("Prepending scalar to rval-list [%s]\n",item); break; case CF_LIST: Debug("Expanding and prepending list (ends up in reverse)\n"); for (rp = (struct Rlist *)item; rp != NULL; rp=rp->next) { lp = PrependRlist(start,rp->item,rp->type); } return lp; case CF_FNCALL: Debug("Prepending function to rval-list function call: "); fp = (struct FnCall *)item; if (DEBUG) { ShowFnCall(stdout,fp); } Debug("\n"); break; default: Debug("Cannot prepend %c to rval-list [%s]\n",type,item); return NULL; } ThreadLock(cft_system); if ((rp = (struct Rlist *)malloc(sizeof(struct Rlist))) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Rlist"); FatalError(""); } ThreadUnlock(cft_system); rp->next = *start; rp->item = CopyRvalItem(item,type); rp->type = type; /* scalar, builtin function */ if (type == CF_LIST) { rp->state_ptr = rp->item; } else { rp->state_ptr = NULL; } ThreadLock(cft_lock); *start = rp; ThreadUnlock(cft_lock); return rp; } /*******************************************************************/ struct Rlist *OrthogAppendRlist(struct Rlist **start,void *item, char type) /* Allocates new memory for objects - careful, could leak! */ { struct Rlist *rp,*lp; struct CfAssoc *cp; Debug("OrthogAppendRlist\n"); switch(type) { case CF_LIST: Debug("Expanding and appending list object, orthogonally\n"); break; default: Debug("Cannot append %c to rval-list [%s]\n",type,item); return NULL; } if ((rp = (struct Rlist *)malloc(sizeof(struct Rlist))) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Rlist"); FatalError(""); } if (*start == NULL) { *start = rp; } else { for (lp = *start; lp->next != NULL; lp=lp->next) { } lp->next = rp; } // This is item is in fact a struct CfAssoc pointing to a list cp = (struct CfAssoc *)item; // Note, we pad all iterators will a blank so the ptr arithmetic works // else EndOfIteration will not see lists with only one element lp = PrependRlist((struct Rlist **)&(cp->rval),CF_NULL_VALUE,CF_SCALAR); rp->state_ptr = lp->next; // Always skip the null value AppendRlist((struct Rlist **)&(cp->rval),CF_NULL_VALUE,CF_SCALAR); rp->item = item; rp->type = CF_LIST; rp->next = NULL; return rp; } /*******************************************************************/ int RlistLen(struct Rlist *start) { int count = 0; struct Rlist *rp; for (rp = start; rp != NULL; rp=rp->next) { count++; } return count; } /*******************************************************************/ struct Rlist *ParseShownRlist(char *string) { struct Rlist *newlist = NULL,*splitlist,*rp; char value[CF_MAXVARSIZE]; /* Parse a string representation generated by ShowList and turn back into Rlist */ splitlist = SplitStringAsRList(string,','); for (rp = splitlist; rp != NULL; rp = rp->next) { sscanf(rp->item,"%*[{ '\"]%255[^'\"]",value); AppendRlist(&newlist,value,CF_SCALAR); } DeleteRlist(splitlist); return newlist; } /*******************************************************************/ void ShowRlist(FILE *fp,struct Rlist *list) { struct Rlist *rp; fprintf(fp," {"); for (rp = list; rp != NULL; rp=rp->next) { fprintf(fp,"\'"); ShowRval(fp,rp->item,rp->type); fprintf(fp,"\'"); if (rp->next != NULL) { fprintf(fp,","); } } fprintf(fp,"}"); } /*******************************************************************/ int PrintRlist(char *buffer,int bufsize,struct Rlist *list) { struct Rlist *rp; StartJoin(buffer,"{",bufsize); for (rp = list; rp != NULL; rp=rp->next) { if(!JoinSilent(buffer,"'",bufsize)) { EndJoin(buffer,"...TRUNCATED'}",bufsize); return false; } if(!PrintRval(buffer,bufsize,rp->item,rp->type)) { EndJoin(buffer,"...TRUNCATED'}",bufsize); return false; } if(!JoinSilent(buffer,"'",bufsize)) { EndJoin(buffer,"...TRUNCATED'}",bufsize); return false; } if (rp->next != NULL) { if(!JoinSilent(buffer,",",bufsize)) { EndJoin(buffer,"...TRUNCATED}",bufsize); return false; } } } EndJoin(buffer,"}",bufsize); return true; } /*******************************************************************/ int GetStringListElement(char *strList, int index, char *outBuf, int outBufSz) /** Takes a string-parsed list "{'el1','el2','el3',..}" and writes ** "el1" or "el2" etc. based on index (starting on 0) in outBuf. ** returns true on success, false otherwise. **/ { char *sp,*elStart = strList,*elEnd; int elNum = 0; int minBuf; memset(outBuf,0,outBufSz); if (EMPTY(strList)) { return false; } if(strList[0] != '{') { return false; } for(sp = strList; *sp != '\0'; sp++) { if((sp[0] == '{' || sp[0] == ',') && sp[1] == '\'') { elStart = sp + 2; } else if((sp[0] == '\'') && sp[1] == ',' || sp[1] == '}') { elEnd = sp; if(elNum == index) { if(elEnd - elStart < outBufSz) { minBuf = elEnd - elStart; } else { minBuf = outBufSz - 1; } strncpy(outBuf,elStart,minBuf); break; } elNum++; } } return true; } /*******************************************************************/ int StripListSep(char *strList, char *outBuf, int outBufSz) { memset(outBuf,0,outBufSz); if(EMPTY(strList)) { return false; } if(strList[0] != '{') { return false; } snprintf(outBuf,outBufSz,"%s",strList + 1); if(outBuf[strlen(outBuf) - 1] == '}') { outBuf[strlen(outBuf) - 1] = '\0'; } return true; } /*******************************************************************/ int PrintRval(char *buffer,int bufsize,void *rval,char type) { if (rval == NULL) { return 0; } switch (type) { case CF_SCALAR: return JoinSilent(buffer,(char *)rval,bufsize); break; case CF_LIST: return PrintRlist(buffer,bufsize,(struct Rlist *)rval); break; case CF_FNCALL: PrintFnCall(buffer,bufsize,(struct FnCall *)rval); break; case CF_NOPROMISEE: // fprintf(fp,"(no-one)"); break; } return true; } /*******************************************************************/ static void ShowRlistState(FILE *fp,struct Rlist *list) { ShowRval(fp,list->state_ptr->item,list->type); } /*******************************************************************/ void ShowRval(FILE *fp,void *rval,char type) { char buf[CF_BUFSIZE]; if (rval == NULL) { return; } switch (type) { case CF_SCALAR: EscapeQuotes((char *)rval,buf,sizeof(buf)); fprintf(fp,"%s",buf); break; case CF_LIST: ShowRlist(fp,(struct Rlist *)rval); break; case CF_FNCALL: ShowFnCall(fp,(struct FnCall *)rval); break; case CF_NOPROMISEE: fprintf(fp,"(no-one)"); break; } } /*******************************************************************/ void DeleteRvalItem(void *rval, char type) { struct Rlist *clist, *next = NULL; Debug("DeleteRvalItem(%c)",type); if (DEBUG) { ShowRval(stdout,rval,type); } Debug("\n"); if (rval == NULL) { Debug("DeleteRval NULL\n"); return; } switch(type) { case CF_SCALAR: ThreadLock(cft_lock); free((char *)rval); ThreadUnlock(cft_lock); break; case CF_LIST: /* rval is now a list whose first item is clist->item */ for(clist = (struct Rlist *)rval; clist != NULL; clist = next) { next = clist->next; if (clist->item) { DeleteRvalItem(clist->item,clist->type); } free(clist); } break; case CF_FNCALL: if (rval) { DeleteFnCall((struct FnCall *)rval); } break; default: Debug("Nothing to do\n"); return; } } /*********************************************************************/ void DeleteRlistEntry(struct Rlist **liststart,struct Rlist *entry) { struct Rlist *rp, *sp; if (entry != NULL) { if (entry->item != NULL) { free(entry->item); } sp = entry->next; if (entry == *liststart) { *liststart = sp; } else { for (rp = *liststart; rp->next != entry; rp=rp->next) { } rp->next = sp; } free((char *)entry); } } /*******************************************************************/ struct Rlist *AppendRlistAlien(struct Rlist **start,void *item) /* Allocates new memory for objects - careful, could leak! */ { struct Rlist *rp,*lp = *start; if ((rp = (struct Rlist *)malloc(sizeof(struct Rlist))) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Rlist"); FatalError(""); } if (*start == NULL) { *start = rp; } else { for (lp = *start; lp->next != NULL; lp=lp->next) { } lp->next = rp; } rp->item = item; rp->type = CF_SCALAR; ThreadLock(cft_lock); rp->next = NULL; ThreadUnlock(cft_lock); return rp; } /*******************************************************************/ struct Rlist *PrependRlistAlien(struct Rlist **start,void *item) /* Allocates new memory for objects - careful, could leak! */ { struct Rlist *rp; ThreadLock(cft_lock); if ((rp = (struct Rlist *)malloc(sizeof(struct Rlist))) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Rlist"); FatalError(""); } rp->next = *start; *start = rp; ThreadUnlock(cft_lock); rp->item = item; rp->type = CF_SCALAR; return rp; } /*******************************************************************/ /* Stack */ /*******************************************************************/ /* char *sp1 = strdup("String 1\n"); char *sp2 = strdup("String 2\n"); char *sp3 = strdup("String 3\n"); PushStack(&stack,(void *)sp1); PopStack(&stack,(void *)&sp,sizeof(sp)); */ void PushStack(struct Rlist **liststart,void *item) { struct Rlist *rp; /* Have to keep track of types personally */ if ((rp = (struct Rlist *)malloc(sizeof(struct Rlist))) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Rlist"); FatalError(""); } rp->next = *liststart; rp->item = item; rp->type = CF_STACK; *liststart = rp; } /*******************************************************************/ void PopStack(struct Rlist **liststart, void **item,size_t size) { struct Rlist *rp = *liststart; if (*liststart == NULL) { FatalError("Attempt to pop from empty stack"); } *item = rp->item; if (rp->next == NULL) /* only one left */ { *liststart = (void *)NULL; } else { *liststart = rp->next; } free((char *)rp); } /*******************************************************************/ struct Rlist *SplitStringAsRList(char *string,char sep) /* Splits a string containing a separator like "," into a linked list of separate items, supports escaping separators, e.g. \, */ { struct Rlist *liststart = NULL; char *sp; char node[CF_MAXVARSIZE]; int maxlen = strlen(string); Debug("SplitStringAsRList(%s)\n",string); if (string == NULL) { return NULL; } for (sp = string; *sp != '\0'; sp++) { if (*sp == '\0' || sp > string+maxlen) { break; } memset(node,0,CF_MAXVARSIZE); sp += SubStrnCopyChr(node,sp,CF_MAXVARSIZE,sep); AppendRScalar(&liststart,node,CF_SCALAR); } return liststart; } /*******************************************************************/ struct Rlist *SplitRegexAsRList(char *string,char *regex,int max,int blanks) /* Splits a string containing a separator like "," into a linked list of separate items, */ { struct Rlist *liststart = NULL; char *sp; char node[CF_MAXVARSIZE]; int start,end; int delta, count = 0; if (string == NULL) { return NULL; } Debug("\n\nSplit \"%s\" with regex \"%s\" (up to maxent %d)\n\n",string,regex,max); sp = string; while ((count < max) && BlockTextMatch(regex,sp,&start,&end)) { if (end == 0) { break; } delta = end - start; memset(node,0,CF_MAXVARSIZE); strncpy(node,sp,start); if (blanks || strlen(node) > 0) { AppendRScalar(&liststart,node,CF_SCALAR); count++; } sp += end; } if (count < max) { memset(node,0,CF_MAXVARSIZE); strncpy(node,sp,CF_MAXVARSIZE-1); if (blanks || strlen(node) > 0) { AppendRScalar(&liststart,node,CF_SCALAR); } } return liststart; } /*****************************************************************************/ int PrependPackageItem(struct CfPackageItem **list,char *name,char *version,char *arch,struct Attributes a,struct Promise *pp) { struct CfPackageItem *pi; if (strlen(name) == 0 || strlen(version) == 0 || strlen(arch) == 0) { return false; } CfOut(cf_verbose,""," -> Package (%s,%s,%s) found",name,version,arch); if ((pi = (struct CfPackageItem *)malloc(sizeof(struct CfPackageItem))) == NULL) { CfOut(cf_error,"malloc","Can't allocate new package\n"); return false; } if (list) { pi->next = *list; } else { pi->next = NULL; } pi->name = strdup(name); pi->version = strdup(version); pi->arch = strdup(arch); *list = pi; /* Finally we need these for later schedule exec, once this iteration context has gone */ pi->pp = DeRefCopyPromise("this",pp); return true; } /*****************************************************************************/ int PrependListPackageItem(struct CfPackageItem **list,char *item,struct Attributes a,struct Promise *pp) { char name[CF_MAXVARSIZE]; char arch[CF_MAXVARSIZE]; char version[CF_MAXVARSIZE]; char vbuff[CF_MAXVARSIZE]; strncpy(vbuff,ExtractFirstReference(a.packages.package_list_name_regex,item),CF_MAXVARSIZE-1); sscanf(vbuff,"%s",name); /* trim */ strncpy(vbuff,ExtractFirstReference(a.packages.package_list_version_regex,item),CF_MAXVARSIZE-1); sscanf(vbuff,"%s",version); /* trim */ if (a.packages.package_list_arch_regex) { strncpy(vbuff,ExtractFirstReference(a.packages.package_list_arch_regex,item),CF_MAXVARSIZE-1); sscanf(vbuff,"%s",arch); /* trim */ } else { strncpy(arch,"default",CF_MAXVARSIZE-1); } if (strcmp(name,"CF_NOMATCH") == 0 || strcmp(version,"CF_NOMATCH") == 0 || strcmp(arch,"CF_NOMATCH") == 0) { return false; } Debug(" -? Package line \"%s\"\n",item); Debug(" -? with name \"%s\"\n",name); Debug(" -? with version \"%s\"\n",version); Debug(" -? with architecture \"%s\"\n",arch); return PrependPackageItem(list,name,version,arch,a,pp); } cfengine-3.2.4/src/sysinfo.c0000644000175000017500000014441611715232734012663 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: sysinfo.c */ /* */ /* Created: Sun Sep 30 14:14:47 2007 */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #ifdef IRIX #include #endif static void FindDomainName(char *hostname); static int Linux_Fedora_Version(void); static int Linux_Redhat_Version(void); static void Linux_Oracle_VM_Server_Version(void); static void Linux_Oracle_Version(void); static int Linux_Suse_Version(void); static int Linux_Slackware_Version(char *filename); static int Linux_Debian_Version(void); static int Linux_Mandrake_Version(void); static int Linux_Mandriva_Version(void); static int Linux_Mandriva_Version_Real(char *filename, char *relstring, char *vendor); static int VM_Version(void); static int Xen_Domain(void); static void Xen_Cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx); static int Xen_Hv_Check(void); static FILE *ReadFirstLine(const char *filename, char *buf, int bufsize); static bool ReadLine(const char *filename, char *buf, int bufsize); /**********************************************************************/ void SetSignals() { int i; SIGNALS[SIGHUP] = strdup("SIGHUP"); SIGNALS[SIGINT] = strdup("SIGINT"); SIGNALS[SIGTRAP] = strdup("SIGTRAP"); SIGNALS[SIGKILL] = strdup("SIGKILL"); SIGNALS[SIGPIPE] = strdup("SIGPIPE"); SIGNALS[SIGCONT] = strdup("SIGCONT"); SIGNALS[SIGABRT] = strdup("SIGABRT"); SIGNALS[SIGSTOP] = strdup("SIGSTOP"); SIGNALS[SIGQUIT] = strdup("SIGQUIT"); SIGNALS[SIGTERM] = strdup("SIGTERM"); SIGNALS[SIGCHLD] = strdup("SIGCHLD"); SIGNALS[SIGUSR1] = strdup("SIGUSR1"); SIGNALS[SIGUSR2] = strdup("SIGUSR2"); SIGNALS[SIGBUS] = strdup("SIGBUS"); SIGNALS[SIGSEGV] = strdup("SIGSEGV"); for (i = 0; i < highest_signal; i++) { if (SIGNALS[i] == NULL) { SIGNALS[i] = strdup("NOSIG"); } } } /*******************************************************************/ void GetNameInfo3() { int i,found = false; char *sp,workbuf[CF_BUFSIZE]; time_t tloc; struct hostent *hp; struct sockaddr_in cin; unsigned char digest[EVP_MAX_MD_SIZE+1]; #ifdef AIX char real_version[_SYS_NMLN]; #endif #ifdef IRIX char real_version[256]; /* see */ #endif #if defined(HAVE_SYSINFO) && (defined(SI_ARCHITECTURE) || defined(SI_PLATFORM)) long sz; #endif char *components[] = { "cf-twin", "cf-agent", "cf-serverd", "cf-monitord", "cf-know", "cf-report", "cf-key", "cf-runagent", "cf-execd", "cf-hub", "cf-promises", NULL }; int have_component[11]; struct stat sb; char name[CF_MAXVARSIZE],quoteName[CF_MAXVARSIZE],shortname[CF_MAXVARSIZE]; Debug("GetNameInfo()\n"); if (VSYSTEMHARDCLASS != unused1) { CfOut(cf_verbose,"","Already know our hard classes...\n"); /* Already have our name - so avoid memory leaks by recomputing */ return; } VFQNAME[0] = VUQNAME[0] = '\0'; if (uname(&VSYSNAME) == -1) { CfOut(cf_error, "uname", "!!! Couldn't get kernel name info!"); memset(&VSYSNAME, 0, sizeof(VSYSNAME)); } #ifdef AIX snprintf(real_version,_SYS_NMLN,"%.80s.%.80s", VSYSNAME.version, VSYSNAME.release); strncpy(VSYSNAME.release, real_version, _SYS_NMLN); #elif defined IRIX /* This gets us something like `6.5.19m' rather than just `6.5'. */ syssgi (SGI_RELEASE_NAME, 256, real_version); #endif for (sp = VSYSNAME.sysname; *sp != '\0'; sp++) { *sp = ToLower(*sp); } for (sp = VSYSNAME.machine; *sp != '\0'; sp++) { *sp = ToLower(*sp); } #ifdef _AIX switch (_system_configuration.architecture) { case POWER_RS: strncpy(VSYSNAME.machine, "power", _SYS_NMLN); break; case POWER_PC: strncpy(VSYSNAME.machine, "powerpc", _SYS_NMLN); break; case IA64: strncpy(VSYSNAME.machine, "ia64", _SYS_NMLN); break; } #endif for (i = 0; CLASSATTRIBUTES[i][0] != '\0'; i++) { if (FullTextMatch(CLASSATTRIBUTES[i][0],ToLowerStr(VSYSNAME.sysname))) { if (FullTextMatch(CLASSATTRIBUTES[i][1],VSYSNAME.machine)) { if (FullTextMatch(CLASSATTRIBUTES[i][2],VSYSNAME.release)) { NewClass(CLASSTEXT[i]); found = true; VSYSTEMHARDCLASS = (enum classes) i; NewScalar("sys","class",CLASSTEXT[i],cf_str); break; } } else { Debug2("Cfengine: I recognize %s but not %s\n",VSYSNAME.sysname,VSYSNAME.machine); continue; } } } FindDomainName(VSYSNAME.nodename); if (!StrStr(VSYSNAME.nodename,VDOMAIN)) { strcpy(VUQNAME,ToLowerStr(VSYSNAME.nodename)); NewClass(ToLowerStr(VUQNAME)); snprintf(VFQNAME,CF_BUFSIZE,"%s.%s",VUQNAME,ToLowerStr(VDOMAIN)); NewClass(ToLowerStr(VFQNAME)); } else { int n = 0; strcpy(VFQNAME,ToLowerStr(VSYSNAME.nodename)); NewClass(VFQNAME); while(VSYSNAME.nodename[n++] != '.' && VSYSNAME.nodename[n] != '\0') { } strncpy(VUQNAME,ToLowerStr(VSYSNAME.nodename),n); if (VUQNAME[n-1] == '.') { VUQNAME[n-1] = '\0'; } else { VUQNAME[n] = '\0'; } NewClass(VUQNAME); } if ((tloc = time((time_t *)NULL)) == -1) { printf("Couldn't read system clock\n"); } snprintf(workbuf,CF_BUFSIZE,"%s",CLASSTEXT[i]); CfOut(cf_verbose,"",NameVersion()); CfOut(cf_verbose,"","------------------------------------------------------------------------\n\n"); CfOut(cf_verbose,"","Host name is: %s\n",VSYSNAME.nodename); CfOut(cf_verbose,"","Operating System Type is %s\n",VSYSNAME.sysname); CfOut(cf_verbose,"","Operating System Release is %s\n",VSYSNAME.release); CfOut(cf_verbose,"","Architecture = %s\n\n\n",VSYSNAME.machine); CfOut(cf_verbose,"","Using internal soft-class %s for host %s\n\n",workbuf,VSYSNAME.nodename); CfOut(cf_verbose,"","The time is now %s\n\n",cf_ctime(&tloc)); CfOut(cf_verbose,"","------------------------------------------------------------------------\n\n"); snprintf(workbuf,CF_MAXVARSIZE,"%s",cf_ctime(&tloc)); Chop(workbuf); NewScalar("sys","date",workbuf,cf_str); NewScalar("sys","cdate",CanonifyName(workbuf),cf_str); NewScalar("sys","host",VSYSNAME.nodename,cf_str); NewScalar("sys","uqhost",VUQNAME,cf_str); NewScalar("sys","fqhost",VFQNAME,cf_str); NewScalar("sys","os",VSYSNAME.sysname,cf_str); NewScalar("sys","release",VSYSNAME.release,cf_str); NewScalar("sys","version",VSYSNAME.version,cf_str); NewScalar("sys","arch",VSYSNAME.machine,cf_str); NewScalar("sys","workdir",CFWORKDIR,cf_str); NewScalar("sys","fstab",VFSTAB[VSYSTEMHARDCLASS],cf_str); NewScalar("sys","resolv",VRESOLVCONF[VSYSTEMHARDCLASS],cf_str); NewScalar("sys","maildir",VMAILDIR[VSYSTEMHARDCLASS],cf_str); NewScalar("sys","exports",VEXPORTS[VSYSTEMHARDCLASS],cf_str); NewScalar("sys","expires",EXPIRY,cf_str); /* FIXME: type conversion */ NewScalar("sys","cf_version",(char*)Version(),cf_str); #ifdef HAVE_NOVA /* FIXME: type conversion */ NewScalar("sys","nova_version",(char*)Nova_Version(),cf_str); #endif #ifdef HAVE_CONSTELLATION /* FIXME: type conversion */ NewScalar("sys","constellation_version",(char*)Constellation_Version(),cf_str); #endif if (PUBKEY) { HashPubKey(PUBKEY,digest,CF_DEFAULT_DIGEST); snprintf(PUBKEY_DIGEST, sizeof(PUBKEY_DIGEST), "%s", HashPrint(CF_DEFAULT_DIGEST,digest)); NewScalar("sys","key_digest",PUBKEY_DIGEST,cf_str); snprintf(workbuf,CF_MAXVARSIZE-1,"PK_%s",CanonifyName(HashPrint(CF_DEFAULT_DIGEST,digest))); NewClass(workbuf); } for (i = 0; components[i] != NULL; i++) { snprintf(shortname,CF_MAXVARSIZE-1,"%s",CanonifyName(components[i])); if (VSYSTEMHARDCLASS == mingw || VSYSTEMHARDCLASS == cfnt) { // twin has own dir, and is named agent if(i == 0) { snprintf(name,CF_MAXVARSIZE-1,"%s%cbin-twin%ccf-agent.exe",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); } else { snprintf(name,CF_MAXVARSIZE-1,"%s%cbin%c%s.exe",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR,components[i]); } } else { snprintf(name,CF_MAXVARSIZE-1,"%s%cbin%c%s",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR,components[i]); } have_component[i] = false; if (cfstat(name, &sb) != -1) { snprintf(quoteName, sizeof(quoteName), "\"%s\"", name); NewScalar("sys",shortname,quoteName,cf_str); have_component[i] = true; } } // If no twin, fail over the agent if (!have_component[0]) { snprintf(shortname,CF_MAXVARSIZE-1,"%s",CanonifyName(components[0])); if (VSYSTEMHARDCLASS == mingw || VSYSTEMHARDCLASS == cfnt) { snprintf(name,CF_MAXVARSIZE-1,"%s%cbin%c%s.exe",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR,components[1]); } else { snprintf(name,CF_MAXVARSIZE-1,"%s%cbin%c%s",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR,components[1]); } if (cfstat(name, &sb) != -1) { snprintf(quoteName, sizeof(quoteName), "\"%s\"", name); NewScalar("sys",shortname,quoteName,cf_str); } } /* Windows special directories */ #ifdef MINGW if(NovaWin_GetWinDir(workbuf, sizeof(workbuf))) { NewScalar("sys","windir",workbuf,cf_str); } if(NovaWin_GetSysDir(workbuf, sizeof(workbuf))) { NewScalar("sys","winsysdir",workbuf,cf_str); } if(NovaWin_GetProgDir(workbuf, sizeof(workbuf))) { NewScalar("sys","winprogdir",workbuf,cf_str); } # ifdef _WIN64 // only available on 64 bit windows systems if(NovaWin_GetEnv("PROGRAMFILES(x86)", workbuf, sizeof(workbuf))) { NewScalar("sys","winprogdir86",workbuf,cf_str); } # else /* NOT _WIN64 */ NewScalar("sys","winprogdir86","",cf_str); # endif #else /* NOT MINGW */ // defs on Unix for manual-building purposes NewScalar("sys","windir","/dev/null",cf_str); NewScalar("sys","winsysdir","/dev/null",cf_str); NewScalar("sys","winprogdir","/dev/null",cf_str); NewScalar("sys","winprogdir86","/dev/null",cf_str); #endif /* NOT MINGW */ LoadSlowlyVaryingObservations(); EnterpriseContext(); if (strlen(VDOMAIN) > 0) { NewScalar("sys","domain",VDOMAIN,cf_str); } else { NewScalar("sys","domain","undefined_domain",cf_str); NewClass("undefined_domain"); } sprintf(workbuf,"%d_bit",sizeof(long)*8); NewClass(workbuf); CfOut(cf_verbose,"","Additional hard class defined as: %s\n",CanonifyName(workbuf)); snprintf(workbuf,CF_BUFSIZE,"%s_%s",VSYSNAME.sysname,VSYSNAME.release); NewClass(workbuf); #ifdef IRIX /* Get something like `irix64_6_5_19m' defined as well as `irix64_6_5'. Just copying the latter into VSYSNAME.release wouldn't be backwards-compatible. */ snprintf(workbuf,CF_BUFSIZE,"%s_%s",VSYSNAME.sysname,real_version); NewClass(workbuf); #endif NewClass(VSYSNAME.machine); CfOut(cf_verbose,"","Additional hard class defined as: %s\n",CanonifyName(workbuf)); snprintf(workbuf,CF_BUFSIZE,"%s_%s",VSYSNAME.sysname,VSYSNAME.machine); NewClass(workbuf); CfOut(cf_verbose,"","Additional hard class defined as: %s\n",CanonifyName(workbuf)); snprintf(workbuf,CF_BUFSIZE,"%s_%s_%s",VSYSNAME.sysname,VSYSNAME.machine,VSYSNAME.release); NewClass(workbuf); CfOut(cf_verbose,"","Additional hard class defined as: %s\n",CanonifyName(workbuf)); #ifdef HAVE_SYSINFO #ifdef SI_ARCHITECTURE sz = sysinfo(SI_ARCHITECTURE,workbuf,CF_BUFSIZE); if (sz == -1) { CfOut(cf_verbose,"","cfengine internal: sysinfo returned -1\n"); } else { NewClass(workbuf); CfOut(cf_verbose,"","Additional hard class defined as: %s\n",workbuf); } #endif #ifdef SI_PLATFORM sz = sysinfo(SI_PLATFORM,workbuf,CF_BUFSIZE); if (sz == -1) { CfOut(cf_verbose,"","cfengine internal: sysinfo returned -1\n"); } else { NewClass(workbuf); CfOut(cf_verbose,"","Additional hard class defined as: %s\n",workbuf); } #endif #endif snprintf(workbuf,CF_BUFSIZE,"%s_%s_%s_%s",VSYSNAME.sysname,VSYSNAME.machine,VSYSNAME.release,VSYSNAME.version); if (strlen(workbuf) > CF_MAXVARSIZE-2) { CfOut(cf_verbose,"","cfengine internal: $(arch) overflows CF_MAXVARSIZE! Truncating\n"); } sp = strdup(CanonifyName(workbuf)); NewScalar("sys","long_arch",sp,cf_str); NewClass(sp); free(sp); snprintf(workbuf,CF_BUFSIZE,"%s_%s",VSYSNAME.sysname,VSYSNAME.machine); sp = strdup(CanonifyName(workbuf)); NewScalar("sys","ostype",sp,cf_str); NewClass(sp); free(sp); if (! found) { CfOut(cf_error,"","Cfengine: I don't understand what architecture this is!"); } strcpy(workbuf,"compiled_on_"); strcat(workbuf,CanonifyName(AUTOCONF_SYSNAME)); NewClass(workbuf); CfOut(cf_verbose,"","GNU autoconf class from compile time: %s",workbuf); /* Get IP address from nameserver */ if ((hp = gethostbyname(VFQNAME)) == NULL) { CfOut(cf_verbose,"","Hostname lookup failed on node name \"%s\"\n",VSYSNAME.nodename); return; } else { memset(&cin,0,sizeof(cin)); cin.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr; CfOut(cf_verbose,"","Address given by nameserver: %s\n",inet_ntoa(cin.sin_addr)); strcpy(VIPADDRESS,inet_ntoa(cin.sin_addr)); for (i = 0; hp->h_aliases[i]!= NULL; i++) { Debug("Adding alias %s..\n",hp->h_aliases[i]); NewClass(hp->h_aliases[i]); } } } /*********************************************************************/ void CfGetInterfaceInfo(enum cfagenttype ag) #ifdef MINGW { NovaWin_GetInterfaceInfo(); } #else { Unix_GetInterfaceInfo(ag); Unix_FindV6InterfaceInfo(); } #endif /* NOT MINGW */ /*********************************************************************/ void Get3Environment() { char env[CF_BUFSIZE],class[CF_BUFSIZE],name[CF_MAXVARSIZE],value[CF_MAXVARSIZE]; FILE *fp; struct stat statbuf; time_t now = time(NULL); CfOut(cf_verbose,"","Looking for environment from cf-monitord...\n"); snprintf(env,CF_BUFSIZE,"%s/state/%s",CFWORKDIR,CF_ENV_FILE); MapName(env); if (cfstat(env,&statbuf) == -1) { CfOut(cf_verbose,"","Unable to detect environment from cf-monitord\n\n"); return; } if (statbuf.st_mtime < (now - 60*60)) { CfOut(cf_verbose,"","Environment data are too old - discarding\n"); unlink(env); return; } snprintf(value,CF_MAXVARSIZE-1,"%s",cf_ctime(&statbuf.st_mtime)); Chop(value); DeleteVariable("mon","env_time"); NewScalar("mon","env_time",value,cf_str); CfOut(cf_verbose,"","Loading environment...\n"); if ((fp = fopen(env,"r")) == NULL) { CfOut(cf_verbose,"","\nUnable to detect environment from cf-monitord\n\n"); return; } while (!feof(fp)) { class[0] = '\0'; name[0] = '\0'; value[0] = '\0'; fgets(class,CF_BUFSIZE-1,fp); if (feof(fp)) { break; } if (strstr(class,"=")) { sscanf(class,"%255[^=]=%255[^\n]",name,value); if (THIS_AGENT_TYPE != cf_executor) { DeleteVariable("mon",name); NewScalar("mon",name,value,cf_str); Debug(" -> Setting new monitoring scalar %s => %s",name,value); } } else { NewClass(class); } } fclose(fp); CfOut(cf_verbose,"","Environment data loaded\n\n"); } /*******************************************************************/ int IsInterfaceAddress(char *adr) /* Does this address belong to a local interface */ { struct Item *ip; for (ip = IPADDRESSES; ip != NULL; ip=ip->next) { if (StrnCmp(adr,ip->name,strlen(adr)) == 0) { Debug("Identifying (%s) as one of my interfaces\n",adr); return true; } } Debug("(%s) is not one of my interfaces\n",adr); return false; } /*********************************************************************/ static void FindDomainName(char *hostname) { char fqn[CF_MAXVARSIZE] = {0}; char *ptr; char buffer[CF_BUFSIZE]; strcpy(VFQNAME,hostname); /* By default VFQNAME = hostname (nodename) */ if (strstr(VFQNAME,".") == 0) { /* The nodename is not full qualified - try to find the FQDN hostname */ if (gethostname(fqn, sizeof(fqn)) != -1) { struct hostent *hp; if ((hp = gethostbyname(fqn))) { if (strstr(hp->h_name,".")) { /* We find a FQDN hostname So we change the VFQNAME variable */ strncpy(VFQNAME,hp->h_name,CF_MAXVARSIZE); VFQNAME[CF_MAXVARSIZE-1]= '\0'; } } } } strcpy(buffer,VFQNAME); NewClass(buffer); NewClass(ToLowerStr(buffer)); if (strstr(VFQNAME,".")) { /* If VFQNAME is full qualified we can create VDOMAIN variable */ ptr = strchr(VFQNAME, '.'); strcpy(VDOMAIN, ++ptr); DeleteClass("undefined_domain"); } if (strstr(VFQNAME,".") == 0 && (strcmp(VDOMAIN,CF_START_DOMAIN) != 0)) { strcat(VFQNAME,"."); strcat(VFQNAME,VDOMAIN); } if (strstr(VFQNAME,".")) { /* Add some domain hierarchy classes */ for (ptr=VFQNAME; *ptr != '\0'; ptr++) { if (*ptr == '.') { if (*(ptr+1) != '\0') { Debug("Defining domain #%s#\n",(ptr+1)); NewClass(ptr+1); } else { Debug("Domain rejected\n"); } } } } NewClass(VDOMAIN); } /*******************************************************************/ void BuiltinClasses(void) { char vbuff[CF_BUFSIZE]; char *sp; NewClass("any"); /* This is a reserved word / wildcard */ snprintf(vbuff,CF_BUFSIZE,"cfengine_%s",CanonifyName(Version())); NewClass(vbuff); while ((sp = strrchr(vbuff, '_'))) { *sp = 0; NewClass(vbuff); } } /*******************************************************************/ void OSClasses() { struct stat statbuf; char vbuff[CF_BUFSIZE]; char *sp; struct passwd *pw; #ifndef LINUX char class[CF_BUFSIZE]; #endif #ifdef LINUX /* Mandrake/Mandriva, Fedora and Oracle VM Server supply /etc/redhat-release, so we test for those distributions first */ if (cfstat("/etc/mandriva-release",&statbuf) != -1) { Linux_Mandriva_Version(); } else if (cfstat("/etc/mandrake-release",&statbuf) != -1) { Linux_Mandrake_Version(); } else if (cfstat("/etc/fedora-release",&statbuf) != -1) { Linux_Fedora_Version(); } else if (cfstat("/etc/ovs-release",&statbuf) != -1) { Linux_Oracle_VM_Server_Version(); } else if (cfstat("/etc/redhat-release",&statbuf) != -1) { Linux_Redhat_Version(); } /* Oracle Linux >= 6 supplies separate /etc/oracle-release alongside /etc/redhat-release, use it to precisely identify version */ if (cfstat("/etc/oracle-release",&statbuf) != -1) { Linux_Oracle_Version(); } if (cfstat("/etc/generic-release",&statbuf) != -1) { CfOut(cf_verbose,"","This appears to be a sun cobalt system.\n"); NewClass("SunCobalt"); } if (cfstat("/etc/SuSE-release",&statbuf) != -1) { Linux_Suse_Version(); } #define SLACKWARE_ANCIENT_VERSION_FILENAME "/etc/slackware-release" #define SLACKWARE_VERSION_FILENAME "/etc/slackware-version" if (cfstat(SLACKWARE_VERSION_FILENAME,&statbuf) != -1) { Linux_Slackware_Version(SLACKWARE_VERSION_FILENAME); } else if (cfstat(SLACKWARE_ANCIENT_VERSION_FILENAME,&statbuf) != -1) { Linux_Slackware_Version(SLACKWARE_ANCIENT_VERSION_FILENAME); } if (cfstat("/etc/generic-release",&statbuf) != -1) { CfOut(cf_verbose,"","This appears to be a sun cobalt system.\n"); NewClass("SunCobalt"); } if (cfstat("/etc/debian_version",&statbuf) != -1) { Linux_Debian_Version(); } if (cfstat("/usr/bin/aptitude",&statbuf) != -1) { CfOut(cf_verbose,"","This system seems to have the aptitude package system\n"); NewClass("have_aptitude"); } if (cfstat("/etc/UnitedLinux-release",&statbuf) != -1) { CfOut(cf_verbose,"","This appears to be a UnitedLinux system.\n"); NewClass("UnitedLinux"); } if (cfstat("/etc/gentoo-release",&statbuf) != -1) { CfOut(cf_verbose,"","This appears to be a gentoo system.\n"); NewClass("gentoo"); } #else strncpy(vbuff,VSYSNAME.release,CF_MAXVARSIZE); for (sp = vbuff; *sp != '\0'; sp++) { if (*sp == '-') { *sp = '\0'; break; } } snprintf(class,CF_BUFSIZE,"%s_%s",VSYSNAME.sysname,vbuff); NewScalar("sys","flavour",class,cf_str); NewScalar("sys","flavor",class,cf_str); #endif if (cfstat("/proc/vmware/version",&statbuf) != -1 || cfstat("/etc/vmware-release",&statbuf) != -1) { VM_Version(); } else if (cfstat("/etc/vmware",&statbuf) != -1 && S_ISDIR(statbuf.st_mode)) { VM_Version(); } if (cfstat("/proc/xen/capabilities",&statbuf) != -1) { Xen_Domain(); } #ifdef XEN_CPUID_SUPPORT else if (Xen_Hv_Check()) { CfOut(cf_verbose,"","This appears to be a xen hv system.\n"); NewClass("xen"); NewClass("xen_domu_hv"); } #endif #ifdef CFCYG for (sp = VSYSNAME.sysname; *sp != '\0'; sp++) { if (*sp == '-') { sp++; if (strncmp(sp,"5.0",3) == 0) { CfOut(cf_verbose,"","This appears to be Windows 2000\n"); NewClass("Win2000"); } if (strncmp(sp,"5.1",3) == 0) { CfOut(cf_verbose,"","This appears to be Windows XP\n"); NewClass("WinXP"); } if (strncmp(sp,"5.2",3) == 0) { CfOut(cf_verbose,"","This appears to be Windows Server 2003\n"); NewClass("WinServer2003"); } if (strncmp(sp,"6.1",3) == 0) { CfOut(cf_verbose,"","This appears to be Windows Vista\n"); NewClass("WinVista"); } if (strncmp(sp,"6.3",3) == 0) { CfOut(cf_verbose,"","This appears to be Windows Server 2008\n"); NewClass("WinServer2008"); } } } NewScalar("sys","crontab","",cf_str); #endif /* CFCYG */ #ifdef MINGW NewClass(VSYSNAME.release); // code name - e.g. Windows Vista NewClass(VSYSNAME.version); // service pack number - e.g. Service Pack 3 if (strstr(VSYSNAME.sysname, "workstation")) { NewClass("WinWorkstation"); } else if(strstr(VSYSNAME.sysname, "server")) { NewClass("WinServer"); } else if(strstr(VSYSNAME.sysname, "domain controller")) { NewClass("DomainController"); NewClass("WinServer"); } else { NewClass("unknown_ostype"); } NewScalar("sys","flavour","windows",cf_str); NewScalar("sys","flavor","windows",cf_str); #endif /* MINGW */ #ifndef NT if ((pw = getpwuid(getuid())) == NULL) { CfOut(cf_error,"getpwuid"," !! Unable to get username for uid %d",getuid); } else { if (IsDefinedClass("SuSE")) { snprintf(vbuff,CF_BUFSIZE,"/var/spool/cron/tabs/%s",pw->pw_name); } else { snprintf(vbuff,CF_BUFSIZE,"/var/spool/cron/crontabs/%s",pw->pw_name); } } NewScalar("sys","crontab",vbuff,cf_str); #endif #if defined(HAVE_NOVA) Nova_SaveDocumentRoot(); #endif } /*********************************************************************************/ static void Linux_Oracle_VM_Server_Version(void) { char relstring[CF_MAXVARSIZE]; char *r; int major, minor, patch; int revcomps; #define ORACLE_VM_SERVER_REL_FILENAME "/etc/ovs-release" #define ORACLE_VM_SERVER_ID "Oracle VM server" CfOut(cf_verbose,"","This appears to be Oracle VM Server"); NewClass("redhat"); NewClass("oraclevmserver"); if (!ReadLine(ORACLE_VM_SERVER_REL_FILENAME, relstring, sizeof(relstring))) { return; } if (strncmp(relstring, ORACLE_VM_SERVER_ID, strlen(ORACLE_VM_SERVER_ID))) { CfOut(cf_verbose, "", "Could not identify distribution from %s\n", ORACLE_VM_SERVER_REL_FILENAME); return; } if ((r = strstr(relstring, "release ")) == NULL) { CfOut(cf_verbose, "", "Could not find distribution version in %s\n", ORACLE_VM_SERVER_REL_FILENAME); return; } revcomps = sscanf(r + strlen("release "), "%d.%d.%d", &major, &minor, &patch); if (revcomps > 0) { char buf[CF_BUFSIZE]; snprintf(buf, CF_BUFSIZE, "oraclevmserver_%d", major); NewClass(buf); NewScalar("sys", "flavour", buf, cf_str); NewScalar("sys", "flavor", buf, cf_str); } if (revcomps > 1) { char buf[CF_BUFSIZE]; snprintf(buf, CF_BUFSIZE, "oraclevmserver_%d_%d", major, minor); NewClass(buf); } if (revcomps > 2) { char buf[CF_BUFSIZE]; snprintf(buf, CF_BUFSIZE, "oraclevmserver_%d_%d_%d", major, minor, patch); NewClass(buf); } } /*********************************************************************************/ static void Linux_Oracle_Version(void) { char relstring[CF_MAXVARSIZE]; char *r; int major, minor; #define ORACLE_REL_FILENAME "/etc/oracle-release" #define ORACLE_ID "Oracle Linux Server" CfOut(cf_verbose,"","This appears to be Oracle Linux"); NewClass("oracle"); if (!ReadLine(ORACLE_REL_FILENAME, relstring, sizeof(relstring))) { return; } if (strncmp(relstring, ORACLE_ID, strlen(ORACLE_ID))) { CfOut(cf_verbose, "", "Could not identify distribution from %s\n", ORACLE_REL_FILENAME); return; } if ((r = strstr(relstring, "release ")) == NULL) { CfOut(cf_verbose, "", "Could not find distribution version in %s\n", ORACLE_REL_FILENAME); return; } if (sscanf(r + strlen("release "), "%d.%d", &major, &minor) == 2) { char buf[CF_BUFSIZE]; snprintf(buf, CF_BUFSIZE, "oracle_%d", major); NewClass(buf); NewScalar("sys", "flavour", buf, cf_str); NewScalar("sys", "flavor", buf, cf_str); snprintf(buf, CF_BUFSIZE, "oracle_%d_%d", major, minor); NewClass(buf); } } /*********************************************************************************/ static int Linux_Fedora_Version(void) { #define FEDORA_ID "Fedora" #define RELEASE_FLAG "release " /* We are looking for one of the following strings... * * Fedora Core release 1 (Yarrow) * Fedora release 7 (Zodfoobar) */ #define FEDORA_REL_FILENAME "/etc/fedora-release" /* The full string read in from fedora-release */ char relstring[CF_MAXVARSIZE]; char classbuf[CF_MAXVARSIZE]; char *vendor=""; char *release=NULL; int major = -1; char strmajor[CF_MAXVARSIZE]; CfOut(cf_verbose,"","This appears to be a fedora system.\n"); NewClass("redhat"); NewClass("fedora"); /* Grab the first line from the file and then close it. */ if (!ReadLine(FEDORA_REL_FILENAME, relstring, sizeof(relstring))) { return 1; } CfOut(cf_verbose,"","Looking for fedora core linux info...\n"); if (!strncmp(relstring, FEDORA_ID, strlen(FEDORA_ID))) { vendor = "fedora"; } else { CfOut(cf_verbose,"","Could not identify OS distro from %s\n", FEDORA_REL_FILENAME); return 2; } /* Now, grok the release. We assume that all the strings will * have the word 'release' before the numerical release. */ release = strstr(relstring, RELEASE_FLAG); if (release == NULL) { CfOut(cf_verbose,"","Could not find a numeric OS release in %s\n",FEDORA_REL_FILENAME); return 2; } else { release += strlen(RELEASE_FLAG); if (sscanf(release, "%d", &major) != 0) { sprintf(strmajor, "%d", major); } } if (major != -1 && (strcmp(vendor,"") != 0)) { classbuf[0] = '\0'; strcat(classbuf, vendor); NewClass(classbuf); strcat(classbuf, "_"); strcat(classbuf, strmajor); NewClass(classbuf); NewScalar("sys","flavour",classbuf,cf_str); NewScalar("sys","flavor",classbuf,cf_str); } return 0; } /*********************************************************************************/ static int Linux_Redhat_Version(void) { #define REDHAT_ID "Red Hat Linux" #define REDHAT_AS_ID "Red Hat Enterprise Linux AS" #define REDHAT_AS21_ID "Red Hat Linux Advanced Server" #define REDHAT_ES_ID "Red Hat Enterprise Linux ES" #define REDHAT_WS_ID "Red Hat Enterprise Linux WS" #define REDHAT_C_ID "Red Hat Enterprise Linux Client" #define REDHAT_S_ID "Red Hat Enterprise Linux Server" #define REDHAT_W_ID "Red Hat Enterprise Linux Workstation" #define MANDRAKE_ID "Linux Mandrake" #define MANDRAKE_10_1_ID "Mandrakelinux" #define WHITEBOX_ID "White Box Enterprise Linux" #define CENTOS_ID "CentOS" #define SCIENTIFIC_SL_ID "Scientific Linux SL" #define SCIENTIFIC_SL6_ID "Scientific Linux" #define SCIENTIFIC_CERN_ID "Scientific Linux CERN" #define RELEASE_FLAG "release " #define ORACLE_4_5_ID "Enterprise Linux Enterprise Linux Server" /* We are looking for one of the following strings... * * Red Hat Linux release 6.2 (Zoot) * Red Hat Linux Advanced Server release 2.1AS (Pensacola) * Red Hat Enterprise Linux AS release 3 (Taroon) * Red Hat Enterprise Linux WS release 3 (Taroon) * Red Hat Enterprise Linux Client release 5 (Tikanga) * Red Hat Enterprise Linux Server release 5 (Tikanga) * Linux Mandrake release 7.1 (helium) * Red Hat Enterprise Linux ES release 2.1 (Panama) * White Box Enterprise linux release 3.0 (Liberation) * Scientific Linux SL Release 4.0 (Beryllium) * CentOS release 4.0 (Final) */ #define RH_REL_FILENAME "/etc/redhat-release" /* The full string read in from redhat-release */ char relstring[CF_MAXVARSIZE]; char classbuf[CF_MAXVARSIZE]; /* Red Hat, Mandrake */ char *vendor=""; /* as (Advanced Server, Enterprise) */ char *edition=""; /* Where the numerical release will be found */ char *release=NULL; int i; int major = -1; char strmajor[CF_MAXVARSIZE]; int minor = -1; char strminor[CF_MAXVARSIZE]; CfOut(cf_verbose,"","This appears to be a redhat (or redhat-based) system.\n"); NewClass("redhat"); /* Grab the first line from the file and then close it. */ if (!ReadLine(RH_REL_FILENAME, relstring, sizeof(relstring))) { return 1; } CfOut(cf_verbose,"","Looking for redhat linux info in \"%s\"\n",relstring); /* First, try to grok the vendor and the edition (if any) */ if (!strncmp(relstring, REDHAT_ES_ID, strlen(REDHAT_ES_ID))) { vendor = "redhat"; edition = "es"; } else if(!strncmp(relstring, REDHAT_WS_ID, strlen(REDHAT_WS_ID))) { vendor = "redhat"; edition = "ws"; } else if(!strncmp(relstring, REDHAT_WS_ID, strlen(REDHAT_WS_ID))) { vendor = "redhat"; edition = "ws"; } else if(!strncmp(relstring, REDHAT_AS_ID, strlen(REDHAT_AS_ID)) || !strncmp(relstring, REDHAT_AS21_ID, strlen(REDHAT_AS21_ID))) { vendor = "redhat"; edition = "as"; } else if(!strncmp(relstring, REDHAT_S_ID, strlen(REDHAT_S_ID))) { vendor = "redhat"; edition = "s"; } else if(!strncmp(relstring, REDHAT_C_ID, strlen(REDHAT_C_ID)) || !strncmp(relstring, REDHAT_W_ID, strlen(REDHAT_W_ID))) { vendor = "redhat"; edition = "c"; } else if(!strncmp(relstring, REDHAT_ID, strlen(REDHAT_ID))) { vendor = "redhat"; } else if(!strncmp(relstring, MANDRAKE_ID, strlen(MANDRAKE_ID))) { vendor = "mandrake"; } else if(!strncmp(relstring, MANDRAKE_10_1_ID, strlen(MANDRAKE_10_1_ID))) { vendor = "mandrake"; } else if(!strncmp(relstring, WHITEBOX_ID, strlen(WHITEBOX_ID))) { vendor = "whitebox"; } else if(!strncmp(relstring, SCIENTIFIC_SL_ID, strlen(SCIENTIFIC_SL_ID))) { vendor = "scientific"; edition = "sl"; } else if(!strncmp(relstring, SCIENTIFIC_CERN_ID, strlen(SCIENTIFIC_CERN_ID))) { vendor = "scientific"; edition = "cern"; } else if(!strncmp(relstring, SCIENTIFIC_SL6_ID, strlen(SCIENTIFIC_SL6_ID))) { vendor = "scientific"; edition = "sl"; } else if(!strncmp(relstring, CENTOS_ID, strlen(CENTOS_ID))) { vendor = "centos"; } else if (!strncmp(relstring, ORACLE_4_5_ID, strlen(ORACLE_4_5_ID))) { vendor = "oracle"; edition = "s"; } else { CfOut(cf_verbose,"","Could not identify OS distro from %s\n", RH_REL_FILENAME); return 2; } /* Now, grok the release. For AS, we neglect the AS at the end of the * numerical release because we already figured out that it *is* AS * from the infomation above. We assume that all the strings will * have the word 'release' before the numerical release. */ /* Convert relstring to lowercase so that vendors like Scientific Linux don't fall through the cracks. */ for (i = 0; i < strlen(relstring); i++) { relstring[i] = tolower(relstring[i]); } release = strstr(relstring, RELEASE_FLAG); if (release == NULL) { CfOut(cf_verbose,"","Could not find a numeric OS release in %s\n", RH_REL_FILENAME); return 2; } else { release += strlen(RELEASE_FLAG); if (sscanf(release, "%d.%d", &major, &minor) == 2) { sprintf(strmajor, "%d", major); sprintf(strminor, "%d", minor); } /* red hat 9 is *not* red hat 9.0. * and same thing with RHEL AS 3 */ else if (sscanf(release, "%d", &major) == 1) { sprintf(strmajor, "%d", major); minor = -2; } } if (major != -1 && minor != -1 && (strcmp(vendor,"") != 0)) { classbuf[0] = '\0'; strcat(classbuf, vendor); NewClass(classbuf); strcat(classbuf, "_"); if (strcmp(edition,"") != 0) { strcat(classbuf, edition); NewClass(classbuf); strcat(classbuf, "_"); } strcat(classbuf, strmajor); NewClass(classbuf); if (minor != -2) { strcat(classbuf, "_"); strcat(classbuf, strminor); NewClass(classbuf); } } // Now a version without the edition if (major != -1 && minor != -1 && (strcmp(vendor,"") != 0)) { classbuf[0] = '\0'; strcat(classbuf, vendor); NewClass(classbuf); strcat(classbuf, "_"); strcat(classbuf, strmajor); NewClass(classbuf); NewScalar("sys","flavour",classbuf,cf_str); NewScalar("sys","flavor",classbuf,cf_str); if (minor != -2) { strcat(classbuf, "_"); strcat(classbuf, strminor); NewClass(classbuf); } } return 0; } /******************************************************************/ static int Linux_Suse_Version(void) { #define SUSE_REL_FILENAME "/etc/SuSE-release" /* Check if it's a SuSE Enterprise version (all in lowercase) */ #define SUSE_SLES8_ID "suse sles-8" #define SUSE_SLES_ID "suse linux enterprise server" #define SUSE_SLED_ID "suse linux enterprise desktop" #define SUSE_RELEASE_FLAG "linux " /* The full string read in from SuSE-release */ char relstring[CF_MAXVARSIZE]; char classbuf[CF_MAXVARSIZE]; char vbuf[CF_BUFSIZE],strversion[CF_MAXVARSIZE],strpatch[CF_MAXVARSIZE]; /* Where the numerical release will be found */ char *release=NULL; int i,version; int major = -1; char strmajor[CF_MAXVARSIZE]; int minor = -1; char strminor[CF_MAXVARSIZE]; FILE *fp; CfOut(cf_verbose,"","This appears to be a SuSE system.\n"); NewClass("SuSE"); /* Grab the first line from the file and then close it. */ fp = ReadFirstLine(SUSE_REL_FILENAME, relstring, sizeof(relstring)); if (fp == NULL) { return 1; } strversion[0] = '\0'; strpatch[0] = '\0'; while (!feof(fp)) { fgets(vbuf,sizeof(vbuf),fp); if (strncmp(vbuf,"VERSION",strlen("version")) == 0) { strncpy(strversion,vbuf,sizeof(strversion)); sscanf(strversion,"VERSION = %d",&major); } if (strncmp(vbuf,"PATCH",strlen("PATCH")) == 0) { strncpy(strpatch,vbuf,sizeof(strpatch)); sscanf(strpatch,"PATCHLEVEL = %d",&minor); } } fclose(fp); /* Check if it's a SuSE Enterprise version */ CfOut(cf_verbose,"","Looking for SuSE enterprise info in \"%s\"\n",relstring); /* Convert relstring to lowercase to handle rename of SuSE to * SUSE with SUSE 10.0. */ for (i = 0; i < strlen(relstring); i++) { relstring[i] = tolower(relstring[i]); } /* Check if it's a SuSE Enterprise version (all in lowercase) */ if (!strncmp(relstring, SUSE_SLES8_ID, strlen(SUSE_SLES8_ID))) { classbuf[0] = '\0'; strcat(classbuf, "SLES8"); NewClass(classbuf); } else if (strncmp(relstring,"sles",4) == 0) { struct Item *list, *ip; sscanf(relstring,"%[-_a-zA-Z0-9]",vbuf); NewClass(vbuf); list = SplitString(vbuf,'-'); for (ip = list; ip != NULL; ip=ip->next) { NewClass(ip->name); } DeleteItemList(list); } else { for (version = 9; version < 13; version++) { snprintf(vbuf,CF_BUFSIZE,"%s %d ",SUSE_SLES_ID,version); Debug("Checking for suse [%s]\n",vbuf); if (!strncmp(relstring, vbuf, strlen(vbuf))) { snprintf(classbuf,CF_MAXVARSIZE,"SLES%d",version); NewClass(classbuf); } else { snprintf(vbuf,CF_BUFSIZE,"%s %d ",SUSE_SLED_ID,version); Debug("Checking for suse [%s]\n",vbuf); if (!strncmp(relstring, vbuf, strlen(vbuf))) { snprintf(classbuf,CF_MAXVARSIZE,"SLED%d",version); NewClass(classbuf); } } } } /* Determine release version. We assume that the version follows * the string "SuSE Linux" or "SUSE LINUX". */ release = strstr(relstring, SUSE_RELEASE_FLAG); if (release == NULL) { release = strstr(relstring,"opensuse"); } if (release == NULL) { release = strversion; } if (release == NULL) { CfOut(cf_verbose,"","Could not find a numeric OS release in %s\n",SUSE_REL_FILENAME); return 2; } else { if (strchr(release,'.')) { sscanf(release, "%*s %d.%d", &major, &minor); sprintf(strmajor, "%d", major); sprintf(strminor, "%d", minor); if (major != -1 && minor != -1) { strcpy(classbuf, "SuSE"); NewClass(classbuf); strcat(classbuf, "_"); strcat(classbuf, strmajor); NewClass(classbuf); NewScalar("sys","flavour",classbuf,cf_str); NewScalar("sys","flavor",classbuf,cf_str); strcat(classbuf, "_"); strcat(classbuf, strminor); NewClass(classbuf); CfOut(cf_verbose,""," -> Discovered SuSE version %s",classbuf); return 0; } } else { sscanf(strversion,"VERSION = %s",strmajor); sscanf(strpatch,"PATCHLEVEL = %s",strminor); if (major != -1 && minor != -1) { strcpy(classbuf, "SLES"); NewClass(classbuf); strcat(classbuf, "_"); strcat(classbuf, strmajor); NewClass(classbuf); strcat(classbuf, "_"); strcat(classbuf, strminor); NewClass(classbuf); snprintf(classbuf,CF_MAXVARSIZE,"SuSE_%d",major); NewScalar("sys","flavour",classbuf,cf_str); NewScalar("sys","flavor",classbuf,cf_str); NewClass(classbuf); CfOut(cf_verbose,""," -> Discovered SuSE version %s",classbuf); return 0; } } } CfOut(cf_verbose,"","Could not find a numeric OS release in %s\n",SUSE_REL_FILENAME); return 0; } /******************************************************************/ static int Linux_Slackware_Version(char *filename) { int major = -1; int minor = -1; int release = -1; char classname[CF_MAXVARSIZE] = ""; char buffer[CF_MAXVARSIZE]; CfOut(cf_verbose,"","This appears to be a slackware system.\n"); NewClass("slackware"); if (!ReadLine(filename, buffer, sizeof(buffer))) { return 1; } CfOut(cf_verbose,"","Looking for Slackware version...\n"); switch (sscanf(buffer, "Slackware %d.%d.%d", &major, &minor, &release)) { case 3: CfOut(cf_verbose,"","This appears to be a Slackware %u.%u.%u system.", major, minor, release); snprintf(classname, CF_MAXVARSIZE, "slackware_%u_%u_%u", major, minor, release); NewClass(classname); /* Fall-through */ case 2: CfOut(cf_verbose,"","This appears to be a Slackware %u.%u system.", major, minor); snprintf(classname, CF_MAXVARSIZE, "slackware_%u_%u", major, minor); NewClass(classname); /* Fall-through */ case 1: CfOut(cf_verbose,"","This appears to be a Slackware %u system.", major); snprintf(classname, CF_MAXVARSIZE, "slackware_%u", major); NewClass(classname); break; case 0: CfOut(cf_verbose,"","No Slackware version number found.\n"); return 2; } return 0; } /******************************************************************/ static int Linux_Debian_Version(void) { #define DEBIAN_VERSION_FILENAME "/etc/debian_version" #define DEBIAN_ISSUE_FILENAME "/etc/issue" int major = -1; int release = -1; int result; char classname[CF_MAXVARSIZE],buffer[CF_MAXVARSIZE],os[CF_MAXVARSIZE],version[CF_MAXVARSIZE]; CfOut(cf_verbose,"","This appears to be a debian system.\n"); NewClass("debian"); buffer[0] = classname[0] = '\0'; CfOut(cf_verbose,"","Looking for Debian version...\n"); if (!ReadLine(DEBIAN_VERSION_FILENAME, buffer, sizeof(buffer))) { return 1; } result = sscanf(buffer,"%d.%d", &major, &release); switch (result) { case 2: CfOut(cf_verbose,"","This appears to be a Debian %u.%u system.", major, release); snprintf(classname, CF_MAXVARSIZE, "debian_%u_%u", major, release); NewClass(classname); snprintf(classname, CF_MAXVARSIZE, "debian_%u",major); NewClass(classname); NewScalar("sys","flavour",classname,cf_str); NewScalar("sys","flavor",classname,cf_str); break; /* Fall-through */ case 1: CfOut(cf_verbose,"","This appears to be a Debian %u system.", major); snprintf(classname, CF_MAXVARSIZE, "debian_%u", major); NewClass(classname); NewScalar("sys","flavour",classname,cf_str); NewScalar("sys","flavor",classname,cf_str); break; default: version[0] = '\0'; sscanf(buffer,"%25[^/]",version); if (strlen(version) > 0) { snprintf(classname,CF_MAXVARSIZE, "debian_%s",version); NewClass(classname); } break; } if (!ReadLine(DEBIAN_ISSUE_FILENAME, buffer, sizeof(buffer))) { return 1; } os[0] = '\0'; sscanf(buffer,"%250s",os); if (strcmp(os,"Debian") == 0) { sscanf(buffer,"%*s %*s %[^/]",version); snprintf(buffer,CF_MAXVARSIZE, "debian_%s",version); NewClass("debian"); NewClass(buffer); NewScalar("sys","flavour",buffer,cf_str); NewScalar("sys","flavor",buffer,cf_str); } else if (strcmp(os,"Ubuntu") == 0) { sscanf(buffer,"%*s %[^.].%d",version,&release); snprintf(buffer,CF_MAXVARSIZE, "ubuntu_%s",version); NewScalar("sys","flavour",buffer,cf_str); NewScalar("sys","flavor",buffer,cf_str); NewClass("ubuntu"); NewClass(buffer); if (release >= 0) { snprintf(buffer,CF_MAXVARSIZE, "ubuntu_%s_%d",version,release); NewClass(buffer); } } return 0; } /******************************************************************/ static int Linux_Mandrake_Version(void) { /* We are looking for one of the following strings... */ #define MANDRAKE_ID "Linux Mandrake" #define MANDRAKE_REV_ID "Mandrake Linux" #define MANDRAKE_10_1_ID "Mandrakelinux" #define MANDRAKE_REL_FILENAME "/etc/mandrake-release" char relstring[CF_MAXVARSIZE]; char *vendor=NULL; CfOut(cf_verbose,"","This appears to be a mandrake system.\n"); NewClass("Mandrake"); if (!ReadLine(MANDRAKE_REL_FILENAME, relstring, sizeof(relstring))) { return 1; } CfOut(cf_verbose,"","Looking for Mandrake linux info in \"%s\"\n",relstring); /* Older Mandrakes had the 'Mandrake Linux' string in reverse order */ if(!strncmp(relstring, MANDRAKE_ID, strlen(MANDRAKE_ID))) { vendor = "mandrake"; } else if(!strncmp(relstring, MANDRAKE_REV_ID, strlen(MANDRAKE_REV_ID))) { vendor = "mandrake"; } else if(!strncmp(relstring, MANDRAKE_10_1_ID, strlen(MANDRAKE_10_1_ID))) { vendor = "mandrake"; } else { CfOut(cf_verbose,"","Could not identify OS distro from %s\n", MANDRAKE_REL_FILENAME); return 2; } return Linux_Mandriva_Version_Real(MANDRAKE_REL_FILENAME, relstring, vendor); } /******************************************************************/ static int Linux_Mandriva_Version(void) { /* We are looking for the following strings... */ #define MANDRIVA_ID "Mandriva Linux" #define MANDRIVA_REL_FILENAME "/etc/mandriva-release" char relstring[CF_MAXVARSIZE]; char *vendor=NULL; CfOut(cf_verbose,"","This appears to be a mandriva system.\n"); NewClass("Mandrake"); NewClass("Mandriva"); if (!ReadLine(MANDRIVA_REL_FILENAME, relstring, sizeof(relstring))) { return 1; } CfOut(cf_verbose,"","Looking for Mandriva linux info in \"%s\"\n",relstring); if(!strncmp(relstring, MANDRIVA_ID, strlen(MANDRIVA_ID))) { vendor = "mandriva"; } else { CfOut(cf_verbose,"","Could not identify OS distro from %s\n", MANDRIVA_REL_FILENAME); return 2; } return Linux_Mandriva_Version_Real(MANDRIVA_REL_FILENAME, relstring, vendor); } /******************************************************************/ static int Linux_Mandriva_Version_Real(char *filename, char *relstring, char *vendor) { char *release=NULL; char classbuf[CF_MAXVARSIZE]; int major = -1; char strmajor[CF_MAXVARSIZE]; int minor = -1; char strminor[CF_MAXVARSIZE]; #define RELEASE_FLAG "release " release = strstr(relstring, RELEASE_FLAG); if(release == NULL) { CfOut(cf_verbose,"","Could not find a numeric OS release in %s\n",filename); return 2; } else { release += strlen(RELEASE_FLAG); if (sscanf(release, "%d.%d", &major, &minor) == 2) { sprintf(strmajor, "%d", major); sprintf(strminor, "%d", minor); } else { CfOut(cf_verbose,"","Could not break down release version numbers in %s\n",filename); } } if (major != -1 && minor != -1 && strcmp(vendor, "")) { classbuf[0] = '\0'; strcat(classbuf, vendor); NewClass(classbuf); strcat(classbuf, "_"); strcat(classbuf, strmajor); NewClass(classbuf); if (minor != -2) { strcat(classbuf, "_"); strcat(classbuf, strminor); NewClass(classbuf); } } return 0; } /******************************************************************/ static int VM_Version(void) { char *sp,buffer[CF_BUFSIZE],classbuf[CF_BUFSIZE],version[CF_BUFSIZE]; int major,minor,bug; int sufficient = 0; CfOut(cf_verbose,"","This appears to be a VMware Server ESX/xSX system.\n"); NewClass("VMware"); /* VMware Server ESX >= 3 has version info in /proc */ if (ReadLine("/proc/vmware/version", buffer, sizeof(buffer))) { if (sscanf(buffer,"VMware ESX Server %d.%d.%d",&major,&minor,&bug) > 0) { snprintf(classbuf,CF_BUFSIZE,"VMware ESX Server %d",major); NewClass(classbuf); snprintf(classbuf,CF_BUFSIZE,"VMware ESX Server %d.%d",major,minor); NewClass(classbuf); snprintf(classbuf,CF_BUFSIZE,"VMware ESX Server %d.%d.%d",major,minor,bug); NewClass(classbuf); sufficient = 1; } else if (sscanf(buffer,"VMware ESX Server %s",version) > 0) { snprintf(classbuf,CF_BUFSIZE,"VMware ESX Server %s",version); NewClass(classbuf); sufficient = 1; } } /* Fall back to checking for other files */ if (sufficient < 1 && (ReadLine("/etc/vmware-release", buffer, sizeof(buffer)) || ReadLine("/etc/issue", buffer, sizeof(buffer)))) { NewClass(buffer); /* Strip off the release code name e.g. "(Dali)" */ if ((sp = strchr(buffer,'(')) != NULL) { *sp = 0; Chop(buffer); NewClass(buffer); } sufficient = 1; } return sufficient < 1 ? 1 : 0; } /******************************************************************/ static int Xen_Domain(void) { FILE *fp; char buffer[CF_BUFSIZE]; int sufficient = 0; CfOut(cf_verbose,"","This appears to be a xen pv system.\n"); NewClass("xen"); /* xen host will have "control_d" in /proc/xen/capabilities, xen guest will not */ if ((fp = fopen("/proc/xen/capabilities","r")) != NULL) { while (!feof(fp)) { CfReadLine(buffer,CF_BUFSIZE,fp); if (strstr(buffer,"control_d")) { NewClass("xen_dom0"); sufficient = 1; } } if (!sufficient) { NewClass("xen_domu_pv"); sufficient = 1; } fclose(fp); } return sufficient < 1 ? 1 : 0; } /******************************************************************/ #ifdef XEN_CPUID_SUPPORT /* borrowed from Xen source/tools/libxc/xc_cpuid_x86.c */ static void Xen_Cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { asm ( /* %ebx register need to be saved before usage and restored thereafter * for PIC-compliant code on i386 */ #ifdef __i386__ "push %%ebx; cpuid; mov %%ebx,%1; pop %%ebx" #else "push %%rbx; cpuid; mov %%ebx,%1; pop %%rbx" #endif : "=a" (*eax), "=r" (*ebx), "=c" (*ecx), "=d" (*edx) : "0" (idx), "2" (0) ); } /******************************************************************/ static int Xen_Hv_Check(void) { uint32_t eax, ebx, ecx, edx; char signature[13]; Xen_Cpuid(0x40000000, &eax, &ebx, &ecx, &edx); *(uint32_t *)(signature + 0) = ebx; *(uint32_t *)(signature + 4) = ecx; *(uint32_t *)(signature + 8) = edx; signature[12] = '\0'; if (strcmp("XenVMMXenVMM", signature) || (eax < 0x40000002)) { return 0; } Xen_Cpuid(0x40000001, &eax, &ebx, &ecx, &edx); return 1; } #endif /******************************************************************/ static bool ReadLine(const char *filename, char *buf, int bufsize) { FILE *fp = ReadFirstLine(filename, buf, bufsize); if (fp == NULL) { return false; } else { fclose(fp); return true; } } static FILE *ReadFirstLine(const char *filename, char *buf, int bufsize) { FILE *fp = fopen(filename, "r"); if (fp == NULL) { return NULL; } if (fgets(buf, bufsize, fp) == NULL) { free(fp); return NULL; } StripTrailingNewline(buf); return fp; } /******************************************************************/ /* User info */ /******************************************************************/ int GetCurrentUserName(char *userName, int userNameLen) { #ifdef MINGW return NovaWin_GetCurrentUserName(userName, userNameLen); #else return Unix_GetCurrentUserName(userName, userNameLen); #endif } /******************************************************************/ #ifndef MINGW char *GetHome(uid_t uid) { struct passwd *mpw = getpwuid(uid); return mpw->pw_dir; } #endif cfengine-3.2.4/src/files_names.c0000644000175000017500000006547711715232734013467 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: files_names.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void DeEscapeFilename(char *in,char *out); static int JoinFast(char *path,char *leaf,char **nextFree,int bufsize); static int StartJoinFast(char *path,char *leaf,char **nextFree,int bufsize); /*****************************************************************************/ void LocateFilePromiserGroup(char *wildpath,struct Promise *pp,void (*fnptr)(char *path, struct Promise *ptr)) { struct Item *path,*ip,*remainder = NULL; char pbuffer[CF_BUFSIZE]; struct stat statbuf; int count = 0,lastnode = false, expandregex = false; uid_t agentuid = getuid(); int create = GetBooleanConstraint("create",pp); char *pathtype = GetConstraint("pathtype",pp,CF_SCALAR); Debug("LocateFilePromiserGroup(%s)\n",wildpath); /* Do a search for promiser objects matching wildpath */ if (!IsPathRegex(wildpath) || (pathtype && (strcmp(pathtype,"literal") == 0))) { CfOut(cf_verbose,""," -> Using literal pathtype for %s\n",wildpath); (*fnptr)(wildpath,pp); return; } else { CfOut(cf_verbose,""," -> Using regex pathtype for %s (see pathtype)\n",wildpath); } pbuffer[0] = '\0'; path = SplitString(wildpath,'/'); // require forward slash in regex on all platforms for (ip = path; ip != NULL; ip=ip->next) { if (ip->name == NULL || strlen(ip->name) == 0) { continue; } if (ip->next == NULL) { lastnode = true; } /* No need to chdir as in recursive descent, since we know about the path here */ if (IsRegex(ip->name)) { remainder = ip->next; expandregex = true; break; } else { expandregex = false; } if (!JoinPath(pbuffer,ip->name)) { CfOut(cf_error,"","Buffer has limited size in LocateFilePromiserGroup\n"); return; } if (cfstat(pbuffer,&statbuf) != -1) { if (S_ISDIR(statbuf.st_mode) && statbuf.st_uid != agentuid && statbuf.st_uid != 0) { CfOut(cf_inform,"","Directory %s in search path %s is controlled by another user (uid %d) - trusting its content is potentially risky (possible race)\n",pbuffer,wildpath,statbuf.st_uid); PromiseRef(cf_inform,pp); } } } if (expandregex) /* Expand one regex link and hand down */ { char nextbuffer[CF_BUFSIZE],nextbufferOrig[CF_BUFSIZE],regex[CF_BUFSIZE]; const struct dirent *dirp; CFDIR *dirh; struct Attributes dummyattr = {{0}}; memset(&dummyattr,0,sizeof(dummyattr)); memset(regex,0,CF_BUFSIZE); strncpy(regex,ip->name,CF_BUFSIZE-1); if ((dirh = OpenDirLocal(pbuffer)) == NULL) { // Could be a dummy directory to be created so this is not an error. CfOut(cf_verbose,""," -> Using best-effort expanded (but non-existent) file base path %s\n",wildpath); (*fnptr)(wildpath,pp); DeleteItemList(path); return; } else { count = 0; for (dirp = ReadDir(dirh); dirp != NULL; dirp = ReadDir(dirh)) { if (!ConsiderFile(dirp->d_name,pbuffer,dummyattr,pp)) { continue; } if (!lastnode && !S_ISDIR(statbuf.st_mode)) { Debug("Skipping non-directory %s\n",dirp->d_name); continue; } if (FullTextMatch(regex,dirp->d_name)) { Debug("Link %s matched regex %s\n",dirp->d_name,regex); } else { continue; } count++; strncpy(nextbuffer,pbuffer,CF_BUFSIZE-1); AddSlash(nextbuffer); strcat(nextbuffer,dirp->d_name); for (ip = remainder; ip != NULL; ip=ip->next) { AddSlash(nextbuffer); strcat(nextbuffer,ip->name); } /* The next level might still contain regexs, so go again as long as expansion is not nullpotent */ if (!lastnode && (strcmp(nextbuffer,wildpath) != 0)) { LocateFilePromiserGroup(nextbuffer,pp,fnptr); } else { struct Promise *pcopy; CfOut(cf_verbose,""," -> Using expanded file base path %s\n",nextbuffer); /* Now need to recompute any back references to get the complete path */ snprintf(nextbufferOrig, sizeof(nextbufferOrig), "%s", nextbuffer); MapNameForward(nextbuffer); if (!FullTextMatch(pp->promiser,nextbuffer)) { Debug("Error recomputing references for \"%s\" in: %s",pp->promiser,nextbuffer); } /* If there were back references there could still be match.x vars to expand */ pcopy = ExpandDeRefPromise(CONTEXTID,pp); (*fnptr)(nextbufferOrig,pcopy); DeletePromise(pcopy); } } CloseDir(dirh); } } else { CfOut(cf_verbose,""," -> Using file base path %s\n",pbuffer); (*fnptr)(pbuffer,pp); } if (count == 0) { CfOut(cf_verbose,"","No promiser file objects matched as regular expression %s\n",wildpath); if (create) { VerifyFilePromise(pp->promiser,pp); } } DeleteItemList(path); } /*********************************************************************/ int IsNewerFileTree(char *dir,time_t reftime) { const struct dirent *dirp; char path[CF_BUFSIZE] = {0}; struct Attributes dummyattr = {{0}}; CFDIR *dirh; struct stat sb; // Assumes that race conditions on the file path are unlikely and unimportant if (lstat(dir,&sb) == -1) { CfOut(cf_error,"stat"," !! Unable to stat directory %s in IsNewerFileTree",dir); // return true to provoke update return true; } if (S_ISDIR(sb.st_mode)) { //CfOut(cf_verbose,""," ?? Looking at %s (%ld)",dir,sb.st_mtime-reftime); if (sb.st_mtime > reftime) { CfOut(cf_verbose,""," >> Detected change in %s",dir); return true; } } if ((dirh = OpenDirLocal(dir)) == NULL) { CfOut(cf_error,"opendir"," !! Unable to open directory '%s' in IsNewerFileTree",dir); return false; } else { for (dirp = ReadDir(dirh); dirp != NULL; dirp = ReadDir(dirh)) { if (!ConsiderFile(dirp->d_name,dir,dummyattr,NULL)) { continue; } strncpy(path,dir,CF_BUFSIZE-1); if (!JoinPath(path,dirp->d_name)) { CfOut(cf_error,"","Internal limit: Buffer ran out of space adding %s to %s in IsNewerFileTree",dir,path); CloseDir(dirh); return false; } if (lstat(path,&sb) == -1) { CfOut(cf_error,"stat"," !! Unable to stat directory %s in IsNewerFileTree",path); CloseDir(dirh); // return true to provoke update return true; } if (S_ISDIR(sb.st_mode)) { if (sb.st_mtime > reftime) { CfOut(cf_verbose,""," >> Detected change in %s",path); CloseDir(dirh); return true; } else { if (IsNewerFileTree(path,reftime)) { CloseDir(dirh); return true; } } } } } CloseDir(dirh); return false; } /*********************************************************************/ int IsDir(char *path) /* Checks if the object pointed to by path exists and is a directory. Returns true if so, false otherwise. */ { #ifdef MINGW return NovaWin_IsDir(path); #else struct stat sb; if (cfstat(path, &sb) != -1) { if (S_ISDIR(sb.st_mode)) { return true; } } return false; #endif /* NOT MINGW */ } /*********************************************************************/ int EmptyString(char *s) { char *sp; for (sp = s; *sp != '\0'; sp++) { if (!isspace(*sp)) { return false; } } return true; } /*********************************************************************/ char *JoinPath(char *path, const char *leaf) { int len = strlen(leaf); Chop(path); AddSlash(path); if ((strlen(path)+len) > (CF_BUFSIZE - CF_BUFFERMARGIN)) { CfOut(cf_error,"","Internal limit: Buffer ran out of space constructing string. Tried to add %s to %s\n",leaf,path); return NULL; } strcat(path,leaf); return path; } /*********************************************************************/ char *JoinSuffix(char *path,char *leaf) { int len = strlen(leaf); Chop(path); DeleteSlash(path); if ((strlen(path)+len) > (CF_BUFSIZE - CF_BUFFERMARGIN)) { CfOut(cf_error,"","Internal limit: Buffer ran out of space constructing string. Tried to add %s to %s\n",leaf,path); return NULL; } strcat(path,leaf); return path; } /*********************************************************************/ int StartJoin(char *path,char *leaf,int bufsize) { *path = '\0'; return JoinMargin(path,leaf,NULL,bufsize,CF_BUFFERMARGIN); } /*********************************************************************/ static int StartJoinFast(char *path,char *leaf,char **nextFree,int bufsize) { *path = '\0'; *nextFree = path; return JoinMargin(path,leaf,nextFree,bufsize,CF_BUFFERMARGIN); } /*********************************************************************/ int Join(char *path, const char *leaf, int bufsize) { return JoinMargin(path,leaf,NULL,bufsize,CF_BUFFERMARGIN); } /*********************************************************************/ int JoinSilent(char *path, const char *leaf, int bufsize) /* Don't warn on buffer limits - just return the value */ { int len = strlen(leaf); if ((strlen(path)+len) > (bufsize - CF_BUFFERMARGIN)) { return false; } strcat(path,leaf); return true; } /*********************************************************************/ static int JoinFast(char *path,char *leaf,char **nextFree,int bufsize) /* * Faster stringjoin by keeping track of where we last stopped */ { return JoinMargin(path,leaf,nextFree,bufsize,CF_BUFFERMARGIN); } /*********************************************************************/ int EndJoin(char *path,char *leaf,int bufsize) { return JoinMargin(path,leaf,NULL,bufsize,0); } /*********************************************************************/ int JoinMargin(char *path, const char *leaf, char **nextFree, int bufsize, int margin) { int len = strlen(leaf); if (margin < 0) { FatalError("Negative margin in JoinMargin()"); } if(nextFree) { if ((*nextFree - path) + len > (bufsize - margin) ) { CfOut(cf_error,"","Internal limit: Buffer ran out of space constructing string (using nextFree), len = %d > %d.\n",(strlen(path)+len),(bufsize - CF_BUFFERMARGIN)); return false; } strcpy(*nextFree, leaf); *nextFree += len; } else { if ((strlen(path)+len) > (bufsize - margin)) { CfOut(cf_error,"","Internal limit: Buffer ran out of space constructing string (%d > %d).\n",(strlen(path)+len),(bufsize - CF_BUFFERMARGIN)); return false; } strcat(path,leaf); } return true; } /*********************************************************************/ int IsAbsPath(char *path) { if (IsFileSep(*path)) { return true; } else { return false; } } /*******************************************************************/ void AddSlash(char *str) { char *sp, *sep = FILE_SEPARATOR_STR; int f = false ,b = false; if (str == NULL) { return; } // add root slash on Unix systems if(strlen(str) == 0) { if((VSYSTEMHARDCLASS != mingw) && (VSYSTEMHARDCLASS != cfnt)) { strcpy(str, "/"); } return; } /* Try to see what convention is being used for filenames in case this is a cross-system copy from Win/Unix */ for (sp = str; *sp != '\0'; sp++) { switch (*sp) { case '/': f = true; break; case '\\': b = true; break; default: break; } } if (f && !b) { sep = "/"; } else if (b && !f) { sep = "\\"; } if (!IsFileSep(str[strlen(str)-1])) { strcat(str,sep); } } /*********************************************************************/ void DeleteSlash(char *str) { if ((strlen(str)== 0) || (str == NULL)) { return; } if (strcmp(str,"/") == 0) { return; } if (IsFileSep(str[strlen(str)-1])) { str[strlen(str)-1] = '\0'; } } /*********************************************************************/ const char *LastFileSeparator(const char *str) /* Return pointer to last file separator in string, or NULL if string does not contains any file separtors */ { const char *sp; /* Walk through string backwards */ sp = str + strlen(str) - 1; while (sp >= str) { if (IsFileSep(*sp)) { return sp; } sp--; } return NULL; } /*********************************************************************/ int ChopLastNode(char *str) /* Chop off trailing node name (possible blank) starting from last character and removing up to the first / encountered e.g. /a/b/c -> /a/b /a/b/ -> /a/b */ { char *sp; int ret; /* Here cast is necessary and harmless, str is modifiable */ if ((sp = (char *)LastFileSeparator(str)) == NULL) { ret = false; } else { *sp = '\0'; ret = true; } if (strlen(str) == 0) { AddSlash(str); } return ret; } /*********************************************************************/ void CanonifyNameInPlace(char *s) { for (; *s != '\0'; s++) { if (!isalnum(*s) || *s == '.') { *s = '_'; } } } /*********************************************************************/ char *CanonifyName(const char *str) { static char buffer[CF_BUFSIZE]; strncpy(buffer,str,CF_BUFSIZE); CanonifyNameInPlace(buffer); return buffer; } /*********************************************************************/ char *CanonifyChar(const char *str,char ch) { static char buffer[CF_BUFSIZE]; char *sp; strncpy(buffer,str,CF_BUFSIZE-1); for (sp = buffer; *sp != '\0'; sp++) { if (*sp == ch) { *sp = '_'; } } return buffer; } /*********************************************************************/ int CompareCSVName(char *s1,char *s2) { char *sp1,*sp2; char ch1,ch2; for (sp1 = s1,sp2 = s2; *sp1 != '\0' || *sp2 != '\0'; sp1++,sp2++) { ch1 = (*sp1 == ',') ? '_' : *sp1; ch2 = (*sp2 == ',') ? '_' : *sp2; if (ch1 > ch2) { return 1; } else if (ch1 < ch2) { return -1; } } return 0; } /*********************************************************************/ const char *ReadLastNode(const char *str) /* Return the last node of a pathname string */ { const char *sp; if ((sp = LastFileSeparator(str)) == NULL) { return str; } else { return sp + 1; } } /*****************************************************************************/ static void DeEscapeFilename(char *in,char *out) { char *sp_in,*sp_out = out; *sp_out = '\0'; for (sp_in = in; *sp_in != '\0'; sp_in++) { if (*sp_in == '\\' && *(sp_in+1) == ' ') { sp_in++; } *sp_out++ = *sp_in; } *sp_out = '\0'; } /*****************************************************************************/ int DeEscapeQuotedString(const char *from,char *to) { char *cp; const char *sp; char start = *from; int len = strlen(from); if (len == 0) { return 0; } for (sp=from+1,cp=to; (sp-from) < len; sp++,cp++) { if ((*sp == start)) { *(cp) = '\0'; if (*(sp+1) != '\0') { return (2+(sp - from)); } return 0; } if (*sp == '\n') { P.line_no++; } if (*sp == '\\') { switch (*(sp+1)) { case '\n': P.line_no++; sp+=2; break; case ' ': break; case '\\': case '\"': case '\'': sp++; break; } } *cp = *sp; } yyerror("Runaway string"); *(cp) = '\0'; return 0; } /*********************************************************************/ void Chop(char *str) /* remove trailing spaces */ { int i; if ((str == NULL) || (strlen(str) == 0)) { return; } if (strlen(str) > CF_EXPANDSIZE) { CfOut(cf_error,"","Chop was called on a string that seemed to have no terminator"); return; } for (i = strlen(str)-1; i >= 0 && isspace((int)str[i]); i--) { str[i] = '\0'; } } /*********************************************************************/ void StripTrailingNewline(char *str) { char *c = str + strlen(str); if (c - str > CF_EXPANDSIZE) { CfOut(cf_error, "", "StripTrailingNewline was called on an overlong string"); return; } for (; c >= str && (*c == '\0' || *c == '\n'); --c) { *c = '\0'; } } /*********************************************************************/ int CompressPath(char *dest,char *src) { char *sp; char node[CF_BUFSIZE]; int nodelen; int rootlen; Debug("CompressPath(%s,%s)\n",dest,src); memset(dest,0,CF_BUFSIZE); rootlen = RootDirLength(src); strncpy(dest,src,rootlen); for (sp = src+rootlen; *sp != '\0'; sp++) { if (IsFileSep(*sp)) { continue; } for (nodelen = 0; sp[nodelen] != '\0' && !IsFileSep(sp[nodelen]); nodelen++) { if (nodelen > CF_MAXLINKSIZE) { CfOut(cf_error,"","Link in path suspiciously large"); return false; } } strncpy(node,sp,nodelen); node[nodelen] = '\0'; sp += nodelen - 1; if (strcmp(node,".") == 0) { continue; } if (strcmp(node,"..") == 0) { if (!ChopLastNode(dest)) { Debug("cfengine: used .. beyond top of filesystem!\n"); return false; } continue; } else { AddSlash(dest); } if (!JoinPath(dest,node)) { return false; } } return true; } /*********************************************************************/ bool IsStrIn(const char *str, const char **strs) { int i; for (i = 0; strs[i]; ++i) { if (strcmp(str, strs[i]) == 0) { return true; } } return false; } bool IsStrCaseIn(const char *str, const char **strs) { int i; for (i = 0; strs[i]; ++i) { if (strcasecmp(str, strs[i]) == 0) { return true; } } return false; } /*********************************************************************/ void FreeStringArray(char **strs) { int i; if (strs == NULL) { return; } for(i = 0; strs[i] != NULL; i++) { free(strs[i]); } free(strs); strs = NULL; } /*********************************************************************/ int IsAbsoluteFileName(const char *f) { int off = 0; // Check for quoted strings for (off = 0; f[off] == '\"'; off++) { } #ifdef NT if (IsFileSep(f[off]) && IsFileSep(f[off+1])) { return true; } if (isalpha(f[off]) && f[off+1] == ':' && IsFileSep(f[off+2])) { return true; } #endif if (f[off] == '/') { return true; } return false; } bool IsFileOutsideDefaultRepository(const char *f) { return (*f == '.') || IsAbsoluteFileName(f); } /*******************************************************************/ static int UnixRootDirLength(char *f) { if (IsFileSep(*f)) { return 1; } return 0; } #ifdef NT static int NTRootDirLength(char *f) { int len; if (IsFileSep(f[0]) && IsFileSep(f[1])) { /* UNC style path */ /* Skip over host name */ for (len=2; !IsFileSep(f[len]); len++) { if (f[len] == '\0') { return len; } } /* Skip over share name */ for (len++; !IsFileSep(f[len]); len++) { if (f[len] == '\0') { return len; } } /* Skip over file separator */ len++; return len; } if (isalpha(f[0]) && f[1] == ':') { if(IsFileSep(f[2])) { return 3; } return 2; } return UnixRootDirLength(f); } #endif int RootDirLength(char *f) /* Return length of Initial directory in path - */ { #ifdef NT return NTRootDirLength(f); #else return UnixRootDirLength(f); #endif } /*********************************************************************/ /* TOOLKIT : String */ /*********************************************************************/ char ToLower (char ch) { if (isupper((int)ch)) { return(ch - 'A' + 'a'); } else { return(ch); } } /*********************************************************************/ char ToUpper (char ch) { if (isdigit((int)ch) || ispunct((int)ch)) { return(ch); } if (isupper((int)ch)) { return(ch); } else { return(ch - 'a' + 'A'); } } /*********************************************************************/ char *ToUpperStr (char *str) { static char buffer[CF_BUFSIZE]; int i; memset(buffer,0,CF_BUFSIZE); if (strlen(str) >= CF_BUFSIZE) { char *tmp; tmp = malloc(40+strlen(str)); sprintf(tmp,"String too long in ToUpperStr: %s",str); FatalError(tmp); } for (i = 0; (str[i] != '\0') && (i < CF_BUFSIZE-1); i++) { buffer[i] = ToUpper(str[i]); } buffer[i] = '\0'; return buffer; } /*********************************************************************/ char *ToLowerStr (char *str) { static char buffer[CF_BUFSIZE]; int i; memset(buffer,0,CF_BUFSIZE); if (strlen(str) >= CF_BUFSIZE-1) { char *tmp; tmp = malloc(40+strlen(str)); snprintf(tmp,CF_BUFSIZE-1,"String too long in ToLowerStr: %s",str); FatalError(tmp); } for (i = 0; (str[i] != '\0') && (i < CF_BUFSIZE-1); i++) { buffer[i] = ToLower(str[i]); } buffer[i] = '\0'; return buffer; } /*********************************************************************/ char *Titleize (char *str) { static char buffer[CF_BUFSIZE]; int i; if (str == NULL) { return NULL; } strcpy(buffer,str); if (strlen(buffer) > 1) { for (i = 1; buffer[i] != '\0'; i++) { buffer[i] = ToLower(str[i]); } } *buffer = ToUpper(*buffer); return buffer; } /*********************************************************************/ int SubStrnCopyChr(char *to,char *from,int len,char sep) { char *sp,*sto = to; int count = 0; memset(to,0,len); if (from == NULL) { return 0; } if (from && strlen(from) == 0) { return 0; } for (sp = from; *sp != '\0'; sp++) { if (count > len-1) { break; } if (*sp == '\\' && *(sp+1) == sep) { *sto++ = *++sp; } else if (*sp == sep) { break; } else { *sto++ = *sp; } count++; } return count; } /*********************************************************************/ int CountChar(char *string,char sep) { char *sp; int count = 0; if (string == NULL) { return 0; } if (string && strlen(string) == 0) { return 0; } for (sp = string; *sp != '\0'; sp++) { if (*sp == '\\' && *(sp+1) == sep) { ++sp; } else if (*sp == sep) { count++; } } return count; } /*********************************************************************/ void ReplaceChar(char *in, char *out, int outSz, char from, char to) /* Replaces all occurences of 'from' to 'to' in preallocated * string 'out'. */ { int len; int i; memset(out,0,outSz); len = strlen(in); for(i = 0; (i < len) && (i < outSz - 1); i++) { if (in[i] == from) { out[i] = to; } else { out[i] = in[i]; } } } /*********************************************************************/ void ReplaceTrailingChar(char *str, char from, char to) /* Replaces any unwanted last char in str. */ { int strLen; strLen = strlen(str); if(strLen == 0) { return; } if(str[strLen - 1] == from) { str[strLen - 1] = to; } } /*********************************************************************/ void ReplaceTrailingStr(char *str, char *from, char to) /* Replaces any unwanted last chars in str. */ { int strLen; int fromLen; strLen = strlen(str); fromLen = strlen(from); if(strLen == 0) { return; } char *startCmp = str + strLen - fromLen; if(strcmp(startCmp, from) == 0) { memset(startCmp, to, fromLen); } } /*********************************************************************/ int ReplaceStr(char *in, char *out, int outSz, char* from, char *to) /* Replaces all occurences of strings 'from' to 'to' in preallocated * string 'out'. Returns true on success, false otherwise. */ { int inSz; int outCount; int inCount; int fromSz, toSz; memset(out,0,outSz); inSz = strlen(in); fromSz = strlen(from); toSz = strlen(to); inCount = 0; outCount = 0; while((inCount < inSz) && (outCount < outSz)) { if (strncmp(in + inCount, from, fromSz) == 0) { if(outCount + toSz >= outSz) { CfOut(cf_error, "", "!! Out of buffer in ReplaceStr"); return false; } strcat(out,to); inCount += fromSz; outCount += toSz; } else { out[outCount] = in[inCount]; inCount++; outCount++; } } return true; } /*********************************************************************/ #if defined HAVE_PTHREAD_H && (defined HAVE_LIBPTHREAD || defined BUILDTIN_GCC_THREAD) void *ThreadUniqueName(pthread_t tid) /* pthread_t is an integer on Unix, but a structure on Windows * Finds a unique name for a thread for both platforms. */ { #ifdef MINGW return tid.p; // pointer to thread structure #else return (void*)tid; // index into thread array ? #endif /* NOT MINGW */ } #endif /* HAVE PTHREAD */ cfengine-3.2.4/src/config.h0000644000175000017500000000007211707771422012433 00000000000000 /* Dummy file required for some malconfigured headers */ cfengine-3.2.4/src/comparray.c0000644000175000017500000000606211715232734013160 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*******************************************************************/ /* */ /* Compressed Arrays */ /* */ /*******************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*******************************************************************/ int FixCompressedArrayValue(int i,char *value,struct CompressedArray **start) { struct CompressedArray *ap; char *sp; for (ap = *start; ap != NULL; ap = ap->next) { if (ap->key == i) { /* value already fixed */ return false; } } Debug("FixCompressedArrayValue(%d,%s)\n",i,value); if ((ap = (struct CompressedArray *)malloc(sizeof(struct CompressedArray))) == NULL) { FatalError("Memory allocation in FixCompressedArray"); } if ((sp = malloc(strlen(value)+2)) == NULL) { FatalError("Memory allocation in FixCompressedArray"); } strcpy(sp,value); ap->key = i; ap->value = sp; ap->next = *start; *start = ap; return true; } /*******************************************************************/ void DeleteCompressedArray(struct CompressedArray *start) { if (start != NULL) { DeleteCompressedArray(start->next); start->next = NULL; if (start->value != NULL) { free(start->value); } free(start); } } /*******************************************************************/ int CompressedArrayElementExists(struct CompressedArray *start,int key) { struct CompressedArray *ap; Debug("CompressedArrayElementExists(%d)\n",key); for (ap = start; ap !=NULL; ap = ap->next) { if (ap->key == key) { return true; } } return false; } /*******************************************************************/ char *CompressedArrayValue(struct CompressedArray *start,int key) { struct CompressedArray *ap; for (ap = start; ap != NULL; ap = ap->next) { if (ap->key == key) { return ap->value; } } return NULL; } cfengine-3.2.4/src/mod_storage.c0000644000175000017500000001067311715232734013471 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_storage.c */ /* */ /*****************************************************************************/ /* This file can act as a template for adding functionality to cfengine 3. All functionality can be added by extending the main array CF_MOD_SUBTYPES[CF3_MODULES] and its array dimension, in mod_common, in the manner shown here. */ #define CF3_MOD_STORAGE #include "cf3.defs.h" #include "cf3.extern.h" /***********************************************************/ /* Read this module file backwards, as dependencies have */ /* to be defined first - these arrays declare pairs of */ /* constraints */ /* */ /* lval => rval */ /* */ /* in the form (lval,type,range) */ /* */ /* If the type is cf_body then the range is a pointer */ /* to another array of pairs, like in a body "sub-routine" */ /* */ /***********************************************************/ struct BodySyntax CF_CHECKVOL_BODY[] = { {"check_foreign",cf_opts,CF_BOOL,"true/false verify storage that is mounted from a foreign system on this host"}, {"freespace",cf_str,"[0-9]+[MBkKgGmb%]","Absolute or percentage minimum disk space that should be available before warning"}, {"sensible_size",cf_int,CF_VALRANGE,"Minimum size in bytes that should be used on a sensible-looking storage device"}, {"sensible_count",cf_int,CF_VALRANGE,"Minimum number of files that should be defined on a sensible-looking storage device"}, {"scan_arrivals",cf_opts,CF_BOOL,"true/false generate pseudo-periodic disk change arrival distribution"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_MOUNT_BODY[] = { {"edit_fstab",cf_opts,CF_BOOL,"true/false add or remove entries to the file system table (\"fstab\")"}, {"mount_type",cf_opts,"nfs,nfs2,nfs3,nfs4","Protocol type of remote file system"}, {"mount_source",cf_str,CF_ABSPATHRANGE,"Path of remote file system to mount"}, {"mount_server",cf_str,"","Hostname or IP or remote file system server"}, {"mount_options",cf_slist,"","List of option strings to add to the file system table (\"fstab\")"}, {"unmount",cf_opts,CF_BOOL,"true/false unmount a previously mounted filesystem"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ struct BodySyntax CF_STORAGE_BODIES[] = { {"mount",cf_body,CF_MOUNT_BODY,"Criteria for mounting foreign file systems"}, {"volume",cf_body,CF_CHECKVOL_BODY,"Criteria for monitoring/probing mounted volumes"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_STORAGE_SUBTYPES[] = { {"agent","storage",CF_STORAGE_BODIES}, {NULL,NULL,NULL}, }; cfengine-3.2.4/src/files_links.c0000644000175000017500000004225311715232734013467 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: files_links.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int MakeLink(char *from,char *to,struct Attributes attr,struct Promise *pp); static char *AbsLinkPath(char *from,char *relto); /*****************************************************************************/ char VerifyLink(char *destination,char *source,struct Attributes attr,struct Promise *pp) #ifdef MINGW { CfOut(cf_verbose, "", "Windows does not support symbolic links (at VerifyLink())"); return CF_FAIL; } #else /* NOT MINGW */ { char to[CF_BUFSIZE],linkbuf[CF_BUFSIZE],absto[CF_BUFSIZE]; int nofile = false; struct stat sb; Debug("Linkfiles(%s -> %s)\n",destination,source); /* if (MatchRlistItem(attr.link.copy_patterns,lastnode)) { CfOut(cf_verbose,"","cfengine: link item %s marked for copying instead\n",sourcefile); LinkCopy(sourcefile,destfile,&ssb,attr,pp); attr.copy_backup = true; CopyFile(source,destination,ssb,attr,pp); return; } */ memset(to,0,CF_BUFSIZE); if (!IsAbsoluteFileName(source) && (*source != '.')) /* links without a directory reference */ { snprintf(to,CF_BUFSIZE-1,"./%s",source); } else { strncpy(to,source,CF_BUFSIZE-1); } if (!IsAbsoluteFileName(to)) /* relative path, must still check if exists */ { Debug("Relative link destination detected: %s\n",to); strcpy(absto,AbsLinkPath(destination,to)); Debug("Absolute path to relative link = %s, destination %s\n",absto,destination); } else { strcpy(absto,to); } if (cfstat(absto,&sb) == -1) { Debug("No source file\n"); nofile = true; } if (nofile && (attr.link.when_no_file != cfa_force) && (attr.link.when_no_file != cfa_delete)) { CfOut(cf_inform,"","Source %s for linking is absent",absto); cfPS(cf_verbose,CF_FAIL,"",pp,attr," !! Unable to create link %s -> %s, no source",destination,to); return CF_WARN; } if (nofile && attr.link.when_no_file == cfa_delete) { KillGhostLink(destination,attr,pp); return CF_CHG; } memset(linkbuf,0,CF_BUFSIZE); if (readlink(destination,linkbuf,CF_BUFSIZE-1) == -1) { if (!MakeParentDirectory(destination,attr.move_obstructions)) /* link doesn't exist */ { cfPS(cf_verbose,CF_FAIL,"",pp,attr," !! Unable to create link %s -> %s",destination,to); return CF_FAIL; } else { if (!MoveObstruction(destination,attr,pp)) { cfPS(cf_verbose,CF_FAIL,"",pp,attr," !! Unable to create link %s -> %s",destination,to); return CF_FAIL; } return MakeLink(destination,to,attr,pp)?CF_CHG:CF_FAIL; } } else { int ok = false; if (attr.link.link_type == cfa_symlink && strcmp(linkbuf,to) != 0 && strcmp(linkbuf,source) != 0) { ok = true; } else if (strcmp(linkbuf,source) != 0) { ok = true; } if (ok) { if (attr.move_obstructions) { if (!DONTDO) { cfPS(cf_inform,CF_CHG,"",pp,attr,"Overriding incorrect link %s\n",destination); if (unlink(destination) == -1) { cfPS(cf_verbose,CF_FAIL,"",pp,attr," !! Link %s points to %s not %s - error removing link",destination,linkbuf,to); return CF_FAIL; } return MakeLink(destination,to,attr,pp); } else { CfOut(cf_error,""," !! Must remove incorrect link %s\n",destination); return CF_NOP; } } else { cfPS(cf_verbose,CF_FAIL,"",pp,attr," !! Link %s points to %s not %s - not authorized to override",destination,linkbuf,to); return true; } } else { cfPS(cf_verbose,CF_NOP,"",pp,attr," -> Link %s points to %s - promise kept",destination,to); return CF_NOP; } } } #endif /* NOT MINGW */ /*****************************************************************************/ char VerifyAbsoluteLink(char *destination,char *source,struct Attributes attr,struct Promise *pp) { char absto[CF_BUFSIZE]; char expand[CF_BUFSIZE]; char linkto[CF_BUFSIZE]; Debug("VerifyAbsoluteLink(%s,%s)\n",destination,source); if (*source == '.') { strcpy(linkto,destination); ChopLastNode(linkto); AddSlash(linkto); strcat(linkto,source); } else { strcpy(linkto,source); } CompressPath(absto,linkto); expand[0] = '\0'; if (attr.link.when_no_file == cfa_force) { if (!ExpandLinks(expand,absto,0)) /* begin at level 1 and beam out at 15 */ { CfOut(cf_error,""," !! Failed to make absolute link in\n"); PromiseRef(cf_error,pp); return CF_FAIL; } else { Debug2("ExpandLinks returned %s\n",expand); } } else { strcpy(expand,absto); } CompressPath(linkto,expand); return VerifyLink(destination,linkto,attr,pp); } /*****************************************************************************/ char VerifyRelativeLink(char *destination,char *source,struct Attributes attr,struct Promise *pp) { char *sp, *commonto, *commonfrom; char buff[CF_BUFSIZE],linkto[CF_BUFSIZE],add[CF_BUFSIZE]; int levels=0; Debug("RelativeLink(%s,%s)\n",destination,source); if (*source == '.') { return VerifyLink(destination,source,attr,pp); } if (!CompressPath(linkto,source)) { cfPS(cf_error,CF_INTERPT,"",pp,attr," !! Failed to link %s to %s\n",destination,source); return CF_FAIL; } commonto = linkto; commonfrom = destination; if (strcmp(commonto,commonfrom) == 0) { cfPS(cf_error,CF_INTERPT,"",pp,attr," !! Failed to link %s to %s - can't link file %s to itself\n",destination,source,commonto); return CF_FAIL; } while (*commonto == *commonfrom) { commonto++; commonfrom++; } while (!(IsAbsoluteFileName(commonto) && IsAbsoluteFileName(commonfrom))) { commonto--; commonfrom--; } commonto++; for (sp = commonfrom; *sp != '\0'; sp++) { if (IsFileSep(*sp)) { levels++; } } memset(buff,0,CF_BUFSIZE); strcat(buff,"."); strcat(buff,FILE_SEPARATOR_STR); while(--levels > 0) { snprintf(add,CF_BUFSIZE-1,"..%c",FILE_SEPARATOR); if (!JoinPath(buff,add)) { return CF_FAIL; } } if (!JoinPath(buff,commonto)) { return CF_FAIL; } return VerifyLink(destination,buff,attr,pp); } /*****************************************************************************/ char VerifyHardLink(char *destination,char *source,struct Attributes attr,struct Promise *pp) { char to[CF_BUFSIZE],absto[CF_BUFSIZE]; struct stat ssb,dsb; memset(to,0,CF_BUFSIZE); if (!IsAbsoluteFileName(source) && (*source != '.')) /* links without a directory reference */ { snprintf(to,CF_BUFSIZE-1,".%c%s",FILE_SEPARATOR,source); } else { strncpy(to,source,CF_BUFSIZE-1); } if (!IsAbsoluteFileName(to)) /* relative path, must still check if exists */ { Debug("Relative link destination detected: %s\n",to); strcpy(absto,AbsLinkPath(destination,to)); Debug("Absolute path to relative link = %s, destination %s\n",absto,destination); } else { strcpy(absto,to); } if (cfstat(absto,&ssb) == -1) { cfPS(cf_inform,CF_INTERPT,"",pp,attr," !! Source file %s doesn't exist\n",source); return CF_WARN; } if (!S_ISREG(ssb.st_mode)) { cfPS(cf_inform,CF_FAIL,"",pp,attr," !! Source file %s is not a regular file, not appropriate to hard-link\n",to); return CF_WARN; } Debug2("Trying to (hard) link %s -> %s\n",destination,to); if (cfstat(destination,&dsb) == -1) { return MakeHardLink(destination,to,attr,pp)?CF_CHG:CF_FAIL; } /* both files exist, but are they the same file? POSIX says */ /* the files could be on different devices, but unix doesn't */ /* allow this behaviour so the tests below are theoretical...*/ if (dsb.st_ino != ssb.st_ino && dsb.st_dev != ssb.st_dev) { CfOut(cf_verbose,""," !! If this is POSIX, unable to determine if %s is hard link is correct\n",destination); CfOut(cf_verbose,""," !! since it points to a different filesystem!\n"); if (dsb.st_mode == ssb.st_mode && dsb.st_size == ssb.st_size) { cfPS(cf_verbose,CF_NOP,"",pp,attr,"Hard link (%s->%s) on different device APPEARS okay\n",destination,to); return CF_NOP; } } if (dsb.st_ino == ssb.st_ino && dsb.st_dev == ssb.st_dev) { cfPS(cf_verbose,CF_NOP,"",pp,attr," -> Hard link (%s->%s) exists and is okay\n",destination,to); return CF_NOP; } CfOut(cf_inform,""," !! %s does not appear to be a hard link to %s\n",destination,to); if (!MoveObstruction(destination,attr,pp)) { return CF_FAIL; } return MakeHardLink(destination,to,attr,pp)?CF_CHG:CF_FAIL; } /*****************************************************************************/ /* Level */ /*****************************************************************************/ int KillGhostLink(char *name,struct Attributes attr,struct Promise *pp) #ifdef MINGW { CfOut(cf_verbose, "", "Windows does not support symbolic links (at KillGhostLink())"); cfPS(cf_error,CF_FAIL,"",pp,attr," !! Windows does not support killing link \"%s\"", name); return false; } #else /* NOT MINGW */ { char linkbuf[CF_BUFSIZE],tmp[CF_BUFSIZE]; char linkpath[CF_BUFSIZE],*sp; struct stat statbuf; Debug("KillGhostLink(%s)\n",name); memset(linkbuf,0,CF_BUFSIZE); memset(linkpath,0,CF_BUFSIZE); if (readlink(name,linkbuf,CF_BUFSIZE-1) == -1) { CfOut(cf_verbose,""," !! (Can't read link %s while checking for deadlinks)\n",name); return true; /* ignore */ } if (!IsAbsoluteFileName(linkbuf)) { strcpy(linkpath,name); /* Get path to link */ for (sp = linkpath+strlen(linkpath); (*sp != FILE_SEPARATOR) && (sp >= linkpath); sp-- ) { *sp = '\0'; } } strcat(linkpath,linkbuf); CompressPath(tmp,linkpath); if (cfstat(tmp,&statbuf) == -1) /* link points nowhere */ { if (attr.link.when_no_file == cfa_delete || attr.recursion.rmdeadlinks) { CfOut(cf_verbose,""," !! %s is a link which points to %s, but that file doesn't seem to exist\n",name,linkbuf); if (!DONTDO) { unlink(name); /* May not work on a client-mounted system ! */ cfPS(cf_inform,CF_CHG,"",pp,attr," -> Removing ghost %s - reference to something that is not there\n",name); return true; } } } return false; } #endif /* NOT MINGW */ /*****************************************************************************/ static int MakeLink (char *from,char *to,struct Attributes attr,struct Promise *pp) #ifdef MINGW // TODO: Remove? Should never get called. { CfOut(cf_verbose, "", "Windows does not support symbolic links"); cfPS(cf_error,CF_FAIL,"symlink",pp,attr," !! Couldn't link %s to %s\n",to,from); return false; } #else /* NOT MINGW */ { if (DONTDO || attr.transaction.action == cfa_warn) { CfOut(cf_error,""," !! Need to link files %s -> %s\n",from,to); return false; } else { if (symlink(to,from) == -1) { cfPS(cf_error,CF_FAIL,"symlink",pp,attr," !! Couldn't link %s to %s\n",to,from); return false; } else { cfPS(cf_inform,CF_CHG,"",pp,attr," -> Linked files %s -> %s\n",from,to); return true; } } } #endif /* NOT MINGW */ /*****************************************************************************/ int MakeHardLink (char *from,char *to,struct Attributes attr,struct Promise *pp) #ifdef MINGW { // TODO: Implement ? CfOut(cf_verbose, "", "Hard links are not yet supported on Windows"); cfPS(cf_error,CF_FAIL,"link",pp,attr," !! Couldn't (hard) link %s to %s\n",to,from); return false; } #else /* NOT MINGW */ { if (DONTDO) { CfOut(cf_error,""," !! Need to hard link files %s -> %s\n",from,to); return false; } else { if (link(to,from) == -1) { cfPS(cf_error,CF_FAIL,"link",pp,attr," !! Couldn't (hard) link %s to %s\n",to,from); return false; } else { cfPS(cf_inform,CF_CHG,"",pp,attr," -> (Hard) Linked files %s -> %s\n",from,to); return true; } } } #endif /* NOT MINGW */ /*********************************************************************/ int ExpandLinks(char *dest,char *from,int level) /* recursive */ /* Expand a path contaning symbolic links, up to 4 levels */ /* of symbolic links and then beam out in a hurry ! */ #ifdef MINGW { CfOut(cf_error, "", "!! Windows does not support symbolic links (at ExpandLinks(%s,%s))", dest, from); return false; } #else /* NOT MINGW */ { char *sp, buff[CF_BUFSIZE]; char node[CF_MAXLINKSIZE]; struct stat statbuf; int lastnode = false; memset(dest,0,CF_BUFSIZE); if (level >= CF_MAXLINKLEVEL) { CfOut(cf_error,""," !! Too many levels of symbolic links to evaluate absolute path\n"); return false; } sp = from; while (*sp != '\0') { if (*sp == FILE_SEPARATOR) { sp++; continue; } sscanf(sp,"%[^/]",node); sp += strlen(node); if (*sp == '\0') { lastnode = true; } if (strcmp(node,".") == 0) { continue; } if (strcmp(node,"..") == 0) { continue; } else { strcat(dest,"/"); } strcat(dest,node); if (lstat(dest,&statbuf) == -1) /* File doesn't exist so we can stop here */ { CfOut(cf_error,"lstat"," !! Can't stat %s in ExpandLinks\n",dest); return false; } if (S_ISLNK(statbuf.st_mode)) { memset(buff,0,CF_BUFSIZE); if (readlink(dest,buff,CF_BUFSIZE-1) == -1) { CfOut(cf_error,"readlink"," !! Expand links can't stat %s\n",dest); return false; } else { if (buff[0] == '.') { ChopLastNode(dest); AddSlash(dest); if (!JoinPath(dest,buff)) { return false; } } else if (IsAbsoluteFileName(buff)) { strcpy(dest,buff); DeleteSlash(dest); if (strcmp(dest,from) == 0) { Debug2("No links to be expanded\n"); return true; } if (!lastnode && !ExpandLinks(buff,dest,level+1)) { return false; } } else { ChopLastNode(dest); AddSlash(dest); strcat(dest,buff); DeleteSlash(dest); if (strcmp(dest,from) == 0) { Debug2("No links to be expanded\n"); return true; } memset(buff,0,CF_BUFSIZE); if (!lastnode && !ExpandLinks(buff,dest,level+1)) { return false; } } } } } return true; } #endif /* NOT MINGW */ /*********************************************************************/ static char *AbsLinkPath (char *from,char *relto) /* Take an abolute source and a relative destination object and find the absolute name of the to object */ { char *sp; int pop = 1; static char destination[CF_BUFSIZE]; if (IsAbsoluteFileName(relto)) { FatalError("Cfengine internal error: call to AbsLInkPath with absolute pathname\n"); } strcpy(destination,from); /* reuse to save stack space */ for (sp = relto; *sp != '\0'; sp++) { if (strncmp(sp,"../",3) == 0) { pop++; sp += 2; continue; } if (strncmp(sp,"./",2) == 0) { sp += 1; continue; } break; /* real link */ } while (pop > 0) { ChopLastNode(destination); pop--; } if (strlen(destination) == 0) { strcpy(destination,"/"); } else { AddSlash(destination); } strcat(destination,sp); Debug("Reconstructed absolute linkname = %s\n",destination); return destination; } cfengine-3.2.4/src/mon_cpu.c0000644000175000017500000000561711715232734012630 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #include "cf3.defs.h" #include "cf3.extern.h" #include "monitoring.h" #if !defined(MINGW) /* Constants */ #define MON_CPU_MAX 4 /* Globals */ static double LAST_CPU_Q[MON_CPU_MAX + 1]; static long LAST_CPU_T[MON_CPU_MAX + 1]; /* Implementation */ void MonCPUGatherData(double *cf_this) { double q,dq; char name[CF_MAXVARSIZE],cpuname[CF_MAXVARSIZE],buf[CF_BUFSIZE]; long cpuidx,userticks=0,niceticks=0,systemticks=0,idle=0,iowait=0,irq=0,softirq=0; long total_time = 1; FILE *fp; enum observables slot = ob_spare; if ((fp=fopen("/proc/stat","r")) == NULL) { CfOut(cf_verbose,"","Didn't find proc data\n"); return; } CfOut(cf_verbose,"","Reading /proc/stat utilization data -------\n"); while (!feof(fp)) { fgets(buf,CF_BUFSIZE,fp); sscanf(buf,"%s%ld%ld%ld%ld%ld%ld%ld",cpuname,&userticks,&niceticks,&systemticks,&idle,&iowait,&irq,&softirq); total_time = (userticks+niceticks+systemticks+idle); q = 100.0 * (double)(total_time - idle); if (strcmp(cpuname,"cpu") == 0) { CfOut(cf_verbose,"","Found aggregate CPU\n",cpuidx); slot = ob_cpuall; cpuidx = MON_CPU_MAX; } else if (strncmp(cpuname, "cpu", 3) == 0) { if (sscanf(cpuname, "cpu%d", &cpuidx) == 1) { if (cpuidx < 0 || cpuidx >= MON_CPU_MAX) { continue; } } slot = ob_cpu0 + cpuidx; } else { CfOut(cf_verbose,"","Found nothing (%s)\n",cpuname); slot = ob_spare; fclose(fp); return; } dq = (q - LAST_CPU_Q[cpuidx])/(double)(total_time-LAST_CPU_T[cpuidx]); /* % Utilization */ if (dq > 100 || dq < 0) // Counter wrap around { dq = 50; } cf_this[slot] = dq; LAST_CPU_Q[cpuidx] = q; LAST_CPU_T[cpuidx] = total_time; CfOut(cf_verbose,"","Set %s=%d to %.1lf after %ld 100ths of a second \n",OBS[slot][1],slot,cf_this[slot],total_time); } fclose(fp); } #endif /* !MINGW */ cfengine-3.2.4/src/processes_select.c0000644000175000017500000002732511715232734014535 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: processes_select.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int SelectProcRangeMatch(char *name1,char *name2,int min,int max,char **names,char **line); static int SelectProcRegexMatch(char *name1,char *name2,char *regex,char **colNames,char **line); static int SplitProcLine(char *proc,char **names,int *start,int *end,char **line); static int SelectProcTimeCounterRangeMatch(char *name1,char *name2,time_t min,time_t max,char **names,char **line); static int SelectProcTimeAbsRangeMatch(char *name1,char *name2,time_t min,time_t max,char **names,char **line); static int GetProcColumnIndex(char *name1,char *name2,char **names); /***************************************************************************/ int SelectProcess(char *procentry,char **names,int *start,int *end,struct Attributes a,struct Promise *pp) { struct AlphaList proc_attr; int result = true,i; char *column[CF_PROCCOLS]; struct Rlist *rp; Debug("SelectProcess(%s)\n",procentry); InitAlphaList(&proc_attr); if (!a.haveselect) { return true; } if (!SplitProcLine(procentry,names,start,end,column)) { return false; } if (DEBUG) { for (i = 0; names[i] != NULL; i++) { printf("COL[%s] = \"%s\"\n",names[i],column[i]); } } for (rp = a.process_select.owner; rp != NULL; rp = rp->next) { if (SelectProcRegexMatch("USER","UID",(char *)rp->item,names,column)) { PrependAlphaList(&proc_attr,"process_owner"); break; } } if (SelectProcRangeMatch("PID","PID",a.process_select.min_pid,a.process_select.max_pid,names,column)) { PrependAlphaList(&proc_attr,"pid"); } if (SelectProcRangeMatch("PPID","PPID",a.process_select.min_ppid,a.process_select.max_ppid,names,column)) { PrependAlphaList(&proc_attr,"ppid"); } if (SelectProcRangeMatch("PGID","PGID",a.process_select.min_pgid,a.process_select.max_pgid,names,column)) { PrependAlphaList(&proc_attr,"pgid"); } if (SelectProcRangeMatch("VSZ","SZ",a.process_select.min_vsize,a.process_select.max_vsize,names,column)) { PrependAlphaList(&proc_attr,"vsize"); } if (SelectProcRangeMatch("RSS","RSS",a.process_select.min_rsize,a.process_select.max_rsize,names,column)) { PrependAlphaList(&proc_attr,"rsize"); } if (SelectProcTimeCounterRangeMatch("TIME","TIME",a.process_select.min_ttime,a.process_select.max_ttime,names,column)) { PrependAlphaList(&proc_attr,"ttime"); } if (SelectProcTimeAbsRangeMatch("STIME","START",a.process_select.min_stime,a.process_select.max_stime,names,column)) { PrependAlphaList(&proc_attr,"stime"); } if (SelectProcRangeMatch("NI","PRI",a.process_select.min_pri,a.process_select.max_pri,names,column)) { PrependAlphaList(&proc_attr,"priority"); } if (SelectProcRangeMatch("NLWP","NLWP",a.process_select.min_thread,a.process_select.max_thread,names,column)) { PrependAlphaList(&proc_attr,"threads"); } if (SelectProcRegexMatch("S","STAT",a.process_select.status,names,column)) { PrependAlphaList(&proc_attr,"status"); } if (SelectProcRegexMatch("CMD","COMMAND",a.process_select.command,names,column)) { PrependAlphaList(&proc_attr,"command"); } if (SelectProcRegexMatch("TTY","TTY",a.process_select.tty,names,column)) { PrependAlphaList(&proc_attr,"tty"); } if ((result = EvalProcessResult(a.process_select.process_result,&proc_attr))) { //ClassesFromString(fp->defines); } DeleteAlphaList(&proc_attr); if (result) { if (a.transaction.action == cfa_warn) { CfOut(cf_error,""," !! Matched: %s\n",procentry); } else { CfOut(cf_inform,""," !! Matched: %s\n",procentry); } } for (i = 0; column[i] != NULL; i++) { free(column[i]); } return result; } /***************************************************************************/ /* Level */ /***************************************************************************/ static int SelectProcRangeMatch(char *name1,char *name2,int min,int max,char **names,char **line) { int i; long value; if (min == CF_NOINT || max == CF_NOINT) { return false; } if ((i = GetProcColumnIndex(name1,name2,names)) != -1) { value = Str2Int(line[i]); if (value == CF_NOINT) { CfOut(cf_inform,"","Failed to extract a valid integer from %s => \"%s\" in process list\n",names[i],line[i]); return false; } if (min <= value && value <= max) { return true; } else { return false; } } return false; } /***************************************************************************/ static int SelectProcTimeCounterRangeMatch(char *name1,char *name2,time_t min,time_t max,char **names,char **line) { int i; time_t value; if (min == CF_NOINT || max == CF_NOINT) { return false; } if ((i = GetProcColumnIndex(name1,name2,names)) != -1) { value = (time_t) TimeCounter2Int(line[i]); if (value == CF_NOINT) { CfOut(cf_inform,"","Failed to extract a valid integer from %s => \"%s\" in process list\n",name1[i],line[i]); return false; } if (min <= value && value <= max) { CfOut(cf_verbose,"","Selection filter matched counter range %s/%s = %s in [%ld,%ld] (= %ld secs)\n",name1,name2,line[i],min,max,value); return true; } else { Debug("Selection filter REJECTED counter range %s/%s = %s in [%ld,%ld] (= %ld secs)\n",name1,name2,line[i],min,max,value); return false; } } return false; } /***************************************************************************/ static int SelectProcTimeAbsRangeMatch(char *name1,char *name2,time_t min,time_t max,char **names,char **line) { int i; time_t value; if (min == CF_NOINT || max == CF_NOINT) { return false; } if ((i = GetProcColumnIndex(name1,name2,names)) != -1) { value = (time_t)TimeAbs2Int(line[i]); if (value == CF_NOINT) { CfOut(cf_inform,"","Failed to extract a valid integer from %s => \"%s\" in process list\n",name1[i],line[i]); return false; } if (min <= value && value <= max) { CfOut(cf_verbose,"","Selection filter matched absolute %s/%s = %s in [%ld,%ld]\n",name1,name2,line[i],min,max); return true; } else { return false; } } return false; } /***************************************************************************/ static int SelectProcRegexMatch(char *name1,char *name2,char *regex,char **colNames,char **line) { int i; if (regex == NULL) { return false; } if ((i = GetProcColumnIndex(name1,name2,colNames)) != -1) { if (FullTextMatch(regex,line[i])) { return true; } else { return false; } } return false; } /*******************************************************************/ static int SplitProcLine(char *proc,char **names,int *start,int *end,char **line) { int i,s,e; char *sp = NULL; char cols1[CF_PROCCOLS][CF_SMALLBUF] = { "" }; char cols2[CF_PROCCOLS][CF_SMALLBUF] = { "" }; Debug("SplitProcLine(%s)\n",proc); if (proc == NULL || strlen(proc) == 0) { return false; } memset(line, 0, sizeof(char *) * CF_PROCCOLS); // First try looking at all the separable items sp = proc; for (i = 0; i < CF_PROCCOLS && names[i] != NULL; i++) { while(*sp == ' ') { sp++; } if (strcmp(names[i],"CMD") == 0 || strcmp(names[i],"COMMAND") == 0) { sscanf(sp,"%127[^\n]",cols1[i]); sp += strlen(cols1[i]); } else { sscanf(sp,"%127s",cols1[i]); sp += strlen(cols1[i]); } // Some ps stimes may contain spaces, e.g. "Jan 25" if (strcmp(names[i],"STIME") == 0 && strlen(cols1[i]) == 3) { char s[CF_SMALLBUF] = {0}; sscanf(sp,"%127s",s); strcat(cols1[i]," "); strcat(cols1[i],s); sp += strlen(s)+1; } } // Now try looking at columne alignment for (i = 0; i < CF_PROCCOLS && names[i] != NULL; i++) { // Start from the header/column tab marker and count backwards until we find 0 or space for (s = start[i]; (s >= 0) && !isspace((int)*(proc+s)); s--) { } if (s < 0) { s = 0; } // Make sure to strip off leading spaces while (isspace((int)proc[s])) { s++; } if (strcmp(names[i],"CMD") == 0 || strcmp(names[i],"COMMAND") == 0) { e = strlen(proc); } else { for (e = end[i]; (e <= end[i]+10) && !isspace((int)*(proc+e)); e++) { } while (isspace((int)proc[e])) { if (e > 0) { e--; } } } if (s <= e) { strncpy(cols2[i],(char *)(proc+s),MIN(CF_SMALLBUF-1,(e-s+1))); } else { cols2[i][0] = '\0'; } Chop(cols2[i]); if (strcmp(cols2[i],cols1[i]) != 0) { CfOut(cf_inform,""," !! Unacceptable model uncertainty examining processes"); } line[i] = strdup(cols1[i]); } return true; } /*******************************************************************/ static int GetProcColumnIndex(char *name1,char *name2,char **names) { int i; for (i = 0; names[i] != NULL; i++) { if ((strcmp(names[i],name1) == 0) || (strcmp(names[i],name2) == 0)) { return i; } } CfOut(cf_verbose,""," INFO - process column %s/%s was not supported on this system",name1,name2); return -1; } /**********************************************************************************/ bool IsProcessNameRunning(char *procNameRegex) { char *colHeaders[CF_PROCCOLS]; struct Item *ip; int start[CF_PROCCOLS] = {0}; int end[CF_PROCCOLS] = {0}; bool matched = false; if (PROCESSTABLE == NULL) { CfOut(cf_error, "", "!! IsProcessNameRunning: PROCESSTABLE is empty"); return false; } GetProcessColumnNames(PROCESSTABLE->name,(char **)colHeaders,start,end); for (ip = PROCESSTABLE->next; ip != NULL; ip=ip->next) // iterate over ps lines { if(EMPTY(ip->name)) { continue; } char *lineSplit[CF_PROCCOLS]; if (!SplitProcLine(ip->name,colHeaders,start,end,lineSplit)) { CfOut(cf_error, "", "!! IsProcessNameRunning: Could not split process line \"%s\"", ip->name); continue; } if (SelectProcRegexMatch("CMD","COMMAND",procNameRegex,colHeaders,lineSplit)) { matched = true; break; } } return matched; } cfengine-3.2.4/src/html.c0000644000175000017500000000700211715232734012122 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: html.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static char *URLControl(char *driver,char *url); /*****************************************************************************/ void CfHtmlHeader(FILE *fp,char *title,char *css,char *webdriver,char *header) { if (title == NULL) { title = "Cfengine Knowledge"; } fprintf(fp,"\n" " \n" " \n" " \n" " %s\n" " \n" " \n" " \n" " \n",title,css,css); if (header && strlen(header) > 0) { if (strlen(LICENSE_COMPANY) > 0) { fprintf(fp,"
%s
\n%s\n",LICENSE_COMPANY,header); } else { fprintf(fp,"%s\n",header); } } fprintf(fp,"
\n"); } /*****************************************************************************/ void CfHtmlFooter(FILE *fp,char *footer) { if (strlen(footer) > 0) { fprintf(fp,"%s",footer); } fprintf(fp,"
\n"); } /*****************************************************************************/ int IsHtmlHeader(char *s) { char *str[] = { "", "", "", "", "", "<meta", "<link", "head>", "<div id=\"primary\">", NULL}; int i; for (i = 0; str[i] != NULL; i++) { if (strstr(s,str[i])) { return true; } } return false; } /*****************************************************************************/ void CfHtmlTitle(FILE *fp,char *title) { fprintf(fp,"<h1>%s</h1>\n",title); } /*********************************************************************/ char *URLControl(char *driver,char *url) { static char transform[CF_BUFSIZE]; if (strncmp(url,"http",4) == 0 || strstr(url,"php")) { return url; } snprintf(transform,CF_BUFSIZE-1,"%s?quote=%s",driver,url); return transform; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/constraints.c��������������������������������������������������������������������0000644�0001750�0001750�00000055162�11715232734�013537� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: constraints.c */ /* */ /* Created: Wed Oct 17 13:00:08 2007 */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static struct PromiseIdent *PromiseIdExists(char *handle); static void DeleteAllPromiseIdsRecurse(struct PromiseIdent *key); static int VerifyConstraintName(char *lval); static void PostCheckConstraint(char *type,char *bundle,char *lval,void *rval,char rvaltype); /*******************************************************************/ struct Constraint *AppendConstraint(struct Constraint **conlist,char *lval, void *rval, char type,char *classes,int body) /* Note rval must be pre-allocated for this function, e.g. use CopyRvalItem in call. This is to make the parser and var expansion non-leaky */ { struct Constraint *cp,*lp; char *sp = NULL; int i; switch(type) { case CF_SCALAR: Debug(" Appending Constraint: %s => %s\n",lval,rval); if (PARSING && strcmp(lval,"ifvarclass") == 0) { ValidateClassSyntax(rval); } break; case CF_FNCALL: Debug(" Appending a function call to rhs\n"); break; case CF_LIST: Debug(" Appending a list to rhs\n"); } // Check class if (THIS_AGENT_TYPE == cf_common) { PostCheckConstraint("none","none",lval,rval,type); } if ((cp = (struct Constraint *)malloc(sizeof(struct Constraint))) == NULL) { CfOut(cf_error,"malloc","Unable to allocate Constraint"); FatalError(""); } if ((sp = strdup(lval)) == NULL) { CfOut(cf_error,"strdup","Unable to allocate Constraint lval"); FatalError(""); } if (*conlist == NULL) { *conlist = cp; } else { for (lp = *conlist; lp->next != NULL; lp=lp->next) { } lp->next = cp; } if (classes != NULL) { if ((cp->classes = strdup(classes)) == NULL) { CfOut(cf_error,"mstrdup","Unable to allocate Constraint classes"); FatalError(""); } } else { cp->classes = NULL; } cp->audit = AUDITPTR; cp->lineno = P.line_no; cp->lval = sp; cp->rval = rval; cp->type = type; /* literal, bodyname, builtin function */ cp->isbody = body; cp->next = NULL; return cp; } /*****************************************************************************/ void EditScalarConstraint(struct Constraint *conlist,char *lval,char *rval) { struct Constraint *cp; for (cp = conlist; cp != NULL; cp = cp->next) { if (strcmp(lval,cp->lval) == 0) { if (cp->rval) { DeleteRvalItem(cp->rval,cp->type); } cp->rval = strdup(rval); cp->type = CF_SCALAR; return; } } } /*****************************************************************************/ void DeleteConstraintList(struct Constraint *conlist) { struct Constraint *cp, *next; Debug("DeleteConstraintList()\n"); for (cp = conlist; cp != NULL; cp = next) { Debug("Delete lval = %s,%c\n",cp->lval,cp->type); next = cp->next; if (cp->rval) { DeleteRvalItem(cp->rval,cp->type); } if (cp->lval) { free((char *)cp->lval); } if (cp->classes) { free(cp->classes); } free((char *)cp); } } /*****************************************************************************/ int GetBooleanConstraint(char *lval,struct Promise *pp) { struct Constraint *cp; int retval = CF_UNDEFINED; for (cp = pp->conlist; cp != NULL; cp=cp->next) { if (strcmp(cp->lval,lval) == 0) { if (IsDefinedClass(cp->classes)) { if (retval != CF_UNDEFINED) { CfOut(cf_error,""," !! Multiple \"%s\" (boolean) constraints break this promise\n",lval); PromiseRef(cf_error,pp); } } else { continue; } if (cp->type != CF_SCALAR) { CfOut(cf_error,""," !! Type mismatch on rhs - expected type (%c) for boolean constraint \"%s\"\n",cp->type,lval); PromiseRef(cf_error,pp); FatalError("Aborted"); } if (strcmp(cp->rval,"true") == 0||strcmp(cp->rval,"yes") == 0) { retval = true; continue; } if (strcmp(cp->rval,"false") == 0||strcmp(cp->rval,"no") == 0) { retval = false; } } } if (retval == CF_UNDEFINED) { retval = false; } return retval; } /*****************************************************************************/ int GetRawBooleanConstraint(char *lval,struct Constraint *list) { struct Constraint *cp; int retval = CF_UNDEFINED; for (cp = list; cp != NULL; cp=cp->next) { if (strcmp(cp->lval,lval) == 0) { if (IsDefinedClass(cp->classes)) { if (retval != CF_UNDEFINED) { CfOut(cf_error,""," !! Multiple \"%s\" (boolean) body constraints break this promise\n",lval); } } else { continue; } if (cp->type != CF_SCALAR) { CfOut(cf_error,""," !! Type mismatch - expected type (%c) for boolean constraint \"%s\"\n",cp->type,lval); FatalError("Aborted"); } if (strcmp(cp->rval,"true") == 0||strcmp(cp->rval,"yes") == 0) { retval = true; continue; } if (strcmp(cp->rval,"false") == 0||strcmp(cp->rval,"no") == 0) { retval = false; } } } if (retval == CF_UNDEFINED) { retval = false; } return retval; } /*****************************************************************************/ int GetBundleConstraint(char *lval,struct Promise *pp) { struct Constraint *cp; int retval = CF_UNDEFINED; for (cp = pp->conlist; cp != NULL; cp=cp->next) { if (strcmp(cp->lval,lval) == 0) { if (IsDefinedClass(cp->classes)) { if (retval != CF_UNDEFINED) { CfOut(cf_error,""," !! Multiple \"%s\" constraints break this promise\n",lval); PromiseRef(cf_error,pp); } } else { continue; } if (!(cp->type == CF_FNCALL || cp->type == CF_SCALAR)) { CfOut(cf_error,"","Anomalous type mismatch - type (%c) for bundle constraint %s did not match internals\n",cp->type,lval); PromiseRef(cf_error,pp); FatalError("Aborted"); } return true; } } return false; } /*****************************************************************************/ int GetIntConstraint(char *lval,struct Promise *pp) { struct Constraint *cp; int retval = CF_NOINT; for (cp = pp->conlist; cp != NULL; cp=cp->next) { if (strcmp(cp->lval,lval) == 0) { if (IsDefinedClass(cp->classes)) { if (retval != CF_NOINT) { CfOut(cf_error,""," !! Multiple \"%s\" (int) constraints break this promise\n",lval); PromiseRef(cf_error,pp); } } else { continue; } if (cp->type != CF_SCALAR) { CfOut(cf_error,"","Anomalous type mismatch - expected type for int constraint %s did not match internals\n",lval); PromiseRef(cf_error,pp); FatalError("Aborted"); } retval = (int)Str2Int((char *)cp->rval); } } return retval; } /*****************************************************************************/ double GetRealConstraint(char *lval,struct Promise *pp) { struct Constraint *cp; double retval = CF_NODOUBLE; for (cp = pp->conlist; cp != NULL; cp=cp->next) { if (strcmp(cp->lval,lval) == 0) { if (IsDefinedClass(cp->classes)) { if (retval != CF_NODOUBLE) { CfOut(cf_error,""," !! Multiple \"%s\" (real) constraints break this promise\n",lval); } } else { continue; } if (cp->type != CF_SCALAR) { CfOut(cf_error,"","Anomalous type mismatch - expected type for int constraint %s did not match internals\n",lval); FatalError("Aborted"); } retval = Str2Double((char *)cp->rval); } } return retval; } /*****************************************************************************/ mode_t GetOctalConstraint(char *lval,struct Promise *pp) { struct Constraint *cp; mode_t retval = 077; // We could handle units here, like kb,b,mb for (cp = pp->conlist; cp != NULL; cp=cp->next) { if (strcmp(cp->lval,lval) == 0) { if (IsDefinedClass(cp->classes)) { if (retval != 077) { CfOut(cf_error,""," !! Multiple \"%s\" (int,octal) constraints break this promise\n",lval); PromiseRef(cf_error,pp); } } else { continue; } if (cp->type != CF_SCALAR) { CfOut(cf_error,"","Anomalous type mismatch - expected type for int constraint %s did not match internals\n",lval); PromiseRef(cf_error,pp); FatalError("Aborted"); } retval = Str2Mode((char *)cp->rval); } } return retval; } /*****************************************************************************/ uid_t GetUidConstraint(char *lval,struct Promise *pp) #ifdef MINGW { // we use sids on windows instead return CF_SAME_OWNER; } #else /* NOT MINGW */ { struct Constraint *cp; int retval = CF_SAME_OWNER; char buffer[CF_MAXVARSIZE]; for (cp = pp->conlist; cp != NULL; cp=cp->next) { if (strcmp(cp->lval,lval) == 0) { if (IsDefinedClass(cp->classes)) { if (retval != CF_UNDEFINED) { CfOut(cf_error,""," !! Multiple \"%s\" (owner/uid) constraints break this promise\n",lval); PromiseRef(cf_error,pp); } } else { continue; } if (cp->type != CF_SCALAR) { CfOut(cf_error,"","Anomalous type mismatch - expected type for owner constraint %s did not match internals\n",lval); PromiseRef(cf_error,pp); FatalError("Aborted"); } retval = Str2Uid((char *)cp->rval,buffer,pp); } } return retval; } #endif /* NOT MINGW */ /*****************************************************************************/ gid_t GetGidConstraint(char *lval,struct Promise *pp) #ifdef MINGW { // not applicable on windows: processes have no group return CF_SAME_GROUP; } #else { struct Constraint *cp; int retval = CF_SAME_OWNER; char buffer[CF_MAXVARSIZE]; for (cp = pp->conlist; cp != NULL; cp=cp->next) { if (strcmp(cp->lval,lval) == 0) { if (IsDefinedClass(cp->classes)) { if (retval != CF_UNDEFINED) { CfOut(cf_error,""," !! Multiple \"%s\" (group/gid) constraints break this promise\n",lval); PromiseRef(cf_error,pp); } } else { continue; } if (cp->type != CF_SCALAR) { CfOut(cf_error,"","Anomalous type mismatch - expected type for group constraint %s did not match internals\n",lval); PromiseRef(cf_error,pp); FatalError("Aborted"); } retval = Str2Gid((char *)cp->rval,buffer,pp); } } return retval; } #endif /* NOT MINGW */ /*****************************************************************************/ struct Rlist *GetListConstraint(char *lval,struct Promise *pp) { struct Constraint *cp; struct Rlist *retval = NULL; for (cp = pp->conlist; cp != NULL; cp=cp->next) { if (strcmp(cp->lval,lval) == 0) { if (IsDefinedClass(cp->classes)) { if (retval != NULL) { CfOut(cf_error,""," !! Multiple \"%s\" int constraints break this promise\n",lval); PromiseRef(cf_error,pp); } } else { continue; } if (cp->type != CF_LIST) { CfOut(cf_error,""," !! Type mismatch on rhs - expected type for list constraint \"%s\" \n",lval); PromiseRef(cf_error,pp); FatalError("Aborted"); } retval = (struct Rlist *)cp->rval; } } return retval; } /*****************************************************************************/ void *GetConstraint(char *lval,struct Promise *pp,char rtype) { struct Constraint *cp; void *retval = NULL; if (pp == NULL) { return NULL; } if (!VerifyConstraintName(lval)) { CfOut(cf_error,""," !! Self-diagnostic: Constraint type \"%s\" is not a registered type\n",lval); } for (cp = pp->conlist; cp != NULL; cp=cp->next) { if (strcmp(cp->lval,lval) == 0) { if (IsDefinedClass(cp->classes)) { if (retval != NULL) { CfOut(cf_error,""," !! Inconsistent \"%s\" constraints break this promise\n",lval); PromiseRef(cf_error,pp); } retval = cp->rval; if (cp->type != rtype) { return NULL; } } } } return retval; } /*****************************************************************************/ void ReCheckAllConstraints(struct Promise *pp) { struct Constraint *cp; char *sp,*handle = GetConstraint("handle",pp,CF_SCALAR); struct PromiseIdent *prid; struct Item *ptr; int in_class_any = false; if (strcmp(pp->agentsubtype,"reports") == 0 && strcmp(pp->classes,"any") == 0) { char *cl = GetConstraint("ifvarclass",pp,CF_SCALAR); if (cl == NULL || strcmp(cl,"any") == 0) { in_class_any = true; } if (in_class_any) { CfOut(cf_error,"","reports promises may not be in class \'any\' - risk of a notification explosion"); PromiseRef(cf_error,pp); } } /* Special promise type checks */ if (SHOWREPORTS) { NewPromiser(pp); } if (!IsDefinedClass(pp->classes)) { return; } if (VarClassExcluded(pp,&sp)) { return; } if (handle) { if (!ThreadLock(cft_policy)) { CfOut(cf_error, "", "!! Could not lock cft_policy in ReCheckAllConstraints() -- aborting"); return; } if ((prid = PromiseIdExists(handle))) { if ((strcmp(prid->filename,pp->audit->filename) != 0) || (prid->lineno != pp->lineno)) { CfOut(cf_error,""," !! Duplicate promise handle -- previously used in file %s near line %d",prid->filename,prid->lineno); PromiseRef(cf_error,pp); } } else { NewPromiseId(handle,pp); } prid = NULL; // we can't access this after unlocking ThreadUnlock(cft_policy); } if (REQUIRE_COMMENTS == true) { if (pp->ref == NULL && strcmp(pp->agentsubtype,"vars") != 0) { CfOut(cf_error,""," !! Un-commented promise found, but comments have been required by policy\n"); PromiseRef(cf_error,pp); } } for (cp = pp->conlist; cp != NULL; cp = cp->next) { PostCheckConstraint(pp->agentsubtype,pp->bundle,cp->lval,cp->rval,cp->type); } if (strcmp(pp->agentsubtype,"insert_lines") == 0) { /* Multiple additions with same criterion will not be convergent -- but ignore for empty file baseline */ if ((sp = GetConstraint("select_line_matching",pp,CF_SCALAR))) { if ((ptr = ReturnItemIn(EDIT_ANCHORS,sp))) { if (strcmp(ptr->classes,pp->bundle) == 0) { CfOut(cf_inform,""," !! insert_lines promise uses the same select_line_matching anchor (\"%s\") as another promise. This will lead to non-convergent behaviour unless \"empty_file_before_editing\" is set.",sp); PromiseRef(cf_inform,pp); } } else { PrependItem(&EDIT_ANCHORS,sp,pp->bundle); } } } PreSanitizePromise(pp); } /*****************************************************************************/ static void PostCheckConstraint(char *type,char *bundle,char *lval,void *rval,char rvaltype) { struct SubTypeSyntax ss; int i,j,l,m; struct BodySyntax *bs,*bs2; struct SubTypeSyntax *ssp; Debug(" Post Check Constraint %s: %s =>",type,lval); if (DEBUG) { ShowRval(stdout,rval,rvaltype); printf("\n"); } // Check class for (i = 0; CF_CLASSBODY[i].lval != NULL; i++) { if (strcmp(lval,CF_CLASSBODY[i].lval) == 0) { CheckConstraintTypeMatch(lval,rval,rvaltype,CF_CLASSBODY[i].dtype,CF_CLASSBODY[i].range,0); } } for (i = 0; i < CF3_MODULES; i++) { if ((ssp = CF_ALL_SUBTYPES[i]) == NULL) { continue; } for (j = 0; ssp[j].btype != NULL; j++) { ss = ssp[j]; if (ss.subtype != NULL) { if (strcmp(ss.subtype,type) == 0) { bs = ss.bs; for (l = 0; bs[l].lval != NULL; l++) { if (bs[l].dtype == cf_bundle) { } else if (bs[l].dtype == cf_body) { bs2 = (struct BodySyntax *)bs[l].range; for (m = 0; bs2[m].lval != NULL; m++) { if (strcmp(lval,bs2[m].lval) == 0) { CheckConstraintTypeMatch(lval,rval,rvaltype,bs2[m].dtype,(char *)(bs2[m].range),0); return; } } } if (strcmp(lval,bs[l].lval) == 0) { CheckConstraintTypeMatch(lval,rval,rvaltype,bs[l].dtype,(char *)(bs[l].range),0); return; } } } } } } /* Now check the functional modules - extra level of indirection */ for (i = 0; CF_COMMON_BODIES[i].lval != NULL; i++) { if (CF_COMMON_BODIES[i].dtype == cf_body) { continue; } if (strcmp(lval,CF_COMMON_BODIES[i].lval) == 0) { Debug("Found a match for lval %s in the common constraint attributes\n",lval); CheckConstraintTypeMatch(lval,rval,rvaltype,CF_COMMON_BODIES[i].dtype,(char *)(CF_COMMON_BODIES[i].range),0); return; } } } /*****************************************************************************/ static int VerifyConstraintName(char *lval) { struct SubTypeSyntax ss; int i,j,l,m; struct BodySyntax *bs,*bs2; struct SubTypeSyntax *ssp; Debug(" Verify Constrant name %s\n",lval); for (i = 0; i < CF3_MODULES; i++) { if ((ssp = CF_ALL_SUBTYPES[i]) == NULL) { continue; } for (j = 0; ssp[j].btype != NULL; j++) { ss = ssp[j]; if (ss.subtype != NULL) { bs = ss.bs; for (l = 0; bs[l].lval != NULL; l++) { if (bs[l].dtype == cf_bundle) { } else if (bs[l].dtype == cf_body) { bs2 = (struct BodySyntax *)bs[l].range; for (m = 0; bs2[m].lval != NULL; m++) { if (strcmp(lval,bs2[m].lval) == 0) { return true; } } } if (strcmp(lval,bs[l].lval) == 0) { return true; } } } } } /* Now check the functional modules - extra level of indirection */ for (i = 0; CF_COMMON_BODIES[i].lval != NULL; i++) { if (strcmp(lval,CF_COMMON_BODIES[i].lval) == 0) { return true; } } return false; } /*****************************************************************************/ /* Level */ /*****************************************************************************/ // NOTE: PROMISE_ID_LIST must be thread-safe here (locked by caller) struct PromiseIdent *NewPromiseId(char *handle,struct Promise *pp) { struct PromiseIdent *ptr; AssertThreadLocked(cft_policy,"NewPromiseId"); if ((ptr = malloc(sizeof(struct PromiseIdent))) == NULL) { FatalError("MemoryAlloc NewPromiseId\n"); } ptr->filename = strdup(pp->audit->filename); ptr->lineno = pp->lineno; ptr->handle = strdup(handle); ptr->next = PROMISE_ID_LIST; PROMISE_ID_LIST = ptr; return ptr; } /*****************************************************************************/ static void DeleteAllPromiseIdsRecurse(struct PromiseIdent *key) { AssertThreadLocked(cft_policy, "DeleteAllPromiseIdsRecurse"); if (key->next != NULL) { DeleteAllPromiseIdsRecurse(key->next); } free(key->filename); free(key->handle); free(key); } /*****************************************************************************/ void DeleteAllPromiseIds(void) { if (!ThreadLock(cft_policy)) { CfOut(cf_error, "", "!! Could not lock cft_policy in DelteAllPromiseIds() -- aborting"); return; } if (PROMISE_ID_LIST) { DeleteAllPromiseIdsRecurse(PROMISE_ID_LIST); PROMISE_ID_LIST = NULL; } ThreadUnlock(cft_policy); } /*****************************************************************************/ static struct PromiseIdent *PromiseIdExists(char *handle) { struct PromiseIdent *key; AssertThreadLocked(cft_policy, "PromiseIdExists"); for (key = PROMISE_ID_LIST; key != NULL; key=key->next) { if (strcmp(handle,key->handle) == 0) { return key; } } return NULL; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/expand.c�������������������������������������������������������������������������0000644�0001750�0001750�00000103554�11715232734�012446� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*********************************************************************/ /* */ /* Variable expansion in cf3 */ /* */ /*********************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void ConvergePromiseValues(struct Promise *pp); static void ScanScalar(char *scope,struct Rlist **los,struct Rlist **lol,char *string,int level,struct Promise *pp); static int ExpandPrivateScalar(const char *contextid, const char *string, char buffer[CF_EXPANDSIZE]); static int Epimenides(char *var,char *rval,char rtype,int level); /* Expanding variables is easy -- expanding lists automagically requires some thought. Remember that promiser <=> CF_SCALAR promisee <=> CF_LIST Expanding all bodies in the constraint list, we have lval <=> CF_LIST|CF_SCALAR Now the rule for variable substitution is that any list variable @(name) substituted directly for a LIST is not iterated, but dropped into place, i.e. in list-lvals and the promisee (since this would be equivalent to a re-concatenation of the expanded separate promises) Any list variable occuring within a scalar or in place of a scalar is assumed to be iterated i.e. $(name). To expand a promise, we build temporary hash tables. There are two stages, to this - one is to create a promise copy including all of the body templates and translate the parameters. This requires one round of expansion with scopeid "body". Then we use this fully assembled promise and expand vars and function calls. To expand the variables in a promise we need to -- first get all strings, also parameterized bodies, which could also be lists / // ScanRval("scope",&lol,"ksajd$(one)$(two)...$(three)"); \/ -- compile an ordered list of variables involved , with types - / assume all are lists - these are never inside sub-bodies by design, \/ so all expansion data are in the promise itself can also be variables based on list items - derived like arrays x[i] -- Copy the promise to a temporary promise + constraint list, expanding one by one, / then execute that \/ -- In a sub-bundle, create a new context and make hashes of the the transferred variables in the temporary context -- bodies cannot contain iterators -- we've already checked types of lhs rhs, must match so an iterator can only be in a non-naked variable? -- form the outer loops to generate combinations Note, we map the current context into a fluid context "this" that maps every list into a scalar during iteration. Thus "this" never contains lists. This presents a problem for absolute references like $(abs.var), since these cannot be mapped into "this" without some magic. **********************************************************************/ void ExpandPromise(enum cfagenttype agent,char *scopeid,struct Promise *pp,void *fnptr) { struct Rlist *listvars = NULL, *scalarvars = NULL; struct Constraint *cp; struct Promise *pcopy; Debug("****************************************************\n"); Debug("* ExpandPromises (scope = %s )\n",scopeid); Debug("****************************************************\n\n"); DeleteScope("match"); /* in case we expand something expired accidentially */ THIS_BUNDLE = scopeid; pcopy = DeRefCopyPromise(scopeid,pp); ScanRval(scopeid,&scalarvars,&listvars,pcopy->promiser,CF_SCALAR,pp); if (pcopy->promisee != NULL) { ScanRval(scopeid,&scalarvars,&listvars,pp->promisee,pp->petype,pp); } for (cp = pcopy->conlist; cp != NULL; cp=cp->next) { ScanRval(scopeid,&scalarvars,&listvars,cp->rval,cp->type,pp); } PushThisScope(); ExpandPromiseAndDo(agent,scopeid,pcopy,scalarvars,listvars,fnptr); PopThisScope(); DeletePromise(pcopy); DeleteRlist(scalarvars); DeleteRlist(listvars); } /*********************************************************************/ struct Rval ExpandDanglers(char *scopeid,struct Rval rval,struct Promise *pp) { struct Rval final; /* If there is still work left to do, expand and replace alloc */ switch (rval.rtype) { case CF_SCALAR: if (IsCf3VarString(rval.item)) { final = EvaluateFinalRval(scopeid,rval.item,rval.rtype,false,pp); } else { final.item = CopyRvalItem(rval.item,rval.rtype); final.rtype = rval.rtype; } break; default: final.item = CopyRvalItem(rval.item,rval.rtype); final.rtype = rval.rtype; break; } return final; } /*********************************************************************/ void ScanRval(char *scopeid,struct Rlist **scalarvars,struct Rlist **listvars,void *rval,char type,struct Promise *pp) { struct Rlist *rp; struct FnCall *fp; if (rval == NULL) { return; } switch(type) { case CF_SCALAR: ScanScalar(scopeid,scalarvars,listvars,(char *)rval,0,pp); break; case CF_LIST: for (rp = (struct Rlist *)rval; rp != NULL; rp=rp->next) { ScanRval(scopeid,scalarvars,listvars,rp->item,rp->type,pp); } break; case CF_FNCALL: fp = (struct FnCall *)rval; for (rp = (struct Rlist *)fp->args; rp != NULL; rp=rp->next) { Debug("Looking at arg for function-like object %s()\n",fp->name); ScanRval(scopeid,scalarvars,listvars,(char *)rp->item,rp->type,pp); } break; default: Debug("Unknown Rval type for scope %s",scopeid); break; } } /*********************************************************************/ static void ScanScalar(char *scopeid,struct Rlist **scal,struct Rlist **its,char *string,int level,struct Promise *pp) { char *sp,rtype; void *rval; char v[CF_BUFSIZE],var[CF_EXPANDSIZE],exp[CF_EXPANDSIZE],temp[CF_BUFSIZE]; Debug("ScanScalar(\"%s\")\n",string); if (string == NULL) { return; } for (sp = string; (*sp != '\0') ; sp++) { v[0] = '\0'; var[0] = '\0'; exp[0] = '\0'; if (*sp == '$') { if (ExtractInnerCf3VarString(sp,v)) { char absscope[CF_MAXVARSIZE]; if (IsQualifiedVariable(v)) { strncpy(temp,var,CF_BUFSIZE-1); absscope[0] = '\0'; sscanf(temp,"%[^.].%s",absscope,v); } else { strncpy(absscope,scopeid,CF_MAXVARSIZE-1); } ExpandPrivateScalar(absscope,v,var); RegisterBundleDependence(absscope,pp); if (GetVariable(absscope,var,&rval,&rtype) != cf_notype) { if (rtype == CF_LIST) { ExpandScalar(var,exp); /* embedded iterators should be incremented fastest, so order list -- and MUST return de-scoped name else list expansion cannot map var to this.name */ if (level > 0) { IdempPrependRScalar(its,exp,CF_SCALAR); } else { IdempAppendRScalar(its,exp,CF_SCALAR); } } else if (rtype == CF_SCALAR) { Debug("Scalar variable $(%s) found\n",var); IdempAppendRScalar(scal,var,CF_SCALAR); } } else { Debug("Checking for nested vars, e.g. $(array[$(index)])....\n"); if (IsExpandable(var)) { Debug("Found embedded variables\n"); ScanScalar(scopeid,scal,its,var,level+1,pp); } } sp += strlen(var)-1; } } } } /*********************************************************************/ int ExpandScalar(const char *string,char buffer[CF_EXPANDSIZE]) { Debug("ExpandScalar(context=%s,id=%s)\n",CONTEXTID,string); return ExpandPrivateScalar(CONTEXTID,string,buffer); } /*********************************************************************/ int ExpandThis(enum cfreport level,char *string,char buffer[CF_EXPANDSIZE]) { if (level == cf_error || ((strstr(string,"$(this.") == 0) && (strstr(string,"${this.") == 0))) { strncpy(buffer,string,CF_EXPANDSIZE-1); return true; } return ExpandPrivateScalar(CONTEXTID,string,buffer); } /*********************************************************************/ struct Rlist *ExpandList(char *scopeid,struct Rlist *list,int expandnaked) { struct Rlist *rp, *start = NULL; struct Rval returnval; char naked[CF_MAXVARSIZE]; for (rp = (struct Rlist *)list; rp != NULL; rp=rp->next) { if (!expandnaked && (rp->type == CF_SCALAR) && IsNakedVar(rp->item,'@')) { returnval.item = strdup(rp->item); returnval.rtype = CF_SCALAR; } else if ((rp->type == CF_SCALAR) && IsNakedVar(rp->item,'@')) { GetNaked(naked,rp->item); if (GetVariable(scopeid,naked,&(returnval.item),&(returnval.rtype)) != cf_notype) { returnval = ExpandPrivateRval(scopeid,returnval.item,returnval.rtype); } else { returnval = ExpandPrivateRval(scopeid,rp->item,rp->type); } } else { returnval = ExpandPrivateRval(scopeid,rp->item,rp->type); } AppendRlist(&start,returnval.item,returnval.rtype); DeleteRvalItem(returnval.item,returnval.rtype); } return start; } /*********************************************************************/ struct Rval ExpandPrivateRval(char *scopeid,void *rval,char type) { char buffer[CF_EXPANDSIZE]; struct FnCall *fp,*fpe; struct Rval returnval; Debug("ExpandPrivateRval(scope=%s,type=%c)\n",scopeid,type); /* Allocates new memory for the copy */ returnval.item = NULL; returnval.rtype = CF_NOPROMISEE; switch (type) { case CF_SCALAR: ExpandPrivateScalar(scopeid,(char *)rval,buffer); returnval.item = strdup(buffer); returnval.rtype = CF_SCALAR; break; case CF_LIST: returnval.item = ExpandList(scopeid,rval,true); returnval.rtype = CF_LIST; break; case CF_FNCALL: /* Note expand function does not mean evaluate function, must preserve type */ fp = (struct FnCall *)rval; fpe = ExpandFnCall(scopeid,fp,true); returnval.item = fpe; returnval.rtype = CF_FNCALL; break; } return returnval; } /*********************************************************************/ struct Rval ExpandBundleReference(char *scopeid,void *rval,char type) { char buffer[CF_EXPANDSIZE]; struct FnCall *fp,*fpe; struct Rval returnval; Debug("ExpandBundleReference(scope=%s,type=%c)\n",scopeid,type); /* Allocates new memory for the copy */ returnval.item = NULL; returnval.rtype = CF_NOPROMISEE; switch (type) { case CF_SCALAR: ExpandPrivateScalar(scopeid,(char *)rval,buffer); returnval.item = strdup(buffer); returnval.rtype = CF_SCALAR; break; case CF_FNCALL: /* Note expand function does not mean evaluate function, must preserve type */ fp = (struct FnCall *)rval; fpe = ExpandFnCall(scopeid,fp,false); returnval.item = fpe; returnval.rtype = CF_FNCALL; break; } return returnval; } /*********************************************************************/ static int ExpandOverflow(char *str1,char *str2) { int len = strlen(str2); if ((strlen(str1)+len) > (CF_EXPANDSIZE - CF_BUFFERMARGIN)) { CfOut(cf_error,"","Expansion overflow constructing string. Increase CF_EXPANDSIZE macro. Tried to add %s to %s\n",str2,str1); return true; } return false; } /*********************************************************************/ static int ExpandPrivateScalar(const char *scopeid, const char *string,char buffer[CF_EXPANDSIZE]) { char rtype; const char *sp; void *rval; int varstring = false; char currentitem[CF_EXPANDSIZE],temp[CF_BUFSIZE],name[CF_MAXVARSIZE]; int increment, returnval = true; memset(buffer,0,CF_EXPANDSIZE); if (string == 0 || strlen(string) == 0) { return false; } Debug("\nExpandPrivateScalar(%s,%s)\n",scopeid,string); for (sp = string; /* No exit */ ; sp++) /* check for varitems */ { char var[CF_BUFSIZE]; memset(var,0,CF_BUFSIZE); increment = 0; if (*sp == '\0') { break; } memset(currentitem,0,CF_EXPANDSIZE); sscanf(sp,"%[^$]",currentitem); if (ExpandOverflow(buffer,currentitem)) { FatalError("Can't expand varstring"); } strcat(buffer,currentitem); sp += strlen(currentitem); Debug(" Aggregate result |%s|, scanning at \"%s\" (current delta %s)\n",buffer,sp,currentitem); if (*sp == '\0') { break; } if (*sp == '$') { switch (*(sp+1)) { case '(': ExtractOuterCf3VarString(sp,var); varstring = ')'; if (strlen(var) == 0) { strcat(buffer,"$"); continue; } break; case '{': ExtractOuterCf3VarString(sp,var); varstring = '}'; if (strlen(var) == 0) { strcat(buffer,"$"); continue; } break; default: strcat(buffer,"$"); continue; } } memset(currentitem,0,CF_EXPANDSIZE); temp[0] = '\0'; ExtractInnerCf3VarString(sp,temp); if (IsCf3VarString(temp)) { Debug(" Nested variables - %s\n",temp); ExpandPrivateScalar(scopeid,temp,currentitem); } else { Debug(" Delta - %s\n",temp); strncpy(currentitem,temp,CF_BUFSIZE-1); } increment = strlen(var) - 1; switch (GetVariable(scopeid,currentitem,&rval,&rtype)) { case cf_str: case cf_int: case cf_real: if (ExpandOverflow(buffer,(char*)rval)) { FatalError("Can't expand varstring"); } strcat(buffer,(char *)rval); break; case cf_slist: case cf_ilist: case cf_rlist: case cf_notype: Debug(" Currently non existent or list variable $(%s)\n",currentitem); if (varstring == '}') { snprintf(name,CF_MAXVARSIZE,"${%s}",currentitem); } else { snprintf(name,CF_MAXVARSIZE,"$(%s)",currentitem); } strcat(buffer,name); returnval = false; break; default: Debug("Returning Unknown Scalar (%s => %s)\n\n",string,buffer); return false; } sp += increment; currentitem[0] = '\0'; } if (returnval) { Debug("Returning complete scalar expansion (%s => %s)\n\n",string,buffer); /* Can we be sure this is complete? What about recursion */ } else { Debug("Returning partial / best effort scalar expansion (%s => %s)\n\n",string,buffer); } return returnval; } /*********************************************************************/ void ExpandPromiseAndDo(enum cfagenttype agent,char *scopeid,struct Promise *pp,struct Rlist *scalarvars,struct Rlist *listvars,void (*fnptr)()) { struct Rlist *lol = NULL; struct Promise *pexp; const int cf_null_cutoff = 5; char *handle = GetConstraint("handle",pp,CF_SCALAR),v[CF_MAXVARSIZE]; int cutoff = 0; lol = NewIterationContext(scopeid,listvars); if (lol && EndOfIteration(lol)) { DeleteIterationContext(lol); return; } while (NullIterators(lol)) { IncrementIterationContext(lol,1); // In case a list is completely blank if (cutoff++ > cf_null_cutoff) { break; } } if (lol && EndOfIteration(lol)) { DeleteIterationContext(lol); return; } do { char number[CF_SMALLBUF]; /* Set scope "this" first to ensure list expansion ! */ SetScope("this"); DeRefListsInHashtable("this",listvars,lol); /* Allow $(this.handle) etc variables */ if (handle) { NewScalar("this","handle",handle,cf_str); } else { NewScalar("this","handle",PromiseID(pp),cf_str); } if (pp->audit && pp->audit->filename) { NewScalar("this","promise_filename",pp->audit->filename,cf_str); snprintf(number,CF_SMALLBUF,"%d",pp->lineno); NewScalar("this","promise_linenumber",number,cf_str); } snprintf(v,CF_MAXVARSIZE,"%d",(int)getuid()); NewScalar("this","promiser_uid",v,cf_int); snprintf(v,CF_MAXVARSIZE,"%d",(int)getgid()); NewScalar("this","promiser_gid",v,cf_int); /* End special variables */ pexp = ExpandDeRefPromise("this",pp); switch (agent) { case cf_common: ShowPromise(pexp,6); ReCheckAllConstraints(pexp); break; default: if (fnptr != NULL) { (*fnptr)(pexp); } break; } if (strcmp(pp->agentsubtype,"vars") == 0) { ConvergeVarHashPromise(pp->bundle,pexp,true); } DeletePromise(pexp); /* End thread monitor */ } while (IncrementIterationContext(lol,1)); DeleteIterationContext(lol); } /*********************************************************************/ struct Rval EvaluateFinalRval(char *scopeid,void *rval,char rtype,int forcelist,struct Promise *pp) { struct Rlist *rp; struct Rval returnval,newret; char naked[CF_MAXVARSIZE]; struct FnCall *fp; Debug("EvaluateFinalRval -- type %c\n",rtype); if ((rtype == CF_SCALAR) && IsNakedVar(rval,'@')) /* Treat lists specially here */ { GetNaked(naked,rval); if (GetVariable(scopeid,naked,&(returnval.item),&(returnval.rtype)) == cf_notype || returnval.rtype != CF_LIST) { returnval = ExpandPrivateRval("this",rval,rtype); } else { returnval.item = ExpandList(scopeid,returnval.item,true); returnval.rtype = CF_LIST; } } else { if (forcelist) /* We are replacing scalar @(name) with list */ { returnval = ExpandPrivateRval(scopeid,rval,rtype); } else { if (IsBuiltinFnCall(rval,rtype)) { returnval.item = CopyRvalItem(rval,rtype); returnval.rtype = rtype; } else { returnval = ExpandPrivateRval("this",rval,rtype); } } } switch (returnval.rtype) { case CF_SCALAR: break; case CF_LIST: for (rp = (struct Rlist *)returnval.item; rp != NULL; rp=rp->next) { if (rp->type == CF_FNCALL) { fp = (struct FnCall *)rp->item; newret = EvaluateFunctionCall(fp,pp); DeleteFnCall(fp); rp->item = newret.item; rp->type = newret.rtype; Debug("Replacing function call with new type (%c)\n",rp->type); } else { struct Scope *ptr = GetScope("this"); if (ptr != NULL) { if (IsCf3VarString(rp->item)) { newret = ExpandPrivateRval("this",rp->item,rp->type); free(rp->item); rp->item = newret.item; } } } /* returnval unchanged */ } break; case CF_FNCALL: // Also have to eval function now fp = (struct FnCall *)returnval.item; returnval = EvaluateFunctionCall(fp,pp); DeleteFnCall(fp); break; default: returnval.item = NULL; returnval.rtype = CF_NOPROMISEE; break; } return returnval; } /*********************************************************************/ /* Tools */ /*********************************************************************/ int IsExpandable(const char *str) { const char *sp; char left = 'x', right = 'x'; int dollar = false; int bracks = 0, vars = 0; Debug1("IsExpandable(%s) - syntax verify\n",str); for (sp = str; *sp != '\0' ; sp++) /* check for varitems */ { switch (*sp) { case '$': if (*(sp+1) == '{' || *(sp+1) == '(') { dollar = true; } break; case '(': case '{': if (dollar) { left = *sp; bracks++; } break; case ')': case '}': if (dollar) { bracks--; right = *sp; } break; } if (left == '(' && right == ')' && dollar && (bracks == 0)) { vars++; dollar=false; } if (left == '{' && right == '}' && dollar && (bracks == 0)) { vars++; dollar = false; } } if (bracks != 0) { Debug("If this is an expandable variable string then it contained syntax errors"); return false; } Debug("Found %d variables in (%s)\n",vars,str); return vars; } /*********************************************************************/ int IsNakedVar(char *str, char vtype) { char *sp,last; int count=0; if (str == NULL || strlen(str) == 0) { return false; } last = *(str+strlen(str)-1); if (strlen(str) < 3) { return false; } if (*str != vtype) { return false; } switch (*(str+1)) { case '(': if (last != ')') { return false; } break; case '{': if (last != '}') { return false; } break; default: return false; break; } for (sp = str; *sp != '\0'; sp++) { switch (*sp) { case '(': case '{': case '[': count++; break; case ')': case '}': case ']': count--; /* The last character must be the end of the variable */ if (count == 0 && strlen(sp) > 1) { return false; } break; } } if (count != 0) { return false; } Debug("IsNakedVar(%s,%c)!!\n",str,vtype); return true; } /*********************************************************************/ void GetNaked(char *s2, char *s1) /* copy @(listname) -> listname */ { if (strlen(s1) < 4) { CfOut(cf_error,"","Naked variable expected, but \"%s\" is malformed",s1); strncpy(s2,s1,CF_MAXVARSIZE-1); return; } memset(s2,0,CF_MAXVARSIZE); strncpy(s2,s1+2,strlen(s1)-3); } /*********************************************************************/ /* General */ /*********************************************************************/ void ConvergeVarHashPromise(char *scope,struct Promise *pp,int allow_redefine) { struct Constraint *cp,*cp_save = NULL; struct Attributes a = {{0}}; char rtype,type = 'x'; void *rval = NULL,*retval; int i = 0,ok_redefine = false,drop_undefined = false; struct Rval returnval; /* Must expand naked functions here for consistency */ struct Rlist *rp; if (pp->done) { return; } if (IsExcluded(pp->classes)) { return; } for (cp = pp->conlist; cp != NULL; cp=cp->next) { if (strcmp(cp->lval,"comment") == 0) { continue; } if (cp->rval == NULL) { continue; } if (strcmp(cp->lval,"ifvarclass") == 0) { struct Rval res; switch(cp->type) { case CF_SCALAR: if (IsExcluded(cp->rval)) { return; } break; case CF_FNCALL: /* eval it: e.g. ifvarclass => not("a_class") */ res = EvaluateFunctionCall(cp->rval,NULL); bool excluded = IsExcluded(res.item); DeleteRvalItem(res.item,res.rtype); if(excluded) { return; } break; default: CfOut(cf_error, "", "!! Invalid ifvarclass type '%c': should be string or function", cp->type); continue; } continue; } if (strcmp(cp->lval,"policy") == 0) { if (strcmp(cp->rval,"ifdefined") == 0) { drop_undefined = true; ok_redefine = false; } else if (strcmp(cp->rval,"constant") == 0) { ok_redefine = false; } else { ok_redefine = true; } } else if (strcmp(cp->lval,"string") == 0 || strcmp(cp->lval,"slist") == 0 || strcmp(cp->lval,"int") == 0 || strcmp(cp->lval,"ilist") == 0 || strcmp(cp->lval,"real") == 0 || strcmp(cp->lval,"rlist") == 0) { i++; rval = cp->rval; cp_save = cp; } } cp = cp_save; if (cp == NULL) { CfOut(cf_inform,"","Warning: Variable body for \"%s\" seems incomplete",pp->promiser); PromiseRef(cf_inform,pp); return; } if (i > 2) { CfOut(cf_error,"","Variable \"%s\" breaks its own promise with multiple values (code %d)",pp->promiser,i); PromiseRef(cf_error,pp); return; } //More consideration needs to be given to using these //a.transaction = GetTransactionConstraints(pp); a.classes = GetClassDefinitionConstraints(pp); if (rval != NULL) { struct FnCall *fp = (struct FnCall *)rval; if (cp->type == CF_FNCALL) { returnval = EvaluateFunctionCall(fp,pp); rval = returnval.item; type = returnval.rtype; if (FNCALL_STATUS.status == FNCALL_FAILURE) { /* We do not assign variables to failed fn calls */ DeleteRvalItem(rval,type); return; } } else { char conv[CF_MAXVARSIZE]; if (strcmp(cp->lval,"int") == 0) { snprintf(conv,CF_MAXVARSIZE,"%ld",Str2Int(cp->rval)); rval = CopyRvalItem(conv,cp->type); } else if (strcmp(cp->lval,"real") == 0) { snprintf(conv,CF_MAXVARSIZE,"%lf",Str2Double(cp->rval)); rval = CopyRvalItem(conv,cp->type); } else { rval = CopyRvalItem(cp->rval,cp->type); } type = cp->type; } if (Epimenides(pp->promiser,rval,type,0)) { CfOut(cf_error,"","Variable \"%s\" contains itself indirectly - an unkeepable promise",pp->promiser); exit(1); } else { /* See if the variable needs recursively expanding again */ returnval = EvaluateFinalRval(scope,rval,type,true,pp); DeleteRvalItem(rval,type); // freed before function exit rval = returnval.item; type = returnval.rtype; } if (GetVariable(scope,pp->promiser,(void *)&retval,&rtype) != cf_notype) { if (ok_redefine) /* only on second iteration, else we ignore broken promises */ { DeleteVariable(scope,pp->promiser); } else if ((THIS_AGENT_TYPE == cf_common) && (CompareRval(retval,rtype,rval,type) == false)) { switch (type) { char valbuf[CF_BUFSIZE]; case CF_SCALAR: CfOut(cf_verbose,""," !! Redefinition of a constant scalar \"%s\" (was %s now %s)",pp->promiser,retval,rval); PromiseRef(cf_verbose,pp); break; case CF_LIST: CfOut(cf_verbose,""," !! Redefinition of a constant list \"%s\".",pp->promiser); PrintRlist(valbuf, CF_BUFSIZE, retval); CfOut(cf_verbose,"","Old value: %s", valbuf); PrintRlist(valbuf, CF_BUFSIZE, rval); CfOut(cf_verbose,""," New value: %s", valbuf); PromiseRef(cf_verbose,pp); break; } } } if (IsCf3VarString(pp->promiser)) { // Unexpanded variables, we don't do anything with DeleteRvalItem(rval,type); return; } if (!FullTextMatch("[a-zA-Z0-9_\200-\377.]+(\\[.+\\])*",pp->promiser)) { CfOut(cf_error,""," !! Variable identifier contains illegal characters"); PromiseRef(cf_error,pp); DeleteRvalItem(rval,type); return; } if (drop_undefined && type == CF_LIST) { for (rp = rval; rp != NULL; rp=rp->next) { if (IsNakedVar(rp->item,'@')) { free(rp->item); rp->item = strdup(CF_NULL_VALUE); } } } if (!AddVariableHash(scope,pp->promiser,rval,type,Typename2Datatype(cp->lval),cp->audit->filename,cp->lineno)) { CfOut(cf_verbose,"","Unable to converge %s.%s value (possibly empty or infinite regression)\n",scope,pp->promiser); PromiseRef(cf_verbose,pp); cfPS(cf_noreport,CF_FAIL,"",pp,a," !! Couldn't add variable %s",pp->promiser); } else { cfPS(cf_noreport,CF_CHG,"",pp,a," -> Added variable %s",pp->promiser); } } else { CfOut(cf_error,""," !! Variable %s has no promised value\n",pp->promiser); CfOut(cf_error,""," !! Rule from %s at/before line %d\n",cp->audit->filename,cp->lineno); cfPS(cf_noreport,CF_FAIL,"",pp,a," !! Couldn't add variable %s",pp->promiser); } DeleteRvalItem(rval,type); } /*********************************************************************/ static void ConvergePromiseValues(struct Promise *pp) { struct Constraint *cp; struct Rlist *rp; char expandbuf[CF_EXPANDSIZE]; struct FnCall *fp; switch (pp->petype) { case CF_SCALAR: if (IsCf3VarString((char *)pp->promisee)) { ExpandScalar(pp->promisee,expandbuf); if (strcmp(pp->promisee,expandbuf) != 0) { free(pp->promisee); pp->promisee = strdup(expandbuf); } } break; case CF_LIST: for (rp = (struct Rlist *)pp->promisee; rp != NULL; rp=rp->next) { if (IsCf3VarString((char *)rp->item)) { ExpandScalar(rp->item,expandbuf); if (strcmp(rp->item,expandbuf) != 0) { free(rp->item); rp->item = strdup(expandbuf); } } } break; } for (cp = pp->conlist; cp != NULL; cp=cp->next) { switch (cp->type) { case CF_SCALAR: if (IsCf3VarString((char *)cp->rval)) { ExpandScalar(cp->rval,expandbuf); if (strcmp(cp->rval,expandbuf) != 0) { free(cp->rval); cp->rval = strdup(expandbuf); } } break; case CF_LIST: for (rp = (struct Rlist *)cp->rval; rp != NULL; rp=rp->next) { if (IsCf3VarString((char *)rp->item)) { ExpandScalar(rp->item,expandbuf); if (strcmp(rp->item,expandbuf) != 0) { free(rp->item); rp->item = strdup(expandbuf); } } } break; case CF_FNCALL: fp = (struct FnCall *)cp->rval; for (rp = fp->args; rp != NULL; rp=rp->next) { if (rp->type == CF_SCALAR && IsCf3VarString(rp->item)) { ExpandPrivateScalar(CONTEXTID,(char *)rp->item,expandbuf); free(rp->item); rp->item = strdup(expandbuf); } } break; } } } /*********************************************************************/ /* Levels */ /*********************************************************************/ static int Epimenides(char *var,char *rval,char rtype,int level) { struct Rlist *rp,*list; char exp[CF_EXPANDSIZE]; switch (rtype) { case CF_SCALAR: if (StringContainsVar(rval,var)) { CfOut(cf_error,"","Scalar variable \"%s\" contains itself (non-convergent): %s",var,(char *)rval); return true; } if (IsCf3VarString(rval)) { ExpandPrivateScalar(CONTEXTID,rval,exp); Debug("bling %d-%s: (look for %s) in \"%s\" => %s \n",level,CONTEXTID,var,rval,exp); if (level > 3) { return false; } if (Epimenides(var,exp,CF_SCALAR,level+1)) { return true; } } break; case CF_LIST: list = (struct Rlist *)rval; for (rp = list; rp != NULL; rp=rp->next) { if (Epimenides(var,rp->item,rp->type,level)) { return true; } } break; default: return false; } return false; } ����������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/selfdiagnostic.c�����������������������������������������������������������������0000644�0001750�0001750�00000061310�11715232734�014156� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: selfdiagnostic.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void TestRegularExpressions(void); static void TestAgentPromises(void); static void TestFunctionIntegrity(void); static void SDIntegerDefault(char *ref,int cmp); static void TestHashEntropy(char *s,char *s1); int NR = 0; /*****************************************************************************/ void SelfDiagnostic() { int s1,s2,i,j; if (VERBOSE || DEBUG) { FREPORT_TXT = stdout; FREPORT_HTML = fopen(NULLFILE,"w"); FKNOW = fopen(NULLFILE,"w"); } else { FREPORT_TXT= fopen(NULLFILE,"w"); FREPORT_HTML= fopen(NULLFILE,"w"); FKNOW = fopen(NULLFILE,"w"); } printf("----------------------------------------------------------\n"); printf("Cfengine - Level 1 self-diagnostic \n"); printf("----------------------------------------------------------\n\n"); SDIntegerDefault("editfilesize",EDITFILESIZE); SDIntegerDefault("editbinaryfilesize",EDITBINFILESIZE); printf(" -> Internal consistency done\n\n"); printf("----------------------------------------------------------\n"); printf("Cfengine - Level 2 self-diagnostic \n"); printf("----------------------------------------------------------\n\n"); TestVariableScan(); TestFunctionIntegrity(); TestExpandPromise(); TestExpandVariables(); TestRegularExpressions(); TestAgentPromises(); //#ifdef BUILD_TESTSUITE printf("7. Test expected non-local load balancing efficiency\n"); char *names = "company comparison competition complete omplex condition connection conscious control cook copper copy cord cork cotton cough country cover dead dear death debt decision deep degree delicate dependent design desire destruction detail development different digestion direction dirty discovery discussion disease disgust distance distribution division do og door end engine enough equal error even event ever every example exchange group growth guide gun hair hammer hand hanging happy harbour hard harmony hat hate have he head healthy hear hearing heart heat help high history hole hollow hook hope horn horse hospital hour house how humour I ice idea if ill important impulse in increase industry ink insect instrument insurance interest invention iron island jelly jewel join journey judge jump keep kettle key kick kind kiss knee knife knot knowledge land language last late laugh law lead leaf learning leather left leg let letter level library lift light like limit line linen lip liquid list little living lock long look loose loss loud love low machine make male man manager map mark market married mass match material may meal measure meat medical meeting memory metal middle military milk mind mine minute mist mixed money monkey month moon morning mother motion mountain mouth move much muscle music nail name narrow nation natural near necessary neck need needle nerve net new news night no noise normal north nose not note now number nut observation of off offer office oil old on only open operation opinion opposite or orange order organization ornament other out oven over owner page pain paint paper parallel parcel part past paste payment peace pen pencil person physical picture pig pin pipe place plane plant plate play please pleasure plough pocket point poison polish political poor porter position possible pot potato powder power present price print prison private probable process produce profit property prose protest public pull pump punishment purpose push put quality question quick quiet quite rail rain range rat rate ray reaction reading ready reason receipt record red regret regular relation religion representative request respect responsible rest reward rhythm rice right ring river road rod roll roof room root rough round rub rule run sad safe sail salt same sand say scale school science scissors screw sea seat second secret secretary see seed seem selection self send sense separate serious servant sex shade shake shame sharp sheep shelf ship shirt shock shoe short shut side sign silk silver simple sister size skin skirt sky sleep slip slope slow small smash smell smile smoke smooth snake sneeze snow so soap society sock soft solid some son song sort sound soup south space spade special sponge spoon spring square stage stamp star start statement station steam steel stem step stick sticky stiff still stitch stocking stomach stone stop store story straight strange street stretch strong structure substance such sudden sugar suggestion summer sun support surprise sweet swim system table tail take talk tall taste tax teaching tendency test than that the then theory there thick thin thing this thought thread throat through through thumb thunder ticket tight till time tin tired to toe together tomorrow tongue tooth top touch town trade train transport tray tree trick trouble trousers true turn twist umbrella under unit up use value verse very vessel view violent voice waiting walk wall war warm wash waste watch water wave wax way weather week weight well west "; char *numbers = "128.23.67.1 128.23.67.2 128.23.67.3 128.23.67.4 128.23.67.5 128.23.67.6 128.23.67.7 128.23.67.8 128.23.67.9 128.23.67.11 128.23.67.21 128.23.67.31 128.23.67.41 128.23.67.51 128.23.67.61 128.23.67.71 128.23.67.81 128.23.67.91 128.23.67.21 128.23.67.22 128.23.67.23 128.23.67.24 128.23.67.25 128.23.67.26 128.23.67.27 128.23.67.28 128.23.67.29 128.23.67.31 128.23.67.32 128.23.67.33 128.23.67.34 128.23.67.35 128.23.67.36 128.23.67.37 128.23.67.38 128.23.67.39 128.23.67.41 128.23.67.42 128.23.67.43 128.23.67.44 128.23.67.45 128.23.67.46 128.23.67.47 128.23.67.48 128.23.67.49 128.23.67.51 128.23.67.52 128.23.67.53 128.23.67.54 128.23.67.55 128.23.67.56 128.23.67.57 128.23.67.58 128.23.67.59 128.23.67.61 128.23.67.62 128.23.67.63 128.23.67.64 128.23.67.65 128.23.67.66 128.23.67.67 128.23.67.68 128.23.67.69 128.23.67.71 128.23.67.72 128.23.67.73 128.23.67.74 128.23.67.75 128.23.67.76 128.23.67.77 128.23.67.78 128.23.67.79 128.23.67.81 128.23.67.82 128.23.67.83 128.23.67.84 128.23.67.85 128.23.67.86 128.23.67.87 128.23.67.88 128.23.67.89 128.23.67.91 128.23.67.92 128.23.67.93 128.23.67.94 128.23.67.95 128.23.67.96 128.23.67.97 128.23.67.98 128.23.67.99 128.23.67.11 128.23.67.12 128.23.67.13 128.23.67.14 128.23.67.15 128.23.67.16 128.23.67.17 128.23.67.18 128.23.67.19 128.23.67.111 128.23.67.121 128.23.67.131 128.23.67.141 128.23.67.151 128.23.67.161 128.23.67.171 128.23.67.181 128.23.67.191 128.23.67.121 128.23.67.122 128.23.67.123 128.23.67.124 128.23.67.125 128.23.67.126 128.23.67.127 128.23.67.128 128.23.67.129 128.23.67.131 128.23.67.132 128.23.67.133 128.23.67.134 128.23.67.135 128.23.67.136 128.23.67.137 128.23.67.138 128.23.67.139 128.23.67.141 128.23.67.142 128.23.67.143 128.23.67.144 128.23.67.145 128.23.67.146 128.23.67.147 128.23.67.148 128.23.67.149 128.23.67.151 128.23.67.152 128.23.67.153 128.23.67.154 128.23.67.155 128.23.67.156 128.23.67.157 128.23.67.158 128.23.67.159 128.23.67.161 128.23.67.162 128.23.67.163 128.23.67.164 128.23.67.165 128.23.67.166 128.23.67.167 128.23.67.168 128.23.67.169 128.23.67.171 128.23.67.172 128.23.67.173 128.23.67.174 128.23.67.175 128.23.67.176 128.23.67.177 128.23.67.178 128.23.67.179 128.23.67.181 128.23.67.182 128.23.67.183 128.23.67.184 128.23.67.185 128.23.67.186 128.23.67.187 128.23.67.188 128.23.67.189 128.23.67.191 128.23.67.192 128.23.67.193 128.23.67.194 128.23.67.195 128.23.67.196 128.23.67.197 128.23.67.198 128.23.67.199 128.23.67.21 128.23.67.22 128.23.67.23 128.23.67.24 128.23.67.25 128.23.67.26 128.23.67.27 128.23.67.28 128.23.67.29 128.23.67.211 128.23.67.221 128.23.67.231 128.23.67.241 128.23.67.251 128.23.67.261 128.23.67.271 128.23.67.281 128.23.67.291 128.23.67.221 128.23.67.222 128.23.67.223 128.23.67.224 128.23.67.225 128.23.67.226 128.23.67.227 128.23.67.228 128.23.67.229 128.23.67.231 128.23.67.232 128.23.67.233 128.23.67.234 128.23.67.235 128.23.67.236 128.23.67.237 128.23.67.238 128.23.67.239 128.23.67.241 128.23.67.242 128.23.67.243 128.23.67.244 128.23.67.245 128.23.67.246 128.23.67.247 128.23.67.248 128.23.67.249 128.23.67.251 128.23.67.252 128.23.67.253 128.23.67.254 128.23.67.255 128.23.67.256 128.23.67.257 128.23.67.258 128.23.67.259 128.23.67.261 128.23.67.262 128.23.67.263 128.23.67.264 128.23.67.265 128.23.67.266 128.23.67.267 128.23.67.268 128.23.67.269 128.23.67.271 128.23.67.272 128.23.67.273 128.23.67.274 128.23.67.275 128.23.67.276 128.23.67.277 128.23.67.278 128.23.67.279 128.23.67.281 128.23.67.282 128.23.67.283 128.23.67.284 128.23.67.285 128.23.67.286 128.23.67.287 128.23.67.288 128.23.67.289 128.23.67.291 128.23.67.292 128.23.67.293 128.23.67.294 128.23.67.295 128.23.67.296 128.23.67.297 128.23.67.298 128.23.67.299 168.67.67.1 168.67.67.2 168.67.67.3 168.67.67.4 168.67.67.5 168.67.67.6 168.67.67.7 168.67.67.8 168.67.67.9 168.67.67.11 168.67.67.21 168.67.67.31 168.67.67.41 168.67.67.51 168.67.67.61 168.67.67.71 168.67.67.81 168.67.67.91 168.67.67.21 168.67.67.22 168.67.67.23 168.67.67.24 168.67.67.25 168.67.67.26 168.67.67.27 168.67.67.28 168.67.67.29 168.67.67.31 168.67.67.32 168.67.67.33 168.67.67.34 168.67.67.35 168.67.67.36 168.67.67.37 168.67.67.38 168.67.67.39 168.67.67.41 168.67.67.42 168.67.67.43 168.67.67.44 168.67.67.45 168.67.67.46 168.67.67.47 168.67.67.48 168.67.67.49 168.67.67.51 168.67.67.52 168.67.67.53 168.67.67.54 168.67.67.55 168.67.67.56 168.67.67.57 168.67.67.58 168.67.67.59 168.67.67.61 168.67.67.62 168.67.67.63 168.67.67.64 168.67.67.65 168.67.67.66 168.67.67.67 168.67.67.68 168.67.67.69 168.67.67.71 168.67.67.72 168.67.67.73 168.67.67.74 168.67.67.75 168.67.67.76 168.67.67.77 168.67.67.78 168.67.67.79 168.67.67.81 168.67.67.82 168.67.67.83 168.67.67.84 168.67.67.85 168.67.67.86 168.67.67.87 168.67.67.88 168.67.67.89 168.67.67.91 168.67.67.92 168.67.67.93 168.67.67.94 168.67.67.95 168.67.67.96 168.67.67.97 168.67.67.98 168.67.67.99 168.67.67.11 168.67.67.12 168.67.67.13 168.67.67.14 168.67.67.15 168.67.67.16 168.67.67.17 168.67.67.18 168.67.67.19 168.67.67.111 168.67.67.121 168.67.67.131 168.67.67.141 168.67.67.151 168.67.67.161 168.67.67.171 168.67.67.181 168.67.67.191 168.67.67.121 168.67.67.122 168.67.67.123 168.67.67.124 168.67.67.125 168.67.67.126 168.67.67.127 168.67.67.128 168.67.67.129 168.67.67.131 168.67.67.132 168.67.67.133 168.67.67.134 168.67.67.135 168.67.67.136 168.67.67.137 168.67.67.138 168.67.67.139 168.67.67.141 168.67.67.142 168.67.67.143 168.67.67.144 168.67.67.145 168.67.67.146 168.67.67.147 168.67.67.148 168.67.67.149 168.67.67.151 168.67.67.152 168.67.67.153 168.67.67.154 168.67.67.155 168.67.67.156 168.67.67.157 168.67.67.158 168.67.67.159 168.67.67.161 168.67.67.162 168.67.67.163 168.67.67.164 168.67.67.165 168.67.67.166 168.67.67.167 168.67.67.168 168.67.67.169 168.67.67.171 168.67.67.172 168.67.67.173 168.67.67.174 168.67.67.175 168.67.67.176 168.67.67.177 168.67.67.178 168.67.67.179 168.67.67.181 168.67.67.182 168.67.67.183 168.67.67.184 168.67.67.185 168.67.67.186 168.67.67.187 168.67.67.188 168.67.67.189 168.67.67.191 168.67.67.192 168.67.67.193 168.67.67.194 168.67.67.195 168.67.67.196 168.67.67.197 168.67.67.198 168.67.67.199 168.67.67.21 168.67.67.22 168.67.67.23 168.67.67.24 168.67.67.25 168.67.67.26 168.67.67.27 168.67.67.28 168.67.67.29 168.67.67.211 168.67.67.221 168.67.67.231 168.67.67.241 168.67.67.251 168.67.67.261 168.67.67.271 168.67.67.281 168.67.67.291 168.67.67.221 168.67.67.222 168.67.67.223 168.67.67.224 168.67.67.225 168.67.67.226 168.67.67.227 168.67.67.228 168.67.67.229 168.67.67.231 168.67.67.232 168.67.67.233 168.67.67.234 168.67.67.235 168.67.67.236 168.67.67.237 168.67.67.238 168.67.67.239 168.67.67.241 168.67.67.242 168.67.67.243 168.67.67.244 168.67.67.245 168.67.67.246 168.67.67.247 168.67.67.248 168.67.67.249 168.67.67.251 168.67.67.252 168.67.67.253 168.67.67.254 168.67.67.255 168.67.67.256 168.67.67.257 168.67.67.258 168.67.67.259 168.67.67.261 168.67.67.262 168.67.67.263 168.67.67.264 168.67.67.265 168.67.67.266 168.67.67.267 168.67.67.268 168.67.67.269 168.67.67.271 168.67.67.272 168.67.67.273 168.67.67.274 168.67.67.275 168.67.67.276 168.67.67.277 168.67.67.278 168.67.67.279 168.67.67.281 168.67.67.282 168.67.67.283 168.67.67.284 168.67.67.285 168.67.67.286 168.67.67.287 168.67.67.288 168.67.67.289 168.67.67.291 168.67.67.292 168.67.67.293 168.67.67.294 168.67.67.295 168.67.67.296 168.67.67.297 168.67.67.298 168.67.67.299"; char *pattern = malloc(2000000); TestHashEntropy(names,"names"); TestHashEntropy(numbers,"addresses"); memset(pattern,0,8*2000+4); for (i = 0, j= 0; i < 2000; i++) { sprintf(pattern+j,"serv_%d ",i); j += strlen(pattern+j); } TestHashEntropy(pattern,"pattern 1"); memset(pattern,0,8*2000+4); for (i = 0, j= 0; i < 2000; i++) { sprintf(pattern+j,"serv_%d.domain.tld ",i); j += strlen(pattern+j); } TestHashEntropy(pattern,"pattern 2"); //#endif } /*****************************************************************************/ void TestVariableScan() { int i; char *list_text1 = "$(administrator),a,b,c,d,e,f"; char *list_text2 = "1,2,3,4,@(one)"; struct Rlist *varlist1,*varlist2,*listoflists = NULL,*scalars = NULL; static char *varstrings[] = { "alpha $(one) beta $(two) gamma", "alpha $(five) beta $(none) gamma $(array[$(four)])", "alpha $(none) beta $(two) gamma", "alpha $(four) beta $(two) gamma $(array[$(diagnostic.three)])", NULL }; printf("%d. Test variable scanning\n",++NR); SetNewScope("diagnostic"); varlist1 = SplitStringAsRList(list_text1,','); varlist2 = SplitStringAsRList(list_text2,','); NewList("diagnostic","one",varlist1,cf_slist); NewScalar("diagnostic","two","secondary skills",cf_str); NewScalar("diagnostic","administrator","root",cf_str); NewList("diagnostic","three",varlist2,cf_slist); NewList("diagnostic","four",varlist2,cf_slist); NewList("diagnostic","five",varlist2,cf_slist); for (i = 0; varstrings[i] != NULL; i++) { if (VERBOSE || DEBUG) { printf("-----------------------------------------------------------\n"); printf("Scanning: [%s]\n",varstrings[i]); ScanRval("diagnostic",&scalars,&listoflists,varstrings[i],CF_SCALAR,NULL); printf("Cumulative scan produced:\n"); printf(" Scalar variables: "); ShowRlist(stdout,scalars); printf("\n"); printf(" Lists variables: "); ShowRlist(stdout,listoflists); printf("\n"); } } } /*****************************************************************************/ static void TestFunctionIntegrity() { int i,j; struct FnCallArg *args; printf("%d. Testing internal function templates and knowledge\n",++NR); for (i = 0; CF_FNCALL_TYPES[i].name != NULL; i++) { args = CF_FNCALL_TYPES[i].args; for (j = 0; args[j].pattern != NULL; j++) { CfOut(cf_verbose,""," -> .. arg %d %s = %s\n",j,args[j].pattern,args[j].description); } CfOut(cf_verbose,""," -> function %s (%d=%d args)\n",CF_FNCALL_TYPES[i].name,CF_FNCALL_TYPES[i].numargs,j); if (j != CF_FNCALL_TYPES[i].numargs) { printf(" !! Broken internal function declaration for \"%s\", prototype does not match declared number of args",CF_FNCALL_TYPES[i].name); } } } /*****************************************************************************/ void TestExpandPromise() { struct Promise pp = {0},*pcopy; printf("%d. Testing promise duplication and expansion\n",++NR); pp.promiser = "the originator"; pp.promisee = "the recipient"; pp.classes = "upper classes"; pp.petype = CF_SCALAR; pp.lineno = 12; pp.audit = NULL; pp.conlist = NULL; pp.bundletype = "bundle_type"; pp.bundle = "test_bundle"; pp.ref = "commentary"; pp.agentsubtype = NULL; pp.done = false; pp.next = NULL; pp.cache = NULL; pp.inode_cache = NULL; pp.this_server = NULL; pp.donep = &(pp.done); pp.conn = NULL; AppendConstraint(&(pp.conlist),"lval1",strdup("rval1"),CF_SCALAR,"lower classes1",false); AppendConstraint(&(pp.conlist),"lval2",strdup("rval2"),CF_SCALAR,"lower classes2",false); //getuid AppendConstraint(&(pp.conlist),"lval2",,CF_SCALAR,"lower classes2"); /* Now copy promise and delete */ pcopy = DeRefCopyPromise("diagnostic-scope",&pp); if (VERBOSE || DEBUG) { printf("-----------------------------------------------------------\n"); printf("Raw test promises\n\n"); ShowPromise(&pp,4); ShowPromise(pcopy,6); } DeletePromise(pcopy); } /*****************************************************************************/ void TestExpandVariables() { struct Promise pp = {0},*pcopy; struct Rlist *args, *listvars = NULL, *scalarvars = NULL; struct Constraint *cp; struct FnCall *fp; #ifdef MINGW if(NovaWin_GetProgDir(CFWORKDIR, CF_BUFSIZE - sizeof("Cfengine"))) { strcat(CFWORKDIR, "\\Cfengine"); } else { CfOut(cf_error, "", "!! Could not get CFWORKDIR from Windows environment variable, falling back to compile time dir (%s)", WORKDIR); strcpy(CFWORKDIR,WORKDIR); } Debug("Setting CFWORKDIR=%s\n", CFWORKDIR); #elif defined(CFCYG) strcpy(CFWORKDIR,WORKDIR); MapName(CFWORKDIR); #else if (getuid() > 0) { strncpy(CFWORKDIR,GetHome(getuid()),CF_BUFSIZE-10); strcat(CFWORKDIR,"/.cfagent"); if (strlen(CFWORKDIR) > CF_BUFSIZE/2) { FatalError("Suspicious looking home directory. The path is too long and will lead to problems."); } } else { strcpy(CFWORKDIR,WORKDIR); } #endif /* Still have diagnostic scope */ NewScope("control_common"); printf("%d. Testing variable expansion\n",++NR); pp.promiser = "the originator"; pp.promisee = "the recipient with $(two)"; pp.classes = "proletariat"; pp.petype = CF_SCALAR; pp.lineno = 12; pp.audit = NULL; pp.conlist = NULL; pp.agentsubtype = "none"; pp.bundletype = "bundle_type"; pp.bundle = "test_bundle"; pp.ref = "commentary"; pp.agentsubtype = strdup("files"); pp.done = false; pp.next = NULL; pp.cache = NULL; pp.inode_cache = NULL; pp.this_server = NULL; pp.donep = &(pp.done); pp.conn = NULL; args = SplitStringAsRList("$(administrator)",','); fp = NewFnCall("getuid",args); AppendConstraint(&(pp.conlist),"lval1",strdup("@(one)"),CF_SCALAR,"lower classes1",false); AppendConstraint(&(pp.conlist),"lval2",strdup("$(four)"),CF_SCALAR,"upper classes1",false); AppendConstraint(&(pp.conlist),"lval3",fp,CF_FNCALL,"upper classes2",false); /* Now copy promise and delete */ pcopy = DeRefCopyPromise("diagnostic",&pp); ScanRval("diagnostic",&scalarvars,&listvars,pcopy->promiser,CF_SCALAR,NULL); if (pcopy->promisee != NULL) { ScanRval("diagnostic",&scalarvars,&listvars,pp.promisee,pp.petype,NULL); } for (cp = pcopy->conlist; cp != NULL; cp=cp->next) { ScanRval("diagnostic",&scalarvars,&listvars,cp->rval,cp->type,NULL); } ExpandPromiseAndDo(cf_common,"diagnostic",pcopy,scalarvars,listvars,NULL); /* No cleanup */ } /*****************************************************************************/ static void TestRegularExpressions() { int start,end; printf("%d. Testing regular expression engine\n",++NR); if (FullTextMatch("[a-z]*","1234abcd6789")) { CfOut(cf_error,"","Failed regular expression match 1\n"); } else { CfOut(cf_verbose,""," -> FullTextMatch - ok 1\n"); } if (FullTextMatch("[1-4]*[a-z]*.*","1234abcd6789")) { CfOut(cf_error,""," -> FullTextMatch - ok 2\n"); } else { CfOut(cf_error,"","Failed regular expression match 2\n"); } if (BlockTextMatch("#.*","line 1:\nline2: # comment to end\nline 3: blablab",&start,&end)) { CfOut(cf_error,""," -> BlockTextMatch - ok\n"); if (start != 15) { CfOut(cf_error,"","Start was not at 15 -> %d\n",start); } if (end != 31) { CfOut(cf_error,"","Start was not at 31 -> %d\n",end); } } else { CfOut(cf_error,"","Failed regular expression match 3\n"); } if (BlockTextMatch("[a-z]+","1234abcd6789",&start,&end)) { CfOut(cf_error,""," -> BlockTextMatch - ok\n"); if (start != 4) { CfOut(cf_error,"","Start was not at 4 -> %d\n",start); } if (end != 8) { CfOut(cf_error,"","Start was not at 8 -> %d\n",end); } } else { CfOut(cf_error,"","Failed regular expression match 3\n"); } } /*****************************************************************************/ static void TestAgentPromises() { struct Attributes a = {{0}}; struct Promise pp = {0}; pp.conlist = NULL; pp.audit = NULL; printf("%d. Testing promise attribute completeness (with no desired intention)\n",++NR); a = GetFilesAttributes(&pp); a = GetReportsAttributes(&pp); a = GetExecAttributes(&pp); a = GetProcessAttributes(&pp); a = GetStorageAttributes(&pp); a = GetClassContextAttributes(&pp); a = GetTopicsAttributes(&pp); a = GetOccurrenceAttributes(&pp); GetMethodAttributes(&pp); GetInterfacesAttributes(&pp); GetInsertionAttributes(&pp); GetDeletionAttributes(&pp); GetColumnAttributes(&pp); GetReplaceAttributes(&pp); printf(" -> All non-listed items are accounted for\n"); } /*****************************************************************************/ static void SDIntegerDefault(char *ref,int cmp) { char *def; int intval; if ((def = GetControlDefault(ref))) { sscanf(def,"%d",&intval); if (intval != cmp) { printf(" !! Mismatch in default specs for \"%s\" (%d/%d)\n",ref,intval,cmp); } else { printf(" -> %s ok (%d/%d)\n",ref,intval,cmp); } } else { printf(" !! Missing default specs for \"%s\"\n",ref); } } /*****************************************************************************/ static void TestHashEntropy(char *names,char *title) {char word[32],*sp; int i,j,slot,eslot,sslot,hashtable[CF_HASHTABLESIZE],ehashtable[CF_HASHTABLESIZE],shashtable[CF_HASHTABLESIZE]; int freq[10], efreq[10],sfreq[10]; double tot = 0,etot = 0,stot = 0; for (i = 0; i < CF_HASHTABLESIZE; i++) { hashtable[i] = 0; ehashtable[i] = 0; shashtable[i] = 0; } printf(" -> Trial of \"%s\":\n",title); for (i = 0,sp = names; *sp != '\0'; sp += strlen(word)+1,i++) { struct timespec start,stop; word[0] = '\0'; sscanf(sp,"%s",word); if (word[0] == '\0') { break; } clock_gettime(CLOCK_REALTIME, &start); slot = RefHash(word); clock_gettime(CLOCK_REALTIME, &stop); tot += (double)(stop.tv_sec - start.tv_sec)+(double)(stop.tv_nsec-start.tv_nsec); clock_gettime(CLOCK_REALTIME, &start); eslot = ElfHash(word); clock_gettime(CLOCK_REALTIME, &stop); etot += (double)(stop.tv_sec - start.tv_sec)+(double)(stop.tv_nsec-start.tv_nsec); clock_gettime(CLOCK_REALTIME, &start); sslot = OatHash(word); clock_gettime(CLOCK_REALTIME, &stop); stot += (double)(stop.tv_sec - start.tv_sec)+(double)(stop.tv_nsec-start.tv_nsec); hashtable[slot]++; ehashtable[eslot]++; shashtable[sslot]++; printf("SLOTS: %d,%d,%d\n",slot,eslot,sslot); } printf("reference time %lf\n",tot/(double)CF_BILLION); printf("elf time %lf\n",etot/(double)CF_BILLION); printf("fast time %lf\n",stot/(double)CF_BILLION); printf(" -> Hashed %d %s words into %d slots with the following spectra:\n",i,title,CF_HASHTABLESIZE); for (j = 0; j < 10; j++) { freq[j] = efreq[j] = sfreq[j] = 0; } for (i = 0; i < CF_HASHTABLESIZE; i++) { for (j = 0; j < 10; j++) { if (hashtable[i] == j) { freq[j]++; } if (ehashtable[i] == j) { efreq[j]++; } if (shashtable[i] == j) { sfreq[j]++; } } } printf("\n"); for (j = 1; j < 10; j++) { if (freq[j] > 0) { printf(" -> F[%d] = %d\n",j,freq[j]); } } printf("\n"); for (j = 1; j < 10; j++) { if (efreq[j] > 0) { printf(" -> eF[%d] = %d\n",j,efreq[j]); } } printf("\n"); for (j = 1; j < 10; j++) { if (sfreq[j] > 0) { printf(" -> sF[%d] = %d\n",j,sfreq[j]); } } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/dbm_sqlite3.c��������������������������������������������������������������������0000644�0001750�0001750�00000025122�11715232734�013367� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #include "cf3.defs.h" #include "cf3.extern.h" /* * Implement/emulate key-value storage using SQLite3. * * TODO: Re-use compiled statements. */ #ifdef SQLITE3 #include "dbm_sqlite3.h" static int SQLite3_PrepareSchema(sqlite3 *handle); /*****************************************************************************/ int SQLite3_OpenDB(char *filename, sqlite3 **dbp) { *dbp = NULL; int ret = sqlite3_open_v2(filename, dbp, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_SHAREDCACHE, NULL); if (*dbp == NULL) { FatalError("Unable to allocate memory for sqlite3 handle"); } if (ret != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_OpenDB: Unable to open database: %s", sqlite3_errmsg(*dbp)); return false; } return SQLite3_PrepareSchema(*dbp); } /*****************************************************************************/ const char *CREATE_TABLE = "CREATE TABLE IF NOT EXISTS data " "(key TEXT PRIMARY KEY, value TEXT NOT NULL)"; static int SQLite3_PrepareSchema(sqlite3 *dbp) { char *errmsg; if (sqlite3_exec(dbp, CREATE_TABLE, NULL, NULL, &errmsg) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_PrepareSchema: Unable to create table in database: %s", errmsg); sqlite3_free(errmsg); return false; } return true; } /*****************************************************************************/ int SQLite3_CloseDB(sqlite3 *dbp) { if (sqlite3_close(dbp) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_CloseDB: Unable to close database: %s", sqlite3_errmsg(dbp)); return false; } return true; } /*****************************************************************************/ const char *SELECT_SIZE = "SELECT LENGTH(value) FROM data WHERE key = ?1"; int SQLite3_ValueSizeDB(sqlite3 *dbp, char *key) { sqlite3_stmt *stmt = NULL; int retval = -1; int ret; if (sqlite3_prepare_v2(dbp, SELECT_SIZE, -1, &stmt, NULL) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_ValueSizeDB: Unable to prepare statement: %s", sqlite3_errmsg(dbp)); goto done; } if (sqlite3_bind_text(stmt, 1, key, -1, SQLITE_TRANSIENT) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_ValueSizeDB: Unable to bind paremeter: %s", sqlite3_errmsg(dbp)); goto done; } ret = sqlite3_step(stmt); if (ret == SQLITE_DONE) { Debug("Key %s does not exist in database.\n", key); } else if (ret == SQLITE_ROW) { retval = sqlite3_column_int(stmt, 0); } else { CfOut(cf_error, "", "SQLite3_ValueSizeDB: Unable to execute statement: %s", sqlite3_errmsg(dbp)); } done: if (sqlite3_finalize(stmt) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_ValueSizeDB: Unable to finalize statement: %s", sqlite3_errmsg(dbp)); } return retval; } /*****************************************************************************/ const char *SELECT_VALUE = "SELECT value FROM data WHERE key = ?1"; static int SQLite3_RevealComplexKeyDB(sqlite3 *dbp, char *key, int keysize, void **result, int *rsize) { sqlite3_stmt *stmt = NULL; bool retval = false; int ret; if (sqlite3_prepare_v2(dbp, SELECT_VALUE, -1, &stmt, NULL) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_RevealComplexKeyDB: Unable to prepare statament: %s", sqlite3_errmsg(dbp)); goto done; } if (sqlite3_bind_text(stmt, 1, key, keysize, SQLITE_TRANSIENT) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_RevealComplexKeyDB: Unable to bind parameter: %s", sqlite3_errmsg(dbp)); goto done; } ret = sqlite3_step(stmt); if (ret == SQLITE_DONE) { Debug("Key %.*s does not exist in database", keysize, key); } else if (ret == SQLITE_ROW) { *result = (char*)sqlite3_column_text(stmt, 0); *rsize = sqlite3_column_bytes(stmt, 0);; retval = true; } else { CfOut(cf_error, "", "SQLite3_RevealComplexKeyDB: Unable to execute statement: %s", sqlite3_errmsg(dbp)); } done: if (sqlite3_finalize(stmt) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_RevealComplexKeyDB: Unable to finalize statement: %s", sqlite3_errmsg(dbp)); } return retval; } /*****************************************************************************/ int SQLite3_ReadComplexKeyDB(sqlite3 *dbp, char *key, int keysize, void *ptr, int expectedsize) { void *retvalue; int retsize; if (SQLite3_RevealComplexKeyDB(dbp, key, keysize, &retvalue, &retsize)) { if (expectedsize <= retsize) { memcpy(ptr, retvalue, expectedsize); } else if (expectedsize > retsize) { Debug("SQLite3_ReadComplexKeyDB: data for key %.s is larger than expected (%d > %d)", keysize, key, retsize, expectedsize); memcpy(ptr, retvalue, retsize); memset(ptr + retsize, 0, expectedsize - retsize); } return true; } else { return false; } } /*****************************************************************************/ int SQLite3_RevealDB(sqlite3 *dbp, char *key, void **result, int *rsize) { return SQLite3_RevealComplexKeyDB(dbp, key, strlen(key), result, rsize); } /*****************************************************************************/ const char *INSERT_KEY_VALUE = "INSERT OR REPLACE INTO data VALUES (?1, ?2)"; int SQLite3_WriteComplexKeyDB(sqlite3 *dbp, char *key, int keysize, const void *ptr, int size) { sqlite3_stmt *stmt = NULL; bool retval = false; if (sqlite3_prepare_v2(dbp, INSERT_KEY_VALUE, -1, &stmt, NULL) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_WriteComplexKeyDB: Unable to prepare statement: %s", sqlite3_errmsg(dbp)); goto done; } if (sqlite3_bind_text(stmt, 1, key, keysize, SQLITE_TRANSIENT) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_WriteComplexKeyDB: Unable to bind parameter: %s", sqlite3_errmsg(dbp)); goto done; } if (sqlite3_bind_text(stmt, 2, ptr, size, SQLITE_TRANSIENT) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_WriteComplexKeyDB: Unable to bind parameter: %s", sqlite3_errmsg(dbp)); goto done; } if (sqlite3_step(stmt) == SQLITE_DONE) { retval = true; } else { CfOut(cf_error, "", "SQLite3_WriteComplexKeyDB: Unable to execute statement: %s", sqlite3_errmsg(dbp)); } done: if (sqlite3_finalize(stmt) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_WriteComplexKeyDB: Unable to finalize statement: %s", sqlite3_errmsg(dbp)); } return retval; } /*****************************************************************************/ const char *DELETE_KEY = "DELETE FROM data WHERE key = ?1"; int SQLite3_DeleteComplexKeyDB(sqlite3 *dbp, char *key, int keysize) { sqlite3_stmt *stmt = NULL; bool retval = false; if (sqlite3_prepare_v2(dbp, DELETE_KEY, -1, &stmt, NULL) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_DeleteComplexKeyDB: Unable to prepare statement: %s", sqlite3_errmsg(dbp)); goto done; } if (sqlite3_bind_text(stmt, 1, key, keysize, SQLITE_TRANSIENT) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_DeleteComplexKeyDB: Unable to bind parameter: %s", sqlite3_errmsg(dbp)); goto done; } if (sqlite3_step(stmt) == SQLITE_DONE) { if (sqlite3_changes(dbp) == 0) { Debug("Key %.*s requested for deletion is not found in database", keysize, key); } retval = true; } else { CfOut(cf_error, "", "SQLite3_DeleteComplexKeyDB: Unable to execute statement: %s", sqlite3_errmsg(dbp)); } done: if (sqlite3_finalize(stmt) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_DeleteComplexKeyDB: Unable to finalize statement: %s", sqlite3_errmsg(dbp)); } return retval; } /*****************************************************************************/ const char *SELECT_KEYS_VALUES = "SELECT key, value FROM data"; int SQLite3_NewDBCursor(sqlite3 *dbp, sqlite3_stmt **stmt) { if (sqlite3_prepare_v2(dbp, SELECT_KEYS_VALUES, -1, stmt, NULL) == SQLITE_OK) { return true; } CfOut(cf_error, "", "SQLite3_DeleteComplexKeyDB: Unable to prepare statement: %s", sqlite3_errmsg(dbp)); return false; } /*****************************************************************************/ int SQLite3_NextDB(sqlite3 *dbp, sqlite3_stmt *stmt, char **key, int *ksize, void **value, int *vsize) { int ret = sqlite3_step(stmt); if (ret == SQLITE_DONE) { return false; } if (ret == SQLITE_ROW) { *key = (char*)sqlite3_column_text(stmt, 0); *ksize = sqlite3_column_bytes(stmt, 0); *value = (char*)sqlite3_column_text(stmt, 1); *vsize = sqlite3_column_bytes(stmt, 1); return true; } CfOut(cf_error, "", "SQLite3_NextDB: Error trying to read database: %s\n", sqlite3_errmsg(dbp)); return false; } /*****************************************************************************/ int SQLite3_DeleteDBCursor(sqlite3 *dbp, sqlite3_stmt *stmt) { if (sqlite3_finalize(stmt) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_DeleteDBCursor: Unable to finalize statement: %s", sqlite3_errmsg(dbp)); return false; } return true; } /*****************************************************************************/ static const char *OPEN_TRANSACTION="BEGIN TRANSACTION"; void SQLite3_OpenDBTransaction(sqlite3 *dbp) { char *errmsg; if (sqlite3_exec(dbp, OPEN_TRANSACTION, NULL, NULL, &errmsg) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_OpenDBTransaction: Unable to begin transaction: %s", errmsg); sqlite3_free(errmsg); } } /*****************************************************************************/ static const char *COMMIT_TRANSACTION="COMMIT TRANSACTION"; void SQLite3_CommitDBTransaction(sqlite3 *dbp) { char *errmsg; if (sqlite3_exec(dbp, COMMIT_TRANSACTION, NULL, NULL, &errmsg) != SQLITE_OK) { CfOut(cf_error, "", "SQLite3_CommitDBTransaction: Unable to commit: %s", errmsg); sqlite3_free(errmsg); } } #endif ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/cf_sql.c�������������������������������������������������������������������������0000644�0001750�0001750�00000033460�11715232734�012434� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: cf_sql.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #ifdef HAVE_MYSQL_H #include <mysql.h> #elif defined(HAVE_MYSQL_MYSQL_H) #include <mysql/mysql.h> #endif #ifdef HAVE_PGSQL_LIBPQ_FE_H #include <pgsql/libpq-fe.h> #elif defined(HAVE_LIBPQ_FE_H) #include <libpq-fe.h> #endif static char *EscapeSQL(CfdbConn *cfdb,char *query); static void Debugcfdb(CfdbConn *cfdb); /* Cfengine connectors for sql databases. Note that there are significant differences in db admin functions in the various implementations. e.g. sybase/mysql "use database, create database" not in postgres. CfConnectDB(&cfdb,SQL_TYPE,SQL_SERVER,SQL_OWNER,SQL_PASSWD,SQL_DATABASE); if (!cfdb.connected) { printf("Could not open sqldb\n"); return; } CfNewQueryDB(&cfdb,"SELECT * from topics"); while(CfFetchRow(&cfdb)) { for (i = 0; i < cfdb.maxcolumns; i++) { printf("Row %d: %s\n",i,CfFetchColumn(&cfdb,i)); } } CfDeleteQuery(&cfdb); CfCloseDB(&cfdb); */ /*****************************************************************************/ #ifdef HAVE_LIBMYSQLCLIENT struct CfDbMysqlConn { MYSQL conn; MYSQL_RES *res; }; /*****************************************************************************/ static struct CfDbMysqlConn *CfConnectMysqlDB(const char *host, const char *user, const char *password, const char *database) { struct CfDbMysqlConn *c; CfOut(cf_verbose,""," -> This is a MySQL database\n"); c = calloc(1, sizeof(struct CfDbMysqlConn)); if (!c) { CfOut(cf_error, "", "Failed to allocate memory to store MySQL database information"); return NULL; } mysql_init(&c->conn); if (!mysql_real_connect(&c->conn, host, user, password, database, 0, NULL, 0)) { CfOut(cf_error,"","Failed to connect to existing MySQL database: %s\n",mysql_error(&c->conn)); free(c); return NULL; } return c; } /*****************************************************************************/ static void CfCloseMysqlDB(struct CfDbMysqlConn *c) { mysql_close(&c->conn); free(c); } /*****************************************************************************/ static void CfNewQueryMysqlDb(CfdbConn *c, const char *query) { struct CfDbMysqlConn *mc = c->data; if (mysql_query(&mc->conn, query) != 0) { CfOut(cf_inform,"","MySQL query failed: %s, (%s)\n",query,mysql_error(&mc->conn)); } else { mc->res = mysql_store_result(&mc->conn); if (mc->res) { c->result = true; c->maxcolumns = mysql_num_fields(mc->res); c->maxrows = mysql_num_rows(mc->res); } } } /*****************************************************************************/ static void CfFetchMysqlRow(CfdbConn *c) { int i; MYSQL_ROW thisrow; struct CfDbMysqlConn *mc = c->data; if (c->maxrows > 0) { thisrow = mysql_fetch_row(mc->res); if (thisrow) { c->rowdata = malloc(sizeof(char *) * c->maxcolumns); for (i = 0; i < c->maxcolumns; i++) { c->rowdata[i] = (char *)thisrow[i]; } } else { c->rowdata = NULL; } } } /*****************************************************************************/ static void CfDeleteMysqlQuery(CfdbConn *c) { struct CfDbMysqlConn *mc = c->data; if (mc->res) { mysql_free_result(mc->res); mc->res = NULL; } } /*****************************************************************************/ static void CfEscapeMysqlSQL(CfdbConn *c, const char *query, char *result) { struct CfDbMysqlConn *mc = c->data; mysql_real_escape_string(&mc->conn, result, query, strlen(query)); } #else static void *CfConnectMysqlDB(const char *host, const char *user, const char *password, const char *database) { CfOut(cf_inform,"","There is no MySQL support compiled into this version"); return NULL; } static void CfCloseMysqlDB(void *c) { } static void CfNewQueryMysqlDb(CfdbConn *c, const char *query) { } static void CfFetchMysqlRow(CfdbConn *c) { } static void CfDeleteMysqlQuery(CfdbConn *c) { } static void CfEscapeMysqlSQL(CfdbConn *c, const char *query, char *result) { } #endif #ifdef HAVE_LIBPQ struct CfDbPostgresqlConn { PGconn *conn; PGresult *res; }; /*****************************************************************************/ static struct CfDbPostgresqlConn *CfConnectPostgresqlDB(const char *host, const char *user, const char *password, const char *database) { struct CfDbPostgresqlConn *c; char format[CF_BUFSIZE]; CfOut(cf_verbose,""," -> This is a PotsgreSQL database\n"); c = calloc(1, sizeof(struct CfDbPostgresqlConn)); if (!c) { CfOut(cf_error, "", "Failed to allocate memory to store PostgreSQL database information"); return NULL; } if (strcmp(host,"localhost") == 0) { /* Some authentication problem - ?? */ if (database) { snprintf(format,CF_BUFSIZE-1,"dbname=%s user=%s password=%s",database,user,password); } else { snprintf(format,CF_BUFSIZE-1,"user=%s password=%s",user,password); } } else { if (database) { snprintf(format,CF_BUFSIZE-1,"dbname=%s host=%s user=%s password=%s",database,host,user,password); } else { snprintf(format,CF_BUFSIZE-1,"host=%s user=%s password=%s",host,user,password); } } c->conn = PQconnectdb(format); if (PQstatus(c->conn) == CONNECTION_BAD) { CfOut(cf_error,"","Failed to connect to existing PostgreSQL database: %s\n",PQerrorMessage(c->conn)); free(c); return NULL; } return c; } /*****************************************************************************/ static void CfClosePostgresqlDb(struct CfDbPostgresqlConn *c) { PQfinish(c->conn); free(c); } /*****************************************************************************/ static void CfNewQueryPostgresqlDb(CfdbConn *c, const char *query) { struct CfDbPostgresqlConn *pc = c->data; pc->res = PQexec(pc->conn, query); if (PQresultStatus(pc->res) != PGRES_COMMAND_OK && PQresultStatus(pc->res) != PGRES_TUPLES_OK) { CfOut(cf_inform,"","PostgreSQL query failed: %s, %s\n",query,PQerrorMessage(pc->conn)); } else { c->result = true; c->maxcolumns = PQnfields(pc->res); c->maxrows = PQntuples(pc->res); } } /*****************************************************************************/ static void CfFetchPostgresqlRow(CfdbConn *c) { int i; struct CfDbPostgresqlConn *pc = c->data; if (c->row >= c->maxrows) { c->rowdata = NULL; return; } if (c->maxrows > 0) { c->rowdata = malloc(sizeof(char *) * c->maxcolumns); } for (i = 0; i < c->maxcolumns; i++) { c->rowdata[i] = PQgetvalue(pc->res,c->row,i); } } /*****************************************************************************/ static void CfDeletePostgresqlQuery(CfdbConn *c) { struct CfDbPostgresqlConn *pc = c->data; PQclear(pc->res); } /*****************************************************************************/ static void CfEscapePostgresqlSQL(CfdbConn *c, const char *query, char *result) { PQescapeString(result, query, strlen(query)); } #else static void *CfConnectPostgresqlDB(const char *host, const char *user, const char *password, const char *database) { CfOut(cf_inform,"","There is no PostgreSQL support compiled into this version"); return NULL; } static void CfClosePostgresqlDb(void *c) { } static void CfNewQueryPostgresqlDb(CfdbConn *c, const char *query) { } static void CfFetchPostgresqlRow(CfdbConn *c) { } static void CfDeletePostgresqlQuery(CfdbConn *c) { } static void CfEscapePostgresqlSQL(CfdbConn *c, const char *query, char *result) { } #endif /*****************************************************************************/ int CfConnectDB(CfdbConn *cfdb,enum cfdbtype dbtype,char *remotehost,char *dbuser, char *passwd, char *db) { cfdb->connected = false; cfdb->type = dbtype; /* If db == NULL, no database was specified, so we assume it has not been created yet. Need to open a generic database and create */ if (db == NULL) { db = "no db specified"; } CfOut(cf_verbose,"","Connect to SQL database \"%s\" user=%s, host=%s (type=%d)\n",db,dbuser,remotehost,dbtype); switch (dbtype) { case cfd_mysql: cfdb->data = CfConnectMysqlDB(remotehost, dbuser, passwd, db); break; case cfd_postgres: cfdb->data = CfConnectPostgresqlDB(remotehost, dbuser, passwd, db); break; default: CfOut(cf_verbose,"","There is no SQL database selected"); break; } if (cfdb->data) cfdb->connected = true; cfdb->blank = strdup(""); return true; } /*****************************************************************************/ void CfCloseDB(CfdbConn *cfdb) { if (!cfdb->connected) { return; } switch (cfdb->type) { case cfd_mysql: CfCloseMysqlDB(cfdb->data); break; case cfd_postgres: CfClosePostgresqlDb(cfdb->data); break; default: CfOut(cf_verbose,"","There is no SQL database selected"); break; } cfdb->connected = false; free(cfdb->blank); } /*****************************************************************************/ void CfVoidQueryDB(CfdbConn *cfdb,char *query) { if (!cfdb->connected) { return; } /* If we don't need to retrieve table entries...*/ CfNewQueryDB(cfdb,query); CfDeleteQuery(cfdb); } /*****************************************************************************/ void CfNewQueryDB(CfdbConn *cfdb,char *query) { cfdb->result = false; cfdb->row = 0; cfdb->column = 0; cfdb->rowdata = NULL; cfdb->maxcolumns = 0; cfdb->maxrows = 0; Debug("Before Query succeeded: %s - %d,%d\n",query,cfdb->maxrows,cfdb->maxcolumns); switch (cfdb->type) { case cfd_mysql: CfNewQueryMysqlDb(cfdb, query); break; case cfd_postgres: CfNewQueryPostgresqlDb(cfdb, query); break; default: CfOut(cf_verbose,"","There is no SQL database selected"); break; } Debug("Query succeeded: (%s) %d,%d\n",query,cfdb->maxrows,cfdb->maxcolumns); } /*****************************************************************************/ char **CfFetchRow(CfdbConn *cfdb) { switch (cfdb->type) { case cfd_mysql: CfFetchMysqlRow(cfdb); break; case cfd_postgres: CfFetchPostgresqlRow(cfdb); break; default: CfOut(cf_verbose,"","There is no SQL database selected"); break; } cfdb->row++; return cfdb->rowdata; } /*****************************************************************************/ char *CfFetchColumn(CfdbConn *cfdb,int col) { if (cfdb->rowdata && cfdb->rowdata[col]) { return cfdb->rowdata[col]; } else { return NULL; } } /*****************************************************************************/ void CfDeleteQuery(CfdbConn *cfdb) { switch (cfdb->type) { case cfd_mysql: CfDeleteMysqlQuery(cfdb); break; case cfd_postgres: CfDeletePostgresqlQuery(cfdb); break; default: CfOut(cf_verbose,"","There is no SQL database selected"); break; } if (cfdb->rowdata) { free(cfdb->rowdata); cfdb->rowdata = NULL; } } /*****************************************************************************/ static char *EscapeSQL(CfdbConn *cfdb,char *query) { static char result[CF_BUFSIZE]; if (!cfdb->connected) { return query; } memset(result,0,CF_BUFSIZE); switch (cfdb->type) { case cfd_mysql: CfEscapeMysqlSQL(cfdb, query, result); break; case cfd_postgres: CfEscapePostgresqlSQL(cfdb, query, result); break; default: CfOut(cf_verbose,"","There is no SQL database selected"); break; } return result; } /*****************************************************************************/ static void Debugcfdb(CfdbConn *cfdb) { printf("SIZE of CfdbConn: %d = %d\n",sizeof(CfdbConn),sizeof(*cfdb)); printf( "cfdb->result = %d\n",cfdb->result); printf( "cfdb->row = %d\n",cfdb->row); printf( "cfdb->column = %d\n",cfdb->column); printf( "cfdb->maxcolumns = %d\n",cfdb->maxcolumns); printf( "cfdb->maxrows = %d\n",cfdb->maxrows); printf( "cfdb->type = %d\n",cfdb->type); } /*****************************************************************************/ /* EOF */ ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/args.c���������������������������������������������������������������������������0000644�0001750�0001750�00000016321�11715232734�012116� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: args.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /******************************************************************/ /* Argument propagation */ /******************************************************************/ /* When formal parameters are passed, they should be literal strings, i.e. values (check for this). But when the values are received the receiving body should state only variable names without literal quotes. That way we can feed in the received parameter name directly in as an lvalue e.g. access => myaccess("$(person)"), body files myaccess(user) leads to Hash Association (lval,rval) => (user,"$(person)") */ /******************************************************************/ int MapBodyArgs(char *scopeid,struct Rlist *give,struct Rlist *take) { struct Rlist *rpg,*rpt; struct FnCall *fp; enum cfdatatype dtg = cf_notype,dtt = cf_notype; char *lval; void *rval; struct Rval returnval; int len1,len2; Debug("MapBodyArgs(begin)\n"); len1 = RlistLen(give); len2 = RlistLen(take); if (len1 != len2) { CfOut(cf_error,""," !! Argument mismatch in body template give[+args] = %d, take[-args] = %d",len1,len2); return false; } for (rpg = give, rpt = take; rpg != NULL && rpt != NULL; rpg=rpg->next,rpt=rpt->next) { dtg = StringDataType(scopeid,(char *)rpg->item); dtt = StringDataType(scopeid,(char *)rpt->item); if (dtg != dtt) { CfOut(cf_error,"","Type mismatch between logical/formal parameters %s/%s\n",(char *)rpg->item,(char *)rpt->item); CfOut(cf_error,"","%s is %s whereas %s is %s\n",(char *)rpg->item,CF_DATATYPES[dtg],(char *)rpt->item,CF_DATATYPES[dtt]); } switch (rpg->type) { case CF_SCALAR: lval = (char *)rpt->item; rval = rpg->item; Debug("MapBodyArgs(SCALAR,%s,%s)\n",lval,rval); AddVariableHash(scopeid,lval,rval,CF_SCALAR,dtg,NULL,0); break; case CF_LIST: lval = (char *)rpt->item; rval = rpg->item; AddVariableHash(scopeid,lval,rval,CF_LIST,dtg,NULL,0); break; case CF_FNCALL: fp = (struct FnCall *)rpg->item; dtg = FunctionReturnType(fp->name); returnval = EvaluateFunctionCall(fp,NULL); if (FNCALL_STATUS.status == FNCALL_FAILURE && THIS_AGENT_TYPE != cf_common) { // Unresolved variables if (VERBOSE) { printf(" !! Embedded function argument does not resolve to a name - probably too many evaluation levels for "); ShowFnCall(stdout,fp); printf(" (try simplifying)\n"); } } else { DeleteFnCall(fp); rpg->item = returnval.item; rpg->type = returnval.rtype; lval = (char *)rpt->item; rval = rpg->item; AddVariableHash(scopeid,lval,rval,CF_SCALAR,dtg,NULL,0); } break; default: /* Nothing else should happen */ FatalError("Software error: something not a scalar/function in argument literal"); } } Debug("MapBodyArgs(end)\n"); return true; } /******************************************************************/ struct Rlist *NewExpArgs(struct FnCall *fp, struct Promise *pp) { int i, len, ref = 0; struct Rval rval; struct Rlist *rp,*newargs = NULL; struct FnCall *subfp; FnCallType *fn = FindFunction(fp->name); /* Check if numargs correct and expand recursion */ len = RlistLen(fp->args); ref = fn ? fn->numargs : 0; if ((ref != CF_VARARGS) && (ref != len)) { CfOut(cf_error,"","Arguments to function %s(.) do not tally. Expect %d not %d",fp->name,ref,len); PromiseRef(cf_error,pp); exit(1); } for (rp = fp->args; rp != NULL; rp = rp->next) { switch (rp->type) { case CF_FNCALL: subfp = (struct FnCall *)rp->item; rval = EvaluateFunctionCall(subfp,pp); break; default: rval = ExpandPrivateRval(CONTEXTID,rp->item,rp->type); break; } Debug("EXPARG: %s.%s\n",CONTEXTID,rval.item); AppendRlist(&newargs,rval.item,rval.rtype); DeleteRvalItem(rval.item,rval.rtype); } return newargs; } /******************************************************************/ void DeleteExpArgs(struct Rlist *args) { DeleteRlist(args); } /******************************************************************/ void ArgTemplate(struct FnCall *fp,struct FnCallArg *argtemplate,struct Rlist *realargs) { int argnum,i; struct Rlist *rp = fp->args; char id[CF_BUFSIZE],output[CF_BUFSIZE]; FnCallType *fn = FindFunction(fp->name); snprintf(id,CF_MAXVARSIZE,"built-in FnCall %s-arg",fp->name); for (argnum = 0; rp != NULL && argtemplate[argnum].pattern != NULL; argnum++) { if (rp->type != CF_FNCALL) { /* Nested functions will not match to lval so don't bother checking */ CheckConstraintTypeMatch(id,rp->item,rp->type,argtemplate[argnum].dtype,argtemplate[argnum].pattern,1); } rp = rp->next; } if (argnum != RlistLen(realargs) && fn->numargs != CF_VARARGS) { snprintf(output,CF_BUFSIZE,"Argument template mismatch handling function %s(",fp->name); ReportError(output); ShowRlist(stderr,realargs); fprintf(stderr,")\n"); for (i = 0, rp = realargs; i < argnum; i++) { printf(" arg[%d] range %s\t",i,argtemplate[i].pattern); if (rp != NULL) { ShowRval(stdout,rp->item,rp->type); rp=rp->next; } else { printf(" ? "); } printf("\n"); } FatalError("Bad arguments"); } for (rp = realargs; rp != NULL; rp=rp->next) { Debug("finalarg: %s\n",rp->item); } Debug("End ArgTemplate\n"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/chflags.c������������������������������������������������������������������������0000644�0001750�0001750�00000013357�11715232734�012577� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* BSD flags.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" struct CfBSDFlag { char *name; u_long bits; }; struct CfBSDFlag CF_BSDFLAGS[] = { { "arch",(u_long)SF_ARCHIVED }, { "archived",(u_long)SF_ARCHIVED }, { "nodump",(u_long)UF_NODUMP }, { "opaque",(u_long)UF_OPAQUE }, { "sappnd",(u_long)SF_APPEND }, { "sappend",(u_long)SF_APPEND }, { "schg",(u_long)SF_IMMUTABLE }, { "schange",(u_long)SF_IMMUTABLE }, { "simmutable",(u_long)SF_IMMUTABLE }, { "sunlnk",(u_long)SF_NOUNLINK }, { "sunlink",(u_long)SF_NOUNLINK }, { "uappnd",(u_long)UF_APPEND }, { "uappend",(u_long)UF_APPEND }, { "uchg",(u_long)UF_IMMUTABLE }, { "uchange",(u_long)UF_IMMUTABLE }, { "uimmutable",(u_long)UF_IMMUTABLE }, { "uunlnk",(u_long)UF_NOUNLINK }, { "uunlink",(u_long)UF_NOUNLINK }, { NULL,(u_long)NULL } }; /***************************************************************/ static u_long ConvertBSDBits(char *s); /***************************************************************/ int ParseFlagString(struct Rlist *bitlist,u_long *plusmask,u_long *minusmask) { char *flag; struct Rlist *rp; char operator; if (bitlist == NULL) { return true; } *plusmask = 0; *minusmask = 0; for (rp = bitlist; rp != NULL; rp=rp->next) { flag = (char *)(rp->item); operator = *(char *)(rp->item); switch (operator) { case '-': *minusmask |= ConvertBSDBits(flag+1); break; case '+': *plusmask |= ConvertBSDBits(flag+1); break; default: *plusmask |= ConvertBSDBits(flag); break; } } Debug("ParseFlagString:[PLUS=%lo][MINUS=%lo]\n",*plusmask,*minusmask); return true; } /***************************************************************/ static u_long ConvertBSDBits(char *s) { int i; for (i = 0; CF_BSDFLAGS[i].name != NULL; i++) { if (strcmp(s,CF_BSDFLAGS[i].name) == 0) { return CF_BSDFLAGS[i].bits; } } return 0; } /* CHFLAGS(1) FreeBSD General Commands Manual CHFLAGS(1) NAME chflags - change file flags SYNOPSIS chflags [-R [-H | -L | -P]] flags file ... DESCRIPTION The chflags utility modifies the file flags of the listed files as speci- fied by the flags operand. The options are as follows: -H If the -R option is specified, symbolic links on the command line are followed. (Symbolic links encountered in the tree traversal are not followed.) -L If the -R option is specified, all symbolic links are followed. -P If the -R option is specified, no symbolic links are followed. -R Change the file flags for the file hierarchies rooted in the files instead of just the files themselves. Flags are a comma separated list of keywords. The following keywords are currently defined: arch set the archived flag (super-user only) dump set the dump flag sappnd set the system append-only flag (super-user only) schg set the system immutable flag (super-user only) sunlnk set the system undeletable flag (super-user only) uappnd set the user append-only flag (owner or super-user only) uchg set the user immutable flag (owner or super-user only) uunlnk set the user undeletable flag (owner or super-user only) archived, sappend, schange, simmutable, uappend, uchange, uimmutable, sunlink, uunlink aliases for the above Putting the letters ``no'' before an option causes the flag to be turned off. For example: nodump the file should never be dumped Symbolic links do not have flags, so unless the -H or -L option is set, chflags on a symbolic link always succeeds and has no effect. The -H, -L and -P options are ignored unless the -R option is specified. In addi- tion, these options override each other and the command's actions are de- termined by the last one specified. You can use "ls -lo" to see the flags of existing files. The chflags utility exits 0 on success, and >0 if an error occurs. SEE ALSO ls(1), chflags(2), stat(2), fts(3), symlink(7) HISTORY The chflags command first appeared in 4.4BSD. BSD March 31, 1994 1 */ ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/client_code.c��������������������������������������������������������������������0000644�0001750�0001750�00000113343�11715232734�013434� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ /* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*******************************************************************/ /* */ /* File copying */ /* */ /* client part for remote copying */ /* */ /*******************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void NewClientCache(struct cfstat *data,struct Promise *pp); static void CacheServerConnection(struct cfagent_connection *conn,char *server); static int TryConnect(struct cfagent_connection *conn, struct timeval *tvp, struct sockaddr *cinp, int cinpSz); static void MarkServerOffline(char *server); static struct cfagent_connection *ServerConnectionReady(char *server); static int ServerOffline(char *server); static void FlushFileStream(int sd,int toget); static int CacheStat(char *file,struct stat *statbuf,char *stattype,struct Attributes attr,struct Promise *pp); /*********************************************************************/ void DetermineCfenginePort() { struct servent *server; if ((server = getservbyname(CFENGINE_SERVICE,"tcp")) == NULL) { CfOut(cf_verbose,"getservbyname","No registered cfengine service, using default"); snprintf(STR_CFENGINEPORT,15,"5308"); SHORT_CFENGINEPORT = htons((unsigned short)5308); } else { snprintf(STR_CFENGINEPORT,15,"%u",ntohs(server->s_port)); SHORT_CFENGINEPORT = server->s_port; } CfOut(cf_verbose,"","Setting cfengine default port to %u = %s\n",ntohs(SHORT_CFENGINEPORT),STR_CFENGINEPORT); } /*********************************************************************/ struct cfagent_connection *NewServerConnection(struct Attributes attr,struct Promise *pp) { struct cfagent_connection *conn; struct Rlist *rp; // First one in goal has to open the connection, or mark it failed or private (thread) // We never close a non-background connection until end // mark serial connections as such for (rp = attr.copy.servers; rp != NULL; rp = rp->next) { if (ServerOffline(rp->item)) { continue; } pp->this_server = rp->item; if (attr.transaction.background) { if (RlistLen(SERVERLIST) < CFA_MAXTHREADS) { conn = ServerConnection(rp->item,attr,pp); return conn; } } else { if ((conn = ServerConnectionReady(rp->item))) { return conn; } /* This is first usage, need to open */ conn = ServerConnection(rp->item,attr,pp); if (conn == NULL) { cfPS(cf_inform,CF_FAIL,"",pp,attr,"Unable to establish connection with %s\n",rp->item); MarkServerOffline(rp->item); } else { CacheServerConnection(conn,rp->item); return conn; } } } pp->this_server = NULL; return NULL; } /*****************************************************************************/ struct cfagent_connection *ServerConnection(char *server,struct Attributes attr,struct Promise *pp) { struct cfagent_connection *conn; #ifndef MINGW static sigset_t signal_mask; signal(SIGPIPE,SIG_IGN); sigemptyset(&signal_mask); sigaddset(&signal_mask,SIGPIPE); pthread_sigmask (SIG_BLOCK,&signal_mask, NULL); #endif /* NOT MINGW */ if ((conn = NewAgentConn()) == NULL) { cfPS(cf_error,CF_FAIL,"malloc",pp,attr,"Unable to allocate connection structure for %s",server); return NULL; } if (strcmp(server,"localhost") == 0) { conn->authenticated = true; return conn; } conn->authenticated = false; conn->encryption_type = CfEnterpriseOptions(); /* username of the client - say root from Windows */ #ifdef MINGW snprintf(conn->username,CF_SMALLBUF,"root"); #else GetCurrentUserName(conn->username,CF_SMALLBUF); #endif /* NOT MINGW */ if (conn->sd == CF_NOT_CONNECTED) { Debug("Opening server connection to %s\n",server); if (!ServerConnect(conn,server,attr,pp)) { CfOut(cf_inform,""," !! No server is responding on this port"); if (conn->sd != CF_NOT_CONNECTED) { ServerDisconnection(conn); } return NULL; } if (conn->sd == (int)CF_NOT_CONNECTED) { return NULL; } Debug("Remote IP set to %s\n",conn->remoteip); if (!IdentifyAgent(conn->sd,conn->localip,conn->family)) { CfOut(cf_error,""," !! Id-authentication for %s failed\n",VFQNAME); errno = EPERM; ServerDisconnection(conn); return NULL; } if (!AuthenticateAgent(conn,attr,pp)) { CfOut(cf_error,""," !! Authentication dialogue with %s failed\n",server); errno = EPERM; ServerDisconnection(conn); return NULL; } conn->authenticated = true; return conn; } else { Debug("Server connection to %s already open on %d\n",server,conn->sd); } return conn; } /*********************************************************************/ void ServerDisconnection(struct cfagent_connection *conn) { Debug("Closing current server connection\n"); if (conn) { if (conn->sd > 0) { cf_closesocket(conn->sd); conn->sd = CF_NOT_CONNECTED; } DeleteAgentConn(conn); } } /*********************************************************************/ int cf_remote_stat(char *file,struct stat *buf,char *stattype,struct Attributes attr,struct Promise *pp) /* If a link, this reads readlink and sends it back in the same package. It then caches the value for each copy command */ { char sendbuffer[CF_BUFSIZE]; char recvbuffer[CF_BUFSIZE]; char in[CF_BUFSIZE],out[CF_BUFSIZE]; struct cfagent_connection *conn = pp->conn; struct cfstat cfst; int ret,tosend,cipherlen; time_t tloc; Debug("cf_remotestat(%s,%s)\n",file,stattype); memset(recvbuffer,0,CF_BUFSIZE); if (strlen(file) > CF_BUFSIZE-30) { CfOut(cf_error,"","Filename too long"); return -1; } ret = CacheStat(file,buf,stattype,attr,pp); if (ret != 0) { return ret; } if ((tloc = time((time_t *)NULL)) == -1) { CfOut(cf_error,"","Couldn't read system clock\n"); } sendbuffer[0] = '\0'; if (attr.copy.encrypt) { if (conn->session_key == NULL) { cfPS(cf_error,CF_FAIL,"",pp,attr," !! Cannot do encrypted copy without keys (use cf-key)"); return -1; } snprintf(in,CF_BUFSIZE-1,"SYNCH %d STAT %s",tloc,file); cipherlen = EncryptString(conn->encryption_type,in,out,conn->session_key,strlen(in)+1); snprintf(sendbuffer,CF_BUFSIZE-1,"SSYNCH %d",cipherlen); memcpy(sendbuffer+CF_PROTO_OFFSET,out,cipherlen); tosend = cipherlen+CF_PROTO_OFFSET; } else { snprintf(sendbuffer,CF_BUFSIZE,"SYNCH %d STAT %s",tloc,file); tosend = strlen(sendbuffer); } if (SendTransaction(conn->sd,sendbuffer,tosend,CF_DONE) == -1) { cfPS(cf_inform,CF_INTERPT,"send",pp,attr,"Transmission failed/refused talking to %.255s:%.255s in stat",pp->this_server,file); return -1; } if (ReceiveTransaction(conn->sd,recvbuffer,NULL) == -1) { DestroyServerConnection(conn); return -1; } if (strstr(recvbuffer,"unsynchronized")) { CfOut(cf_error,"","Clocks differ too much to do copy by date (security) %s",recvbuffer+4); return -1; } if (BadProtoReply(recvbuffer)) { CfOut(cf_verbose,"","Server returned error: %s\n",recvbuffer+4); errno = EPERM; return -1; } if (OKProtoReply(recvbuffer)) { long d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12=0,d13=0; sscanf(recvbuffer,"OK: %1ld %5ld %14ld %14ld %14ld %14ld %14ld %14ld %14ld %14ld %14ld %14ld %14ld", &d1,&d2,&d3,&d4,&d5,&d6,&d7,&d8,&d9,&d10,&d11,&d12,&d13); cfst.cf_type = (enum cf_filetype) d1; cfst.cf_mode = (mode_t) d2; cfst.cf_lmode = (mode_t) d3; cfst.cf_uid = (uid_t) d4; cfst.cf_gid = (gid_t) d5; cfst.cf_size = (off_t) d6; cfst.cf_atime = (time_t) d7; cfst.cf_mtime = (time_t) d8; cfst.cf_ctime = (time_t) d9; cfst.cf_makeholes = (char) d10; pp->makeholes = (char) d10; cfst.cf_ino = d11; cfst.cf_nlink = d12; cfst.cf_dev = d13; /* Use %?d here to avoid memory overflow attacks */ Debug("Mode = %d,%d\n",d2,d3); Debug("OK: type=%d\n mode=%o\n lmode=%o\n uid=%d\n gid=%d\n size=%ld\n atime=%d\n mtime=%d ino=%d nlnk=%d, dev=%d\n", cfst.cf_type,cfst.cf_mode,cfst.cf_lmode,cfst.cf_uid,cfst.cf_gid,(long)cfst.cf_size, cfst.cf_atime,cfst.cf_mtime,cfst.cf_ino,cfst.cf_nlink,cfst.cf_dev); memset(recvbuffer,0,CF_BUFSIZE); if (ReceiveTransaction(conn->sd,recvbuffer,NULL) == -1) { DestroyServerConnection(conn); return -1; } Debug("Linkbuffer: %s\n",recvbuffer); if (strlen(recvbuffer) > 3) { cfst.cf_readlink = strdup(recvbuffer+3); } else { cfst.cf_readlink = NULL; } switch (cfst.cf_type) { case cf_reg: cfst.cf_mode |= (mode_t) S_IFREG; break; case cf_dir: cfst.cf_mode |= (mode_t) S_IFDIR; break; case cf_char: cfst.cf_mode |= (mode_t) S_IFCHR; break; case cf_fifo: cfst.cf_mode |= (mode_t) S_IFIFO; break; case cf_sock: cfst.cf_mode |= (mode_t) S_IFSOCK; break; case cf_block: cfst.cf_mode |= (mode_t) S_IFBLK; break; case cf_link: cfst.cf_mode |= (mode_t) S_IFLNK; break; } cfst.cf_filename = strdup(file); cfst.cf_server = strdup(pp->this_server); if ((cfst.cf_filename == NULL) ||(cfst.cf_server) == NULL) { FatalError("Memory allocation in cf_rstat"); } cfst.cf_failed = false; if (cfst.cf_lmode != 0) { cfst.cf_lmode |= (mode_t) S_IFLNK; } NewClientCache(&cfst,pp); if ((cfst.cf_lmode != 0) && (strcmp(stattype,"link") == 0)) { buf->st_mode = cfst.cf_lmode; } else { buf->st_mode = cfst.cf_mode; } buf->st_uid = cfst.cf_uid; buf->st_gid = cfst.cf_gid; buf->st_size = cfst.cf_size; buf->st_mtime = cfst.cf_mtime; buf->st_ctime = cfst.cf_ctime; buf->st_atime = cfst.cf_atime; buf->st_ino = cfst.cf_ino; buf->st_dev = cfst.cf_dev; buf->st_nlink = cfst.cf_nlink; return 0; } CfOut(cf_error,""," !! Transmission refused or failed statting %s\nGot: %s\n",file,recvbuffer); errno = EPERM; return -1; } /*********************************************************************/ CFDIR *OpenDirRemote(const char *dirname,struct Attributes attr,struct Promise *pp) { struct cfagent_connection *conn = pp->conn; char sendbuffer[CF_BUFSIZE]; char recvbuffer[CF_BUFSIZE]; char in[CF_BUFSIZE]; char out[CF_BUFSIZE]; int n, cipherlen = 0,plainlen = 0,tosend; CFDIR *cfdirh; char *sp; struct Item *files = NULL; Debug("CfOpenDir(%s:%s)\n",pp->this_server,dirname); if (strlen(dirname) > CF_BUFSIZE - 20) { CfOut(cf_error,""," !! Directory name too long"); return NULL; } if ((cfdirh = calloc(1, sizeof(CFDIR))) == NULL) { CfOut(cf_error,""," !! Couldn't allocate memory in cf_remote_opendir\n"); exit(1); } if (attr.copy.encrypt) { if (conn->session_key == NULL) { cfPS(cf_error,CF_INTERPT,"",pp,attr," !! Cannot do encrypted copy without keys (use cf-key)"); return NULL; free(cfdirh); } snprintf(in,CF_BUFSIZE,"OPENDIR %s",dirname); cipherlen = EncryptString(conn->encryption_type,in,out,conn->session_key,strlen(in)+1); snprintf(sendbuffer,CF_BUFSIZE-1,"SOPENDIR %d",cipherlen); memcpy(sendbuffer+CF_PROTO_OFFSET,out,cipherlen); tosend = cipherlen+CF_PROTO_OFFSET; } else { snprintf(sendbuffer,CF_BUFSIZE,"OPENDIR %s",dirname); tosend = strlen(sendbuffer); } if (SendTransaction(conn->sd,sendbuffer,tosend,CF_DONE) == -1) { free((char *)cfdirh); return NULL; } while (true) { if ((n = ReceiveTransaction(conn->sd,recvbuffer,NULL)) == -1) { DestroyServerConnection(conn); free((char *)cfdirh); return NULL; } if (n == 0) { break; } if (attr.copy.encrypt) { memcpy(in,recvbuffer,n); plainlen = DecryptString(conn->encryption_type,in,recvbuffer,conn->session_key,n); } if (FailedProtoReply(recvbuffer)) { cfPS(cf_inform,CF_INTERPT,"",pp,attr,"Network access to %s:%s denied\n",pp->this_server,dirname); free((char *)cfdirh); return NULL; } if (BadProtoReply(recvbuffer)) { CfOut(cf_inform,"","%s\n",recvbuffer+4); free((char *)cfdirh); return NULL; } for (sp = recvbuffer; *sp != '\0'; sp++) { struct Item *ip; if (strncmp(sp,CFD_TERMINATOR,strlen(CFD_TERMINATOR)) == 0) /* End transmission */ { cfdirh->listpos = cfdirh->list; return cfdirh; } if ((ip = calloc(1, sizeof(struct Item))) == NULL) { FatalError("Failed to alloc in OpenDirRemote"); } ip->name = (char*)AllocateDirentForFilename(sp); if (files == NULL) /* First element */ { cfdirh->list = ip; files = ip; } else { files->next = ip; files = ip; } while(*sp != '\0') { sp++; } } } cfdirh->listpos = cfdirh->list; return cfdirh; } /*********************************************************************/ static void NewClientCache(struct cfstat *data,struct Promise *pp) { struct cfstat *sp; Debug("NewClientCache\n"); if ((sp = (struct cfstat *) malloc(sizeof(struct cfstat))) == NULL) { CfOut(cf_error,""," !! Memory allocation faliure in CacheData()\n"); return; } memcpy(sp,data,sizeof(struct cfstat)); sp->next = pp->cache; pp->cache = sp; } /*********************************************************************/ void DeleteClientCache(struct Attributes attr,struct Promise *pp) { struct cfstat *sp,*sps; Debug("DeleteClientCache\n"); sp = pp->cache; while (sp != NULL) { sps = sp; sp = sp->next; free((char *)sps); } pp->cache = NULL; } /*********************************************************************/ int CompareHashNet(char *file1,char *file2,struct Attributes attr,struct Promise *pp) { static unsigned char d[EVP_MAX_MD_SIZE+1]; char *sp,sendbuffer[CF_BUFSIZE],recvbuffer[CF_BUFSIZE],in[CF_BUFSIZE],out[CF_BUFSIZE]; int i,tosend,cipherlen; struct cfagent_connection *conn = pp->conn; HashFile(file2,d,CF_DEFAULT_DIGEST); Debug("Send digest of %s to server, %s\n",file2,HashPrint(CF_DEFAULT_DIGEST,d)); memset(recvbuffer,0,CF_BUFSIZE); if (attr.copy.encrypt) { snprintf(in,CF_BUFSIZE,"MD5 %s",file1); sp = in + strlen(in) + CF_SMALL_OFFSET; for (i = 0; i < CF_DEFAULT_DIGEST_LEN; i++) { *sp++ = d[i]; } cipherlen = EncryptString(conn->encryption_type,in,out,conn->session_key,strlen(in)+CF_SMALL_OFFSET+CF_DEFAULT_DIGEST_LEN); snprintf(sendbuffer,CF_BUFSIZE,"SMD5 %d",cipherlen); memcpy(sendbuffer+CF_PROTO_OFFSET,out,cipherlen); tosend = cipherlen + CF_PROTO_OFFSET; } else { snprintf(sendbuffer,CF_BUFSIZE,"MD5 %s",file1); sp = sendbuffer + strlen(sendbuffer) + CF_SMALL_OFFSET; for (i = 0; i < CF_DEFAULT_DIGEST_LEN; i++) { *sp++ = d[i]; } tosend = strlen(sendbuffer)+CF_SMALL_OFFSET+CF_DEFAULT_DIGEST_LEN; } if (SendTransaction(conn->sd,sendbuffer,tosend,CF_DONE) == -1) { cfPS(cf_error,CF_INTERPT,"send",pp,attr,"Failed send"); return false; } if (ReceiveTransaction(conn->sd,recvbuffer,NULL) == -1) { DestroyServerConnection(conn); cfPS(cf_error,CF_INTERPT,"recv",pp,attr,"Failed send"); CfOut(cf_verbose,"","No answer from host, assuming checksum ok to avoid remote copy for now...\n"); return false; } if (strcmp(CFD_TRUE,recvbuffer) == 0) { Debug("Hash mismatch: (reply - %s)\n",recvbuffer); return true; /* mismatch */ } else { Debug("Hash matched ok: (reply - %s)\n",recvbuffer); return false; } /* Not reached */ } /*********************************************************************/ int CopyRegularFileNet(char *source,char *new,off_t size,struct Attributes attr,struct Promise *pp) { int dd, buf_size,n_read = 0,toget,towrite; int last_write_made_hole = 0, done = false,tosend,value; char *buf,workbuf[CF_BUFSIZE],cfchangedstr[265]; long n_read_total = 0; EVP_CIPHER_CTX ctx; struct cfagent_connection *conn = pp->conn; snprintf(cfchangedstr,255,"%s%s",CF_CHANGEDSTR1,CF_CHANGEDSTR2); if ((strlen(new) > CF_BUFSIZE-20)) { cfPS(cf_error,CF_INTERPT,"",pp,attr,"Filename too long"); return false; } unlink(new); /* To avoid link attacks */ if ((dd = open(new,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0600)) == -1) { cfPS(cf_error,CF_INTERPT,"open",pp,attr," !! NetCopy to destination %s:%s security - failed attempt to exploit a race? (Not copied)\n",pp->this_server,new); unlink(new); return false; } workbuf[0] = '\0'; buf_size = 2048; /* Send proposition C0 */ snprintf(workbuf,CF_BUFSIZE,"GET %d %s",buf_size,source); tosend=strlen(workbuf); if (SendTransaction(conn->sd,workbuf,tosend,CF_DONE) == -1) { cfPS(cf_error,CF_INTERPT,"",pp,attr,"Couldn't send data"); close(dd); return false; } buf = (char *) malloc(CF_BUFSIZE + sizeof(int)); /* Note CF_BUFSIZE not buf_size !! */ n_read_total = 0; while (!done) { if ((size - n_read_total)/buf_size > 0) { toget = towrite = buf_size; } else if (size != 0) { towrite = (size - n_read_total); toget = towrite; } else { toget = towrite = 0; } /* Stage C1 - receive */ if ((n_read = RecvSocketStream(conn->sd,buf,toget,0)) == -1) { DestroyServerConnection(conn); cfPS(cf_error,CF_INTERPT,"recv",pp,attr,"Error in client-server stream"); close(dd); free(buf); return false; } /* If the first thing we get is an error message, break. */ if (n_read_total == 0 && strncmp(buf,CF_FAILEDSTR,strlen(CF_FAILEDSTR)) == 0) { cfPS(cf_inform,CF_INTERPT,"",pp,attr,"Network access to %s:%s denied\n",pp->this_server,source); close(dd); free(buf); return false; } if (strncmp(buf,cfchangedstr,strlen(cfchangedstr)) == 0) { cfPS(cf_inform,CF_INTERPT,"",pp,attr,"Source %s:%s changed while copying\n",pp->this_server,source); close(dd); free(buf); return false; } value = -1; /* Check for mismatch between encryption here and on server - can lead to misunderstanding*/ sscanf(buf,"t %d",&value); if ((value > 0) && strncmp(buf+CF_INBAND_OFFSET,"BAD: ",5) == 0) { cfPS(cf_inform,CF_INTERPT,"",pp,attr,"Network access to cleartext %s:%s denied\n",pp->this_server,source); close(dd); free(buf); return false; } if (!FSWrite(new,dd,buf,towrite,&last_write_made_hole,n_read,attr,pp)) { cfPS(cf_error,CF_FAIL,"",pp,attr," !! Local disk write failed copying %s:%s to %s\n",pp->this_server,source,new); free(buf); unlink(new); close(dd); FlushFileStream(conn->sd,size - n_read_total); EVP_CIPHER_CTX_cleanup(&ctx); return false; } n_read_total += towrite; /* n_read; */ if (n_read_total >= (long)size) /* Handle EOF without closing socket */ { done = true; } } /* If the file ends with a `hole', something needs to be written at the end. Otherwise the kernel would truncate the file at the end of the last write operation. Write a null character and truncate it again. */ if (last_write_made_hole) { if (cf_full_write(dd,"",1) < 0 || ftruncate(dd,n_read_total) < 0) { cfPS(cf_error,CF_FAIL,"",pp,attr,"cf_full_write or ftruncate error in CopyReg, source %s\n",source); free(buf); unlink(new); close(dd); FlushFileStream(conn->sd,size - n_read_total); return false; } } Debug("End of CopyNetReg\n"); close(dd); free(buf); return true; } /*********************************************************************/ int EncryptCopyRegularFileNet(char *source,char *new,off_t size,struct Attributes attr,struct Promise *pp) { int dd, blocksize = 2048,n_read = 0,towrite,plainlen,more = true, finlen,cnt = 0; int last_write_made_hole = 0, tosend,cipherlen=0; char *buf,in[CF_BUFSIZE],out[CF_BUFSIZE],workbuf[CF_BUFSIZE],cfchangedstr[265]; unsigned char iv[32] = {1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8}; long n_read_total = 0; EVP_CIPHER_CTX ctx; struct cfagent_connection *conn = pp->conn; snprintf(cfchangedstr,255,"%s%s",CF_CHANGEDSTR1,CF_CHANGEDSTR2); if ((strlen(new) > CF_BUFSIZE-20)) { cfPS(cf_error,CF_INTERPT,"",pp,attr,"Filename too long"); return false; } unlink(new); /* To avoid link attacks */ if ((dd = open(new,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0600)) == -1) { cfPS(cf_error,CF_INTERPT,"open",pp,attr," !! NetCopy to destination %s:%s security - failed attempt to exploit a race? (Not copied)\n",pp->this_server,new); unlink(new); return false; } if (size == 0) { // No sense in copying an empty file close(dd); return true; } workbuf[0] = '\0'; EVP_CIPHER_CTX_init(&ctx); snprintf(in,CF_BUFSIZE-CF_PROTO_OFFSET,"GET dummykey %s",source); cipherlen = EncryptString(conn->encryption_type,in,out,conn->session_key,strlen(in)+1); snprintf(workbuf,CF_BUFSIZE,"SGET %4d %4d",cipherlen,blocksize); memcpy(workbuf+CF_PROTO_OFFSET,out,cipherlen); tosend=cipherlen+CF_PROTO_OFFSET; /* Send proposition C0 - query */ if (SendTransaction(conn->sd,workbuf,tosend,CF_DONE) == -1) { cfPS(cf_error,CF_INTERPT,"",pp,attr,"Couldn't send data"); close(dd); return false; } buf = (char *) malloc(CF_BUFSIZE + sizeof(int)); n_read_total = 0; while (more) { if ((cipherlen = ReceiveTransaction(conn->sd,buf,&more)) == -1) { DestroyServerConnection(conn); free(buf); return false; } cnt++; /* If the first thing we get is an error message, break. */ if (n_read_total == 0 && strncmp(buf+CF_INBAND_OFFSET,CF_FAILEDSTR,strlen(CF_FAILEDSTR)) == 0) { cfPS(cf_inform,CF_INTERPT,"",pp,attr,"Network access to %s:%s denied\n",pp->this_server,source); close(dd); free(buf); return false; } if (strncmp(buf+CF_INBAND_OFFSET,cfchangedstr,strlen(cfchangedstr)) == 0) { cfPS(cf_inform,CF_INTERPT,"",pp,attr,"Source %s:%s changed while copying\n",pp->this_server,source); close(dd); free(buf); return false; } EVP_DecryptInit_ex(&ctx,CfengineCipher(CfEnterpriseOptions()),NULL,conn->session_key,iv); if (!EVP_DecryptUpdate(&ctx,workbuf,&plainlen,buf,cipherlen)) { Debug("Decryption failed\n"); close(dd); free(buf); return false; } if (!EVP_DecryptFinal_ex(&ctx,workbuf+plainlen,&finlen)) { Debug("Final decrypt failed\n"); close(dd); free(buf); return false; } towrite = n_read = plainlen+finlen; n_read_total += n_read; if (!FSWrite(new,dd,workbuf,towrite,&last_write_made_hole,n_read,attr,pp)) { cfPS(cf_error,CF_FAIL,"",pp,attr," !! Local disk write failed copying %s:%s to %s\n",pp->this_server,source,new); free(buf); unlink(new); close(dd); EVP_CIPHER_CTX_cleanup(&ctx); return false; } } /* If the file ends with a `hole', something needs to be written at the end. Otherwise the kernel would truncate the file at the end of the last write operation. Write a null character and truncate it again. */ if (last_write_made_hole) { if (cf_full_write(dd,"",1) < 0 || ftruncate(dd,n_read_total) < 0) { cfPS(cf_error,CF_FAIL,"",pp,attr,"cf_full_write or ftruncate error in CopyReg, source %s\n",source); free(buf); unlink(new); close(dd); EVP_CIPHER_CTX_cleanup(&ctx); return false; } } close(dd); free(buf); EVP_CIPHER_CTX_cleanup(&ctx); return true; } /*********************************************************************/ /* Level 2 */ /*********************************************************************/ int ServerConnect(struct cfagent_connection *conn,char *host,struct Attributes attr, struct Promise *pp) { short shortport; char strport[CF_MAXVARSIZE] = {0}; struct sockaddr_in cin = {0}; struct timeval tv = {0}; if (attr.copy.portnumber == (short)CF_NOINT) { shortport = SHORT_CFENGINEPORT; strncpy(strport,STR_CFENGINEPORT,CF_MAXVARSIZE); } else { shortport = htons(attr.copy.portnumber); snprintf(strport,CF_MAXVARSIZE,"%u",(int)attr.copy.portnumber); } CfOut(cf_verbose,"","Set cfengine port number to %s = %u\n",strport,(int)ntohs(shortport)); if (attr.copy.timeout == (short)CF_NOINT || attr.copy.timeout <= 0) { tv.tv_sec = CONNTIMEOUT; } else { tv.tv_sec = attr.copy.timeout; } CfOut(cf_verbose,"","Set connection timeout to %d\n",tv.tv_sec); tv.tv_usec = 0; #if defined(HAVE_GETADDRINFO) if (!attr.copy.force_ipv4) { struct addrinfo query = {0}, *response, *ap; struct addrinfo query2 = {0}, *response2, *ap2; int err,connected = false; memset(&query,0,sizeof(query)); query.ai_family = AF_UNSPEC; query.ai_socktype = SOCK_STREAM; if ((err = getaddrinfo(host,strport,&query,&response)) != 0) { cfPS(cf_inform,CF_INTERPT,"",pp,attr," !! Unable to find host or service: (%s/%s) %s",host,strport,gai_strerror(err)); return false; } for (ap = response; ap != NULL; ap = ap->ai_next) { CfOut(cf_verbose,""," -> Connect to %s = %s on port %s\n",host,sockaddr_ntop(ap->ai_addr),strport); if ((conn->sd = socket(ap->ai_family,ap->ai_socktype,ap->ai_protocol)) == -1) { CfOut(cf_inform,"socket"," !! Couldn't open a socket"); continue; } if (BINDINTERFACE[0] != '\0') { memset(&query2,0,sizeof(query2)); query2.ai_family = AF_UNSPEC; query2.ai_socktype = SOCK_STREAM; if ((err = getaddrinfo(BINDINTERFACE,NULL,&query2,&response2)) != 0) { cfPS(cf_error,CF_FAIL,"",pp,attr," !! Unable to lookup hostname or cfengine service: %s",gai_strerror(err)); cf_closesocket(conn->sd); conn->sd = CF_NOT_CONNECTED; return false; } for (ap2 = response2; ap2 != NULL; ap2 = ap2->ai_next) { if (bind(conn->sd, ap2->ai_addr, ap2->ai_addrlen) == 0) { freeaddrinfo(response2); response2 = NULL; break; } } if (response2) { freeaddrinfo(response2); } } if (TryConnect(conn,&tv,ap->ai_addr,ap->ai_addrlen)) { connected = true; break; } } if (connected) { conn->family = ap->ai_family; snprintf(conn->remoteip,CF_MAX_IP_LEN-1,"%s",sockaddr_ntop(ap->ai_addr)); } else { cf_closesocket(conn->sd); conn->sd = CF_NOT_CONNECTED; } if (response != NULL) { freeaddrinfo(response); } if (!connected && pp) { cfPS(cf_verbose,CF_FAIL,"connect",pp,attr," !! Unable to connect to server %s",host); return false; } return true; } else #endif /* ---------------------- only have ipv4 ---------------------------------*/ { struct hostent *hp; memset(&cin,0,sizeof(cin)); if ((hp = gethostbyname(host)) == NULL) { CfOut(cf_error,"gethostbyname"," !! Unable to look up IP address of %s",host); return false; } cin.sin_port = shortport; cin.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr; cin.sin_family = AF_INET; CfOut(cf_verbose,"","Connect to %s = %s, port = (%u=%s)\n",host,inet_ntoa(cin.sin_addr),(int)ntohs(shortport),strport); if ((conn->sd = socket(AF_INET,SOCK_STREAM,0)) == -1) { cfPS(cf_error,CF_INTERPT,"socket",pp,attr,"Couldn't open a socket"); return false; } if (BINDINTERFACE[0] != '\0') { CfOut(cf_verbose,"","Cannot bind interface with this OS.\n"); /* Could fix this - any point? */ } conn->family = AF_INET; snprintf(conn->remoteip,CF_MAX_IP_LEN-1,"%s",inet_ntoa(cin.sin_addr)); return TryConnect(conn,&tv,(struct sockaddr *)&cin,sizeof(cin)); } } /*********************************************************************/ static int ServerOffline(char *server) { struct Rlist *rp; struct ServerItem *svp; char ipname[CF_MAXVARSIZE]; ThreadLock(cft_getaddr); strncpy(ipname,Hostname2IPString(server),CF_MAXVARSIZE-1); ThreadUnlock(cft_getaddr); for (rp = SERVERLIST; rp != NULL; rp=rp->next) { svp = (struct ServerItem *)rp->item; if (svp == NULL) { continue; } if ((strcmp(ipname,svp->server) == 0) && (svp->conn == NULL)) { return true; } } return false; } /*********************************************************************/ /* * We need to destroy connection as it has got an fatal (or non-fatal) error */ void DestroyServerConnection(struct cfagent_connection *conn) { struct Rlist *entry = KeyInRlist(SERVERLIST, conn->remoteip); ServerDisconnection(conn); if (entry != NULL) { entry->item = NULL; /* Has been freed by ServerDisconnection */ DeleteRlistEntry(&SERVERLIST, entry); } } /*********************************************************************/ static struct cfagent_connection *ServerConnectionReady(char *server) { struct Rlist *rp; struct ServerItem *svp; char ipname[CF_MAXVARSIZE]; ThreadLock(cft_getaddr); strncpy(ipname,Hostname2IPString(server),CF_MAXVARSIZE-1); ThreadUnlock(cft_getaddr); for (rp = SERVERLIST; rp != NULL; rp=rp->next) { svp = (struct ServerItem *)rp->item; if (svp == NULL) { continue; } if (svp->busy) { CfOut(cf_verbose,"","Existing connection to %s seems to be active...\n",ipname); return NULL; } if ((strcmp(ipname,svp->server) == 0) && svp->conn && svp->conn->sd > 0) { CfOut(cf_verbose,"","Connection to %s is already open and ready...\n",ipname); svp->busy = true; return svp->conn; } } CfOut(cf_verbose,"","No existing connection to %s is established...\n",ipname); return NULL; } /*********************************************************************/ void ServerNotBusy(struct cfagent_connection *conn) { struct Rlist *rp; struct ServerItem *svp; for (rp = SERVERLIST; rp != NULL; rp=rp->next) { svp = (struct ServerItem *)rp->item; if (svp->conn == conn) { svp->busy = false; break; } } CfOut(cf_verbose,"","Existing connection just became free...\n"); } /*********************************************************************/ static void MarkServerOffline(char *server) /* Unable to contact the server so don't waste time trying for other connections, mark it offline */ { struct Rlist *rp; struct cfagent_connection *conn = NULL; struct ServerItem *svp; char ipname[CF_MAXVARSIZE]; ThreadLock(cft_getaddr); strncpy(ipname,Hostname2IPString(server),CF_MAXVARSIZE-1); ThreadUnlock(cft_getaddr); for (rp = SERVERLIST; rp != NULL; rp=rp->next) { svp = (struct ServerItem *)rp->item; if (svp == NULL) { continue; } conn = svp->conn; if (strcmp(ipname,conn->localip) == 0) { conn->sd = CF_COULD_NOT_CONNECT; return; } } ThreadLock(cft_getaddr); /* If no existing connection, get one .. */ rp = PrependRlist(&SERVERLIST,"nothing",CF_SCALAR); svp = (struct ServerItem *)malloc((sizeof(struct ServerItem))); if (svp == NULL) { return; } if ((svp->server = strdup(ipname)) == NULL) { return; } free(rp->item); rp->item = svp; if ((svp->conn = NewAgentConn())) { /* If we couldn't connect, mark this server unavailable for everyone */ svp->conn->sd = CF_COULD_NOT_CONNECT; } svp->busy = false; ThreadUnlock(cft_getaddr); } /*********************************************************************/ static void CacheServerConnection(struct cfagent_connection *conn,char *server) /* First time we open a connection, so store it */ { struct Rlist *rp; struct ServerItem *svp; char ipname[CF_MAXVARSIZE]; if (!ThreadLock(cft_getaddr)) { exit(1); } strlcpy(ipname,Hostname2IPString(server),CF_MAXVARSIZE); rp = PrependRlist(&SERVERLIST,"nothing",CF_SCALAR); free(rp->item); svp = (struct ServerItem *)malloc((sizeof(struct ServerItem))); rp->item = svp; svp->server = strdup(ipname); svp->conn = conn; svp->busy = true; ThreadUnlock(cft_getaddr); } /*********************************************************************/ static int CacheStat(char *file,struct stat *statbuf,char *stattype,struct Attributes attr,struct Promise *pp) { struct cfstat *sp; Debug("CacheStat(%s)\n",file); for (sp = pp->cache; sp != NULL; sp=sp->next) { if ((strcmp(pp->this_server,sp->cf_server) == 0) && (strcmp(file,sp->cf_filename) == 0)) { if (sp->cf_failed) /* cached failure from cfopendir */ { errno = EPERM; Debug("Cached failure to stat\n"); return -1; } if ((strcmp(stattype,"link") == 0) && (sp->cf_lmode != 0)) { statbuf->st_mode = sp->cf_lmode; } else { statbuf->st_mode = sp->cf_mode; } statbuf->st_uid = sp->cf_uid; statbuf->st_gid = sp->cf_gid; statbuf->st_size = sp->cf_size; statbuf->st_atime = sp->cf_atime; statbuf->st_mtime = sp->cf_mtime; statbuf->st_ctime = sp->cf_ctime; statbuf->st_ino = sp->cf_ino; statbuf->st_nlink = sp->cf_nlink; Debug("Found in cache\n"); return true; } } Debug("Did not find in cache\n"); return false; } /*********************************************************************/ static void FlushFileStream(int sd,int toget) { int i; char buffer[2]; CfOut(cf_inform,"","Flushing rest of file...%d bytes\n",toget); for (i = 0; i < toget; i++) { recv(sd,buffer,1,0); /* flush to end of current file */ } } /*********************************************************************/ static int TryConnect(struct cfagent_connection *conn, struct timeval *tvp, struct sockaddr *cinp, int cinpSz) /** * Tries a nonblocking connect and then restores blocking if * successful. Returns true on success, false otherwise. * NB! Do not use recv() timeout - see note below. **/ #ifdef MINGW { return NovaWin_TryConnect(conn,tvp,cinp,cinpSz); } #else /* NOT MINGW */ { int res; long arg; struct sockaddr_in emptyCin = {0}; #ifdef LINUX struct timeval tvRecv = {0}; #endif if (!cinp) { cinp = (struct sockaddr *)&emptyCin; cinpSz = sizeof(emptyCin); } /* set non-blocking socket */ arg = fcntl(conn->sd, F_GETFL, NULL); if(fcntl(conn->sd, F_SETFL, arg | O_NONBLOCK) == -1) { CfOut(cf_error,"","!! Could not set socket to non-blocking mode"); } res = connect(conn->sd,cinp,cinpSz); if (res < 0) { if (errno == EINPROGRESS) { fd_set myset; int valopt; socklen_t lon = sizeof(int); FD_ZERO(&myset); FD_SET(conn->sd,&myset); /* now wait for connect, but no more than tvp.sec */ res = select(conn->sd + 1, NULL, &myset, NULL, tvp); if(getsockopt(conn->sd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon) != 0) { CfOut(cf_error,"getsockopt","!! Could not check connection status"); return false; } if (valopt || res <= 0) { CfOut(cf_inform,"connect"," !! Error connecting to server (timeout)"); return false; } } else { CfOut(cf_inform,"connect"," !! Error connecting to server"); return false; } } /* connection suceeded; return to blocking mode */ if(fcntl(conn->sd, F_SETFL, arg) == -1) { CfOut(cf_error,"","!! Could not set socket to blocking mode"); } /* * NB: recv() timeout is not portable. struct timeval is very * unstable - interpreted differently on different * platforms. E.g. setting tv_sec to 50 (and tv_usec to 0) * results in a timeout of 0.5 seconds on Windows, but 50 * seconds on Linux. Thus it must be tested thoroughly on * the affected platforms. */ #ifdef LINUX tvRecv.tv_sec = RECVTIMEOUT; tvRecv.tv_usec = 0; if (setsockopt(conn->sd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tvRecv, sizeof(tvRecv))) { CfOut(cf_error,"setsockopt","!! Couldn't set socket timeout"); } #endif return true; } #endif /* NOT MINGW */ ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/mod_defaults.c�������������������������������������������������������������������0000644�0001750�0001750�00000014417�11715232734�013634� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_defaults.c */ /* */ /*****************************************************************************/ #define CF3_MOD_DEFAULTS #include "cf3.defs.h" #include "cf3.extern.h" struct BodyDefault CONTROL_DEFAULT[] = { {"ignore_missing_bundles","false"}, {"ignore_missing_inputs","false"}, {"lastseenexpireafter","One week"}, {"require_comments","false"}, {"host_licenses_paid","0"}, {"syslog_port","514"}, {"agentfacility","LOG_USER"}, {"auditing","false"}, {"binarypaddingchar","space (ASC=32)"}, {"hashupdates","false"}, {"checksum_alert_time","10 mins"}, {"defaultcopytype","ctime or mtime differ"}, {"dryrun","false"}, {"editbinaryfilesize","100000"}, {"editfilesize","10000"}, {"exclamation","true"}, {"expireafter","1 min"}, {"execresult_newlines","false"}, {"hostnamekeys","false"}, {"ifelapsed","1"}, {"inform","false"}, {"intermittency","false"}, {"max_children","1 concurrent agent promise"}, {"maxconnections","30 remote queries"}, {"mountfilesystems","false"}, {"move_obstructions","false"}, {"nonalphanumfiles","false"}, {"repchar","_"}, {"default_repository","in situ"}, {"secureinput","false"}, {"sensiblecount","2 files"}, {"sensiblesize","1000 bytes"}, {"skipidentify","false"}, {"syslog","false"}, {"track_value","false"}, {"default_timeout","10 seconds"}, {"verbose","false"}, {"denybadclocks","true"}, {"logallconnections","false"}, {"logencryptedtransfers","false"}, {"serverfacility","LOG_USER"}, {"port","5308"}, {"forgetrate","0.6"}, {"monitorfacility","LOG_USER"}, {"histograms","true"}, {"tcpdump","false"}, {"force_ipv4","false"}, {"trustkey","false"}, {"encrypt","false"}, {"background_children","false"}, {"max_children","50 runagents"}, {"output_to_file","false"}, {"splaytime","0"}, {"mailmaxlines","30"}, {"executorfacility","LOG_USER"}, {"build_directory","Current working directory"}, {"generate_manual","false"}, {"view_projections","false"}, {"auto_scaling","true"}, {"error_bars","true"}, {"reports","none"}, {"report_output","none"}, {"time_stamps","false"}, {NULL,NULL}, }; /*****************************************************************************/ struct BodyDefault BODY_DEFAULT[] = { {"ifelapsed","control body value"}, {"expireafter","control body value"}, {"background","false"}, {"report_level","(none)"}, {"audit","false"}, {"timer_policy","reset"}, {"before_after","after"}, {"first_last","last"}, {"allow_blank_fields","false"}, {"extend_fields","false"}, {"field_operation","none"}, {"field_separator","none"}, {"value_separator","none"}, {"occurrences","all"}, {"expand_scalars","false"}, {"insert_type","literal"}, {"not_matching","false"}, {"traverse_links","false"}, {"xdev","false"}, {"rmdeadlinks","false"}, {"empty_file_before_editing","false"}, {"edit_backup","true"}, {"disable","false"}, {"link_children","false"}, {"encrypt","false"}, {"link_type","symlink"}, {"when_no_source","nop"}, {"compare","mtime or ctime differs"}, {"force_update","false"}, {"force_ipv4","false"}, {"preserve","false"}, {"purge","false"}, {"trustkey","false"}, {"typecheck","false"}, {"verify","false"}, {"useshell","false"}, {"preview","false"}, {"no_output","false"}, {"module","false"}, {"package_policy","verify"}, {"package_accept_returncodes","unset (ignored)"}, {"check_foreign","false"}, {"scan_arrivals","false"}, {"edit_fstab","false"}, {"unmount","false"}, {"database_type","none"}, {"db_server_type","none"}, {"ifencrypted","false"}, {"create","false"}, {"insert_match_policy","exact_match"}, {"recognize_join","false"}, {"include_start_delimiter","false"}, {"include_end_delimiter","false"}, {"output_level","verbose"}, {"promiser_type","promise"}, {"keycacheTTL","24"}, {"copy_backup","true"}, {"copy_size","any size range"}, {"stealth","false"}, {"fips_mode","false"}, {"select_class","random_selection"}, {NULL,NULL}, }; /*****************************************************************************/ char *GetControlDefault(char *bodypart) { int i; for (i = 0; CONTROL_DEFAULT[i].lval != NULL; i++) { if (strcmp(CONTROL_DEFAULT[i].lval,bodypart) == 0) { return CONTROL_DEFAULT[i].rval; } } return NULL; } /*****************************************************************************/ char *GetBodyDefault(char *bodypart) { int i; for (i = 0; BODY_DEFAULT[i].lval != NULL; i++) { if (strcmp(BODY_DEFAULT[i].lval,bodypart) == 0) { return BODY_DEFAULT[i].rval; } } return NULL; } /*****************************************************************************/ /* Now a list of features in editions */ /*****************************************************************************/ // All // Nova, Constellation and Galaxy // Constellation and Galaxy // Galaxy �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/dbm_tokyocab.c�������������������������������������������������������������������0000644�0001750�0001750�00000015617�11715232734�013626� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: dbm_tokyocab.c */ /* */ /*****************************************************************************/ /* * Implementation of the Cfengine DBM API using Tokyo Cabinet hash API. */ #include "cf3.defs.h" #include "cf3.extern.h" /* Arbitrary cutoff while trying to open blocked database */ #define MAXATTEMPTS 1000 static long GetSleepTime(void); #ifdef TCDB /*****************************************************************************/ int TCDB_OpenDB(char *filename, CF_TCDB **hdbp) { int attempts = MAXATTEMPTS; *hdbp = xcalloc(1, sizeof(CF_TCDB)); (*hdbp)->hdb = tchdbnew(); while (attempts--) { /* * Note: tchdbsetmutex is not called before tchdbopen, so the created * connection must not be shared by a several threads. */ if (tchdbopen((*hdbp)->hdb, filename, HDBOWRITER | HDBOCREAT)) { return true; } int err_code = tchdbecode((*hdbp)->hdb); if (err_code != TCETHREAD) { CfOut(cf_error, "", "!! tchdbopen: Unable to open database \"%s\": %s", filename, tchdberrmsg(err_code)); tchdbdel((*hdbp)->hdb); free(*hdbp); return false; } struct timespec ts = { .tv_nsec = GetSleepTime() }; nanosleep(&ts, NULL); } CfOut(cf_error, "", "!! TCDB_OpenDB: Unable to lock database \"%s\", lock is held by another thread", filename); tchdbdel((*hdbp)->hdb); free(*hdbp); return false; } /*****************************************************************************/ int TCDB_CloseDB(CF_TCDB *hdbp) { int errCode; char buf[CF_MAXVARSIZE]; snprintf(buf, sizeof(buf), "CloseDB(%s)\n", tchdbpath(hdbp->hdb)); Debug(buf); if (!tchdbclose(hdbp->hdb)) { errCode = tchdbecode(hdbp->hdb); CfOut(cf_error, "", "!! tchdbclose: Closing database failed: %s", tchdberrmsg(errCode)); return false; } tchdbdel(hdbp->hdb); if (hdbp->valmemp != NULL) { free(hdbp->valmemp); } free(hdbp); hdbp = NULL; return true; } /*****************************************************************************/ int TCDB_ValueSizeDB(CF_TCDB *hdbp, char *key) { return tchdbvsiz2(hdbp->hdb, key); } /*****************************************************************************/ int TCDB_ReadComplexKeyDB(CF_TCDB *hdbp, char *key, int keySz,void *dest, int destSz) { int errCode; if (tchdbget3(hdbp->hdb, key, keySz, dest, destSz) == -1) { errCode = tchdbecode(hdbp->hdb); Debug("TCDB_ReadComplexKeyDB(%s): Could not read: %s\n", key, tchdberrmsg(errCode)); return false; } return true; } /*****************************************************************************/ int TCDB_RevealDB(CF_TCDB *hdbp, char *key, void **result, int *rsize) { int errCode; if (hdbp->valmemp != NULL) { free(hdbp->valmemp); hdbp->valmemp = NULL; } *result = tchdbget(hdbp->hdb, key, strlen(key), rsize); if (*result == NULL) { errCode = tchdbecode(hdbp->hdb); Debug("TCDB_RevealDB(%s): Could not read: %s\n", key, tchdberrmsg(errCode)); return false; } hdbp->valmemp = *result; // keep allocated address for later free return true; } /*****************************************************************************/ int TCDB_WriteComplexKeyDB(CF_TCDB *hdbp, char *key, int keySz, const void *src, int srcSz) { int errCode; int res; res = tchdbput(hdbp->hdb, key, keySz, src, srcSz); if (!res) { errCode = tchdbecode(hdbp->hdb); CfOut(cf_error, "", "!! tchdbput: Could not write key to DB \"%s\": %s", tchdbpath(hdbp->hdb), tchdberrmsg(errCode)); return false; } return true; } /*****************************************************************************/ int TCDB_DeleteComplexKeyDB(CF_TCDB *hdbp, char *key, int size) { int errCode; if (!tchdbout(hdbp->hdb, key, size)) { errCode = tchdbecode(hdbp->hdb); Debug("TCDB_DeleteComplexKeyDB(%s): Could not delete key: %s\n", key, tchdberrmsg(errCode)); return false; } return true; } /*****************************************************************************/ int TCDB_NewDBCursor(CF_TCDB *hdbp,CF_TCDBC **hdbcp) { int errCode; if (!tchdbiterinit(hdbp->hdb)) { errCode = tchdbecode(hdbp->hdb); CfOut(cf_error, "", "!! tchdbiterinit: Could not initialize iterator: %s", tchdberrmsg(errCode)); return false; } *hdbcp = xcalloc(1, sizeof(CF_TCDBC)); return true; } /*****************************************************************************/ int TCDB_NextDB(CF_TCDB *hdbp,CF_TCDBC *hdbcp,char **key,int *ksize,void **value,int *vsize) { int errCode; if (hdbcp->curkey != NULL) { free(hdbcp->curkey); hdbcp->curkey = NULL; } if(hdbcp->curval != NULL) { free(hdbcp->curval); hdbcp->curval = NULL; } *key = tchdbiternext(hdbp->hdb, ksize); if (*key == NULL) { Debug("Got NULL-key in TCDB_NextDB()\n"); return false; } *value = tchdbget(hdbp->hdb, *key, *ksize, vsize); if (*value == NULL) { free(*key); *key = NULL; errCode = tchdbecode(hdbp->hdb); CfOut(cf_error, "", "!! tchdbget: Could not get value corrsponding to key \"%s\": %s", key, tchdberrmsg(errCode)); return false; } // keep pointers for later free hdbcp->curkey = *key; hdbcp->curval = *value; return true; } /*****************************************************************************/ int TCDB_DeleteDBCursor(CF_TCDB *hdbp,CF_TCDBC *hdbcp) { if (hdbcp->curkey != NULL) { free(hdbcp->curkey); hdbcp->curkey = NULL; } if (hdbcp->curval != NULL) { free(hdbcp->curval); hdbcp->curval = NULL; } free(hdbcp); return true; } /*****************************************************************************/ /* * 10^7 usec +- 10^7 usec */ static long GetSleepTime(void) { return lrand48() % (2*10*1000*1000); } #endif �����������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/alphalist.c����������������������������������������������������������������������0000644�0001750�0001750�00000012151�11715232734�013140� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ /* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: alphalist.c */ /* */ /* Created: Fri Dec 3 10:26:22 2010 */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void ShowAlphaList(struct AlphaList al); /*****************************************************************************/ /* This library creates a simple indexed array of lists for optimization of high entropy class searches. struct AlphaList al; struct Item *ip; int i; InitAlphaList(&al); PrependAlphaList(&al,"one"); PrependAlphaList(&al,"two"); PrependAlphaList(&al,"three"); PrependAlphaList(&al,"onetwo"); VERBOSE = 1; ShowAlphaList(al); exit(0); */ /*****************************************************************************/ void InitAlphaList(struct AlphaList *al) { int i; for (i = 0; i < CF_ALPHABETSIZE; i++) { al->list[i] = NULL; } } /*****************************************************************************/ void DeleteAlphaList(struct AlphaList *al) { int i; for (i = 0; i < CF_ALPHABETSIZE; i++) { DeleteItemList(al->list[i]); al->list[i] = NULL; } } /*****************************************************************************/ struct AlphaList *CopyAlphaListPointers(struct AlphaList *ap,struct AlphaList *al) { int i; if (ap != NULL) { for (i = 0; i < CF_ALPHABETSIZE; i++) { ap->list[i] = al->list[i]; } } return ap; } /*****************************************************************************/ int InAlphaList(struct AlphaList al,const char *string) { int i = (int)*string; return IsItemIn(al.list[i],string); } /*****************************************************************************/ int MatchInAlphaList(struct AlphaList al,char *string) { struct Item *ip; int i = (int)*string; if (isalnum(i) || *string == '_') { for (ip = al.list[i]; ip != NULL; ip=ip->next) { if (FullTextMatch(string,ip->name)) { return true; } } } else { // We don't know what the correct hash is because the pattern in vague for (i = 0; i < CF_ALPHABETSIZE; i++) { for (ip = al.list[i]; ip != NULL; ip=ip->next) { if (FullTextMatch(string,ip->name)) { return true; } } } } return false; } /*****************************************************************************/ void PrependAlphaList(struct AlphaList *al, const char *string) { int i = (int)*string; al->list[i] = PrependItem(&(al->list[i]),string,NULL); } /*****************************************************************************/ void IdempPrependAlphaList(struct AlphaList *al, const char *string) { if (!InAlphaList(*al, string)) { PrependAlphaList(al, string); } } /*****************************************************************************/ static void ShowAlphaList(struct AlphaList al) { int i; struct Item *ip; if (!(VERBOSE||DEBUG)) { return; } for (i = 0; i < CF_ALPHABETSIZE; i++) { if (al.list[i] == NULL) { } else { printf("%c :",(char)i); for (ip = al.list[i]; ip != NULL; ip=ip->next) { printf(" %s",ip->name); } printf("\n"); } } } /*****************************************************************************/ void ListAlphaList(FILE *fout,struct AlphaList al,char sep) { int i; struct Item *ip; for (i = 0; i < CF_ALPHABETSIZE; i++) { if (al.list[i] == NULL) { } else { for (ip = al.list[i]; ip != NULL; ip=ip->next) { if (!IsItemIn(VNEGHEAP,ip->name)) { fprintf(fout,"%s%c",ip->name,sep); } } } } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/scope.c��������������������������������������������������������������������������0000644�0001750�0001750�00000021351�11715232734�012272� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: scope.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void DebugVariables(char *label); /*******************************************************************/ static void DebugVariables(char *label) /* * Not thread safe */ { struct Scope *ptr; printf("----------------------%s ---------------------------\n",label); for (ptr = VSCOPE; ptr != NULL; ptr=ptr->next) { printf("\nConstant variables in SCOPE %s:\n",ptr->scope); PrintHashes(stdout,ptr->hashtable,0); } printf("--------------------------------------------------\n"); } /*******************************************************************/ struct Scope *GetScope(char *scope) /* * Not thread safe - returns pointer to global memory */ { struct Scope *cp = NULL; Debug("Searching for scope context %s\n",scope); for (cp = VSCOPE; cp != NULL; cp=cp->next) { if (strcmp(cp->scope,scope) == 0) { Debug("Found scope reference %s\n",scope); return cp; } } return NULL; } /*******************************************************************/ void SetScope(char *id) { strncpy(CONTEXTID,id,31); } /*******************************************************************/ void SetNewScope(char *id) { NewScope(id); strncpy(CONTEXTID,id,31); } /*******************************************************************/ void NewScope(char *name) /* * Thread safe */ { struct Scope *ptr; Debug("Adding scope data %s\n", name); if (!ThreadLock(cft_vscope)) { CfOut(cf_error, "", "!! Could not lock VSCOPE"); return; } for (ptr = VSCOPE; ptr != NULL; ptr=ptr->next) { if (strcmp(ptr->scope,name) == 0) { ThreadUnlock(cft_vscope); Debug("SCOPE Object %s already exists\n",name); return; } } if ((ptr = (struct Scope *)malloc(sizeof(struct Scope))) == NULL) { FatalError("Memory Allocation failed for Scope"); } InitHashes(ptr->hashtable); ptr->next = VSCOPE; ptr->scope = strdup(name); VSCOPE = ptr; ThreadUnlock(cft_vscope); } /*******************************************************************/ void AugmentScope(char *scope,struct Rlist *lvals,struct Rlist *rvals) { struct Scope *ptr; struct Rlist *rpl,*rpr; struct Rval retval; char *lval,naked[CF_BUFSIZE]; HashIterator i; struct CfAssoc *assoc; if (RlistLen(lvals) != RlistLen(rvals)) { CfOut(cf_error,"","While constructing scope \"%s\"\n",scope); fprintf(stderr,"Formal = "); ShowRlist(stderr,lvals); fprintf(stderr,", Actual = "); ShowRlist(stderr,rvals); fprintf(stderr,"\n"); FatalError("Augment scope, formal and actual parameter mismatch is fatal"); } for (rpl = lvals, rpr=rvals; rpl != NULL; rpl = rpl->next,rpr = rpr->next) { lval = (char *)rpl->item; CfOut(cf_verbose,""," ? Augment scope %s with %s (%c)\n",scope,lval,rpr->type); // CheckBundleParameters() already checked that there is no namespace collision // By this stage all functions should have been expanded, so we only have scalars left if (IsNakedVar(rpr->item,'@')) { enum cfdatatype vtype; GetNaked(naked,rpr->item); vtype = GetVariable(scope,naked,&(retval.item),&(retval.rtype)); switch(vtype) { case cf_slist: case cf_ilist: case cf_rlist: NewList(scope,lval,CopyRvalItem(retval.item,CF_LIST),cf_slist); break; default: CfOut(cf_error,""," !! List parameter \"%s\" not found while constructing scope \"%s\" - use @(scope.variable) in calling reference",naked,scope); NewScalar(scope,lval,rpr->item,cf_str); break; } } else { NewScalar(scope,lval,rpr->item,cf_str); } } /* Check that there are no danglers left to evaluate in the hash table itself */ ptr = GetScope(scope); i = HashIteratorInit(ptr->hashtable); while ((assoc = HashIteratorNext(&i))) { retval = ExpandPrivateRval(scope,(char *)(assoc->rval),assoc->rtype); // Retain the assoc, just replace rval DeleteRvalItem(assoc->rval,assoc->rtype); assoc->rval = retval.item; assoc->rtype = retval.rtype; } return; } /*******************************************************************/ void DeleteAllScope() { struct Scope *ptr, *this; Debug("Deleting all scoped variables\n"); if (!ThreadLock(cft_vscope)) { CfOut(cf_error, "", "!! Could not lock VSCOPE"); return; } ptr = VSCOPE; while (ptr != NULL) { this = ptr; Debug(" -> Deleting scope %s\n",ptr->scope); DeleteHashes(this->hashtable); free(this->scope); ptr = this->next; free((char *)this); } VSCOPE = NULL; ThreadUnlock(cft_vscope); } /*******************************************************************/ void DeleteScope(char *name) /* * Thread safe */ { struct Scope *ptr, *prev = NULL; int found = false; Debug1("Deleting scope %s\n", name); if (!ThreadLock(cft_vscope)) { CfOut(cf_error, "", "!! Could not lock VSCOPE"); return; } for (ptr = VSCOPE; ptr != NULL; ptr=ptr->next) { if (strcmp(ptr->scope,name) == 0) { Debug("Object %s exists\n",name); found = true; break; } else { prev = ptr; } } if (!found) { Debug("No such scope to delete\n"); ThreadUnlock(cft_vscope); return; } if (ptr == VSCOPE) { VSCOPE = ptr->next; } else { prev->next = ptr->next; } DeleteHashes(ptr->hashtable); free(ptr->scope); free((char *)ptr); ThreadUnlock(cft_vscope); } /*******************************************************************/ void DeleteFromScope(char *scope,struct Rlist *args) { struct Rlist *rp; char *lval; for (rp = args; rp != NULL; rp=rp->next) { lval = (char *)rp->item; DeleteScalar(scope,lval); } } /*******************************************************************/ void CopyScope(char *new, char *old) /* * Thread safe */ { struct Scope *op, *np; Debug("\n*\nCopying scope data %s to %s\n*\n",old,new); NewScope(new); if (!ThreadLock(cft_vscope)) { CfOut(cf_error, "", "!! Could not lock VSCOPE"); return; } if ((op = GetScope(old))) { np = GetScope(new); CopyHashes(np->hashtable,op->hashtable); } ThreadUnlock(cft_vscope); } /*******************************************************************/ void ShowScope(char *name) /* * Not thread safe - access to global variable */ { struct Scope *ptr; for (ptr = VSCOPE; ptr != NULL; ptr=ptr->next) { if (name && strcmp(ptr->scope,name) != 0) { continue; } printf("\nConstant variables in SCOPE %s:\n",ptr->scope); PrintHashes(stdout,ptr->hashtable,0); } } /*******************************************************************/ /* Stack frames */ /*******************************************************************/ void PushThisScope() { struct Scope *op; char name[CF_MAXVARSIZE]; op = GetScope("this"); if (op == NULL) { return; } CF_STCKFRAME++; PushStack(&CF_STCK,(void *)op); snprintf(name,CF_MAXVARSIZE,"this_%d",CF_STCKFRAME); free(op->scope); op->scope = strdup(name); } /*******************************************************************/ void PopThisScope() { struct Scope *op = NULL; if (CF_STCKFRAME > 0) { DeleteScope("this"); PopStack(&CF_STCK,(void *)&op,sizeof(op)); if (op == NULL) { return; } CF_STCKFRAME--; free(op->scope); op->scope = strdup("this"); } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/files_repository.c���������������������������������������������������������������0000644�0001750�0001750�00000006663�11715232734�014573� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: files_repository.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*********************************************************************/ int ArchiveToRepository(char *file,struct Attributes attr,struct Promise *pp) /* Returns true if the file was backup up and false if not */ { char destination[CF_BUFSIZE]; char localrepository[CF_BUFSIZE]; char node[CF_BUFSIZE]; struct stat sb, dsb; char *sp; if (attr.repository == NULL && VREPOSITORY == NULL) { return false; } if (attr.repository != NULL) { strncpy(localrepository,attr.repository,CF_BUFSIZE); } else if (VREPOSITORY != NULL) { strncpy(localrepository,VREPOSITORY,CF_BUFSIZE); } if (attr.copy.backup == cfa_nobackup) { return true; } if (IsItemIn(VREPOSLIST,file)) { CfOut(cf_inform,"","The file %s has already been moved to the repository once. Multiple update will cause loss of backup.",file); return true; } ThreadLock(cft_getaddr); PrependItemList(&VREPOSLIST,file); ThreadUnlock(cft_getaddr); Debug("Repository(%s)\n",file); strcpy (node,file); destination[0] = '\0'; for (sp = node; *sp != '\0'; sp++) { if (*sp == FILE_SEPARATOR) { *sp = REPOSCHAR; } } strncpy(destination,localrepository,CF_BUFSIZE-2); if (!JoinPath(destination,node)) { CfOut(cf_error,"","Internal limit: Buffer ran out of space for long filename\n"); return false; } if (!MakeParentDirectory(destination,attr.move_obstructions)) { } if (cfstat(file,&sb) == -1) { Debug("File %s promised to archive to the repository but it disappeared!\n",file); return true; } cfstat(destination,&dsb); attr.copy.servers = NULL; attr.copy.backup = cfa_repos_store; // cfa_nobackup; attr.copy.stealth = false; attr.copy.verify = false; attr.copy.preserve = false; CheckForFileHoles(&sb,pp); if (CopyRegularFileDisk(file,destination,attr,pp)) { CfOut(cf_inform,"","Moved %s to repository location %s\n",file,destination); return true; } else { CfOut(cf_inform,"","Failed to move %s to repository location %s\n",file,destination); return false; } } �����������������������������������������������������������������������������cfengine-3.2.4/src/verify_interfaces.c��������������������������������������������������������������0000644�0001750�0001750�00000003604�11715232734�014671� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: verify_interfaces.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*****************************************************************************/ void VerifyInterfacesPromise(struct Promise *pp) { struct Attributes a = {{0}}; a = GetInterfacesAttributes(pp); VerifyInterface(a,pp); DeleteScalar("this","promiser"); } /*****************************************************************************/ void VerifyInterface(struct Attributes a,struct Promise *pp) { /* How shall we deal with this now ? */ printf("NOT YET IMPLEMENTED\n"); } ����������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/Makefile.in����������������������������������������������������������������������0000644�0001750�0001750�00000503753�11715232775�013102� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Makefile.in generated by automake 1.11.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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@ target_triplet = @target@ sbin_PROGRAMS = cf-know$(EXEEXT) cf-promises$(EXEEXT) \ cf-agent$(EXEEXT) cf-monitord$(EXEEXT) cf-serverd$(EXEEXT) \ cf-execd$(EXEEXT) cf-runagent$(EXEEXT) cf-key$(EXEEXT) \ cf-report$(EXEEXT) $(am__EXEEXT_1) @HAVE_NOVA_TRUE@am__append_1 = cf-hub @HAVE_NOVA_TRUE@am__append_2 = ../nova/src/libcfmonitord.la subdir = src DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/cf3lex.l.in \ $(srcdir)/conf.h.in cf3lex.c cf3parse.c cf3parse.h ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \ $(top_srcdir)/m4/cf3_with_library.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 = conf.h CONFIG_CLEAN_FILES = cf3lex.l 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(sbindir)" LTLIBRARIES = $(lib_LTLIBRARIES) am_libpromises_la_OBJECTS = libpromises_la-cf3parse.lo \ libpromises_la-cf3lex.lo libpromises_la-alloc.lo \ libpromises_la-patches.lo libpromises_la-attributes.lo \ libpromises_la-install.lo libpromises_la-generic_agent.lo \ libpromises_la-dbm_api.lo libpromises_la-dbm_berkeley.lo \ libpromises_la-dbm_quick.lo libpromises_la-dbm_tokyocab.lo \ libpromises_la-dbm_sqlite3.lo libpromises_la-dir.lo \ libpromises_la-dtypes.lo libpromises_la-classes.lo \ libpromises_la-env_context.lo \ libpromises_la-string_expressions.lo \ libpromises_la-logic_expressions.lo \ libpromises_la-files_interfaces.lo \ libpromises_la-files_properties.lo \ libpromises_la-files_select.lo \ libpromises_la-files_operators.lo \ libpromises_la-files_repository.lo \ libpromises_la-files_copy.lo libpromises_la-files_editline.lo \ libpromises_la-files_edit.lo libpromises_la-files_links.lo \ libpromises_la-files_hashes.lo libpromises_la-files_names.lo \ libpromises_la-chflags.lo libpromises_la-modes.lo \ libpromises_la-exec_tools.lo libpromises_la-nfs.lo \ libpromises_la-item-lib.lo libpromises_la-alphalist.lo \ libpromises_la-cf_sql.lo libpromises_la-client_protocol.lo \ libpromises_la-client_code.lo libpromises_la-communication.lo \ libpromises_la-net.lo libpromises_la-sockaddr.lo \ libpromises_la-recursion.lo libpromises_la-processes_select.lo \ libpromises_la-fncall.lo libpromises_la-cf3globals.lo \ libpromises_la-reporting.lo libpromises_la-evalfunction.lo \ libpromises_la-sysinfo.lo libpromises_la-conversion.lo \ libpromises_la-scope.lo libpromises_la-assoc.lo \ libpromises_la-comparray.lo libpromises_la-vars.lo \ libpromises_la-args.lo libpromises_la-hashes.lo \ libpromises_la-crypto.lo libpromises_la-sort.lo \ libpromises_la-keyring.lo libpromises_la-full-write.lo \ libpromises_la-expand.lo libpromises_la-matching.lo \ libpromises_la-selfdiagnostic.lo \ libpromises_la-instrumentation.lo libpromises_la-granules.lo \ libpromises_la-timeout.lo libpromises_la-promises.lo \ libpromises_la-ontology.lo libpromises_la-constraints.lo \ libpromises_la-iteration.lo libpromises_la-rlist.lo \ libpromises_la-syntax.lo libpromises_la-logging.lo \ libpromises_la-signals.lo libpromises_la-transaction.lo \ libpromises_la-cfstream.lo libpromises_la-pipes.lo \ libpromises_la-html.lo libpromises_la-interfaces.lo \ libpromises_la-storage_tools.lo \ libpromises_la-verify_reports.lo \ libpromises_la-verify_processes.lo \ libpromises_la-enterprise_stubs.lo libpromises_la-bootstrap.lo \ libpromises_la-mod_defaults.lo libpromises_la-mod_common.lo \ libpromises_la-mod_access.lo libpromises_la-mod_exec.lo \ libpromises_la-mod_methods.lo libpromises_la-mod_interfaces.lo \ libpromises_la-mod_packages.lo libpromises_la-mod_files.lo \ libpromises_la-mod_report.lo libpromises_la-mod_storage.lo \ libpromises_la-mod_knowledge.lo \ libpromises_la-mod_measurement.lo \ libpromises_la-mod_databases.lo libpromises_la-mod_services.lo \ libpromises_la-mod_process.lo libpromises_la-mod_environ.lo \ libpromises_la-mod_outputs.lo libpromises_la-unix.lo libpromises_la_OBJECTS = $(am_libpromises_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libpromises_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(libpromises_la_CFLAGS) $(CFLAGS) $(libpromises_la_LDFLAGS) \ $(LDFLAGS) -o $@ @HAVE_NOVA_TRUE@am__EXEEXT_1 = cf-hub$(EXEEXT) PROGRAMS = $(sbin_PROGRAMS) am_cf_agent_OBJECTS = agent.$(OBJEXT) verify_files.$(OBJEXT) \ verify_storage.$(OBJEXT) verify_exec.$(OBJEXT) \ verify_methods.$(OBJEXT) verify_interfaces.$(OBJEXT) \ verify_packages.$(OBJEXT) verify_databases.$(OBJEXT) \ verify_services.$(OBJEXT) verify_environments.$(OBJEXT) \ agentdiagnostic.$(OBJEXT) cf_agent_OBJECTS = $(am_cf_agent_OBJECTS) cf_agent_LDADD = $(LDADD) cf_agent_DEPENDENCIES = libpromises.la am_cf_execd_OBJECTS = exec.$(OBJEXT) cf_execd_OBJECTS = $(am_cf_execd_OBJECTS) cf_execd_LDADD = $(LDADD) cf_execd_DEPENDENCIES = libpromises.la am_cf_hub_OBJECTS = cf_hub_OBJECTS = $(am_cf_hub_OBJECTS) @HAVE_NOVA_TRUE@cf_hub_DEPENDENCIES = ../nova/src/libcfhub.la \ @HAVE_NOVA_TRUE@ libpromises.la am_cf_key_OBJECTS = cfkey.$(OBJEXT) cf_key_OBJECTS = $(am_cf_key_OBJECTS) cf_key_LDADD = $(LDADD) cf_key_DEPENDENCIES = libpromises.la am_cf_know_OBJECTS = cfknow.$(OBJEXT) manual.$(OBJEXT) cf_know_OBJECTS = $(am_cf_know_OBJECTS) cf_know_LDADD = $(LDADD) cf_know_DEPENDENCIES = libpromises.la am_cf_monitord_OBJECTS = verify_measurements.$(OBJEXT) \ env_monitor.$(OBJEXT) mon_cpu.$(OBJEXT) mon_disk.$(OBJEXT) \ mon_entropy.$(OBJEXT) mon_load.$(OBJEXT) \ mon_network_sniffer.$(OBJEXT) mon_network.$(OBJEXT) \ mon_processes.$(OBJEXT) mon_temp.$(OBJEXT) monitor.$(OBJEXT) cf_monitord_OBJECTS = $(am_cf_monitord_OBJECTS) cf_monitord_DEPENDENCIES = libpromises.la $(am__append_2) am_cf_promises_OBJECTS = cfpromises.$(OBJEXT) cf_promises_OBJECTS = $(am_cf_promises_OBJECTS) cf_promises_LDADD = $(LDADD) cf_promises_DEPENDENCIES = libpromises.la am_cf_report_OBJECTS = cfreport.$(OBJEXT) cf_report_OBJECTS = $(am_cf_report_OBJECTS) cf_report_LDADD = $(LDADD) cf_report_DEPENDENCIES = libpromises.la am_cf_runagent_OBJECTS = runagent.$(OBJEXT) cf_runagent_OBJECTS = $(am_cf_runagent_OBJECTS) cf_runagent_LDADD = $(LDADD) cf_runagent_DEPENDENCIES = libpromises.la am_cf_serverd_OBJECTS = server.$(OBJEXT) server_transform.$(OBJEXT) cf_serverd_OBJECTS = $(am_cf_serverd_OBJECTS) cf_serverd_LDADD = $(LDADD) cf_serverd_DEPENDENCIES = libpromises.la DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 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 " $@; @MAINTAINER_MODE_FALSE@am__skiplex = test -f $@ || LEXCOMPILE = $(LEX) $(AM_LFLAGS) $(LFLAGS) LTLEXCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(LEX) $(AM_LFLAGS) $(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 @MAINTAINER_MODE_FALSE@am__skipyacc = test -f $@ || YACCCOMPILE = $(YACC) $(AM_YFLAGS) $(YFLAGS) LTYACCCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(YACC) $(AM_YFLAGS) $(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 = $(libpromises_la_SOURCES) $(cf_agent_SOURCES) \ $(cf_execd_SOURCES) $(cf_hub_SOURCES) $(cf_key_SOURCES) \ $(cf_know_SOURCES) $(cf_monitord_SOURCES) \ $(cf_promises_SOURCES) $(cf_report_SOURCES) \ $(cf_runagent_SOURCES) $(cf_serverd_SOURCES) DIST_SOURCES = $(libpromises_la_SOURCES) $(cf_agent_SOURCES) \ $(cf_execd_SOURCES) $(cf_hub_SOURCES) $(cf_key_SOURCES) \ $(cf_know_SOURCES) $(cf_monitord_SOURCES) \ $(cf_promises_SOURCES) $(cf_report_SOURCES) \ $(cf_runagent_SOURCES) $(cf_serverd_SOURCES) HEADERS = $(noinst_HEADERS) 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@ BERKELEYDB_CFLAGS = @BERKELEYDB_CFLAGS@ BERKELEYDB_LDFLAGS = @BERKELEYDB_LDFLAGS@ BERKELEYDB_LIBS = @BERKELEYDB_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EIGHTBIT = @EIGHTBIT@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GCC_CFLAG = @GCC_CFLAG@ GETCONF = @GETCONF@ GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ GREP = @GREP@ HOSTNAME = @HOSTNAME@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ KMEM_GROUP = @KMEM_GROUP@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_SELINUX = @LIB_SELINUX@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MYSQL_CFLAGS = @MYSQL_CFLAGS@ MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@ MYSQL_LDFLAGS = @MYSQL_LDFLAGS@ MYSQL_LIBS = @MYSQL_LIBS@ MYSQL_PATH = @MYSQL_PATH@ NEED_SETGID = @NEED_SETGID@ NM = @NM@ NMEDIT = @NMEDIT@ NOWRAP = @NOWRAP@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_CPPFLAGS = @OPENSSL_CPPFLAGS@ OPENSSL_LDFLAGS = @OPENSSL_LDFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OPENSSL_PATH = @OPENSSL_PATH@ 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@ PCRE_CFLAGS = @PCRE_CFLAGS@ PCRE_CPPFLAGS = @PCRE_CPPFLAGS@ PCRE_LDFLAGS = @PCRE_LDFLAGS@ PCRE_LIBS = @PCRE_LIBS@ PCRE_PATH = @PCRE_PATH@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_CPPFLAGS = @POSTGRESQL_CPPFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_LIBS = @POSTGRESQL_LIBS@ POSTGRESQL_PATH = @POSTGRESQL_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ TOKYOCABINET_CFLAGS = @TOKYOCABINET_CFLAGS@ TOKYOCABINET_CPPFLAGS = @TOKYOCABINET_CPPFLAGS@ TOKYOCABINET_LDFLAGS = @TOKYOCABINET_LDFLAGS@ TOKYOCABINET_LIBS = @TOKYOCABINET_LIBS@ TOKYOCABINET_PATH = @TOKYOCABINET_PATH@ 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_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ workdir = @workdir@ AM_CFLAGS = $(GCC_CFLAG) $(NOVA_CFLAGS) $(CONSTELLATION_CFLAGS) @CFLAGS@ AM_YFLAGS = -d LDADD = libpromises.la BUILT_SOURCES = cf3parse.h lib_LTLIBRARIES = libpromises.la libpromises_la_LDFLAGS = -version-info 1:0:0 -no-undefined libpromises_la_LIBADD = ../pub/libcfpub.la $(NOVA_LDADD) $(CONSTELLATION_LDADD) libpromises_la_CFLAGS = $(AM_CFLAGS) # Separate out a library libpromises_la_SOURCES = \ cf3parse.y \ cf3lex.l \ alloc.c \ patches.c \ attributes.c \ install.c \ generic_agent.c \ dbm_api.c \ dbm_berkeley.c \ dbm_quick.c \ dbm_tokyocab.c \ dbm_sqlite3.c \ dir.c \ dtypes.c \ classes.c \ env_context.c \ string_expressions.c \ logic_expressions.c \ files_interfaces.c \ files_properties.c \ files_select.c \ files_operators.c \ files_repository.c \ files_copy.c \ files_editline.c \ files_edit.c \ files_links.c \ files_hashes.c \ files_names.c \ chflags.c \ modes.c \ exec_tools.c \ nfs.c \ item-lib.c \ alphalist.c \ cf_sql.c \ client_protocol.c \ client_code.c \ communication.c \ net.c \ sockaddr.c \ recursion.c \ processes_select.c \ fncall.c \ cf3globals.c \ reporting.c \ evalfunction.c \ sysinfo.c \ conversion.c \ scope.c \ assoc.c \ comparray.c \ vars.c \ args.c \ hashes.c \ crypto.c \ sort.c \ keyring.c \ full-write.c \ expand.c \ matching.c \ selfdiagnostic.c \ instrumentation.c \ granules.c \ timeout.c \ promises.c \ ontology.c \ constraints.c \ iteration.c \ rlist.c \ syntax.c \ logging.c \ signals.c \ transaction.c \ cfstream.c \ pipes.c \ html.c \ interfaces.c \ storage_tools.c \ verify_reports.c \ verify_processes.c \ enterprise_stubs.c \ bootstrap.c \ mod_defaults.c \ mod_common.c \ mod_access.c \ mod_exec.c \ mod_methods.c \ mod_interfaces.c \ mod_packages.c \ mod_files.c \ mod_report.c \ mod_storage.c \ mod_knowledge.c \ mod_measurement.c \ mod_databases.c \ mod_services.c \ mod_process.c \ mod_environ.c \ mod_outputs.c \ unix.c # Automake need to be guided due to symlinking libpromises_la_DEPENDENCIES = ../pub/libcfpub.la $(NOVA_LDADD) $(CONSTELLATION_LDADD) cf_promises_SOURCES = \ cfpromises.c cf_key_SOURCES = \ cfkey.c cf_report_SOURCES = \ cfreport.c cf_agent_SOURCES = \ agent.c \ verify_files.c \ verify_storage.c \ verify_exec.c \ verify_methods.c \ verify_interfaces.c \ verify_packages.c \ verify_databases.c \ verify_services.c \ verify_environments.c \ agentdiagnostic.c cf_serverd_SOURCES = \ server.c \ server_transform.c cf_monitord_SOURCES = \ verify_measurements.c \ env_monitor.c \ mon_cpu.c \ mon_disk.c \ mon_entropy.c \ mon_load.c \ mon_network_sniffer.c \ mon_network.c \ mon_processes.c \ mon_temp.c \ monitor.c cf_monitord_LDADD = libpromises.la $(am__append_2) cf_execd_SOURCES = \ exec.c @HAVE_NOVA_TRUE@cf_hub_SOURCES = @HAVE_NOVA_TRUE@cf_hub_LDADD = \ @HAVE_NOVA_TRUE@ ../nova/src/libcfhub.la libpromises.la cf_runagent_SOURCES = \ runagent.c cf_know_SOURCES = \ cfknow.c \ manual.c EXTRA_DIST = cf3lex.c cf3parse.c # # Pickup header files here so Automake knows about them # noinst_HEADERS = \ cf.defs.h \ cf.extern.h \ config.h \ prototypes3.h \ cf3.defs.h \ cf3.server.h \ cf3parse.h \ cf3.extern.h \ cf.events.h \ string_expressions.h \ logic_expressions.h \ compiler.h \ monitoring.h \ bool.h # # Some basic clean ups # MOSTLYCLEANFILES = *~ *.orig *.rej # # Get everything removed down to where rebuilding requires: # "make; make install" # CLEANFILES = cf3lex.c cf3parse.c cf3parse.h # # Get everything removed down to where rebuilding requires: # "configure; make; make install" # DISTCLEANFILES = cflex.c cfparse.c cfparse.h # # Get everything removed down to where rebuilding requires: # "aclocal; autoconf; autoheader; automake --add-missing" # "configure; make; make install" # MAINTAINERCLEANFILES = Makefile.in conf.h.in stamp-h.in SUFFIXES = .h all: $(BUILT_SOURCES) conf.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .h .c .l .lo .o .obj .y $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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) --gnu src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): conf.h: stamp-h1 @if test ! -f $@; then rm -f stamp-h1; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi stamp-h1: $(srcdir)/conf.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status src/conf.h $(srcdir)/conf.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f conf.h stamp-h1 cf3lex.l: $(top_builddir)/config.status $(srcdir)/cf3lex.l.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 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 cf3parse.h: cf3parse.c @if test ! -f $@; then rm -f cf3parse.c; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) cf3parse.c; else :; fi libpromises.la: $(libpromises_la_OBJECTS) $(libpromises_la_DEPENDENCIES) $(AM_V_CCLD)$(libpromises_la_LINK) -rpath $(libdir) $(libpromises_la_OBJECTS) $(libpromises_la_LIBADD) $(LIBS) 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 cf-agent$(EXEEXT): $(cf_agent_OBJECTS) $(cf_agent_DEPENDENCIES) @rm -f cf-agent$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cf_agent_OBJECTS) $(cf_agent_LDADD) $(LIBS) cf-execd$(EXEEXT): $(cf_execd_OBJECTS) $(cf_execd_DEPENDENCIES) @rm -f cf-execd$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cf_execd_OBJECTS) $(cf_execd_LDADD) $(LIBS) cf-hub$(EXEEXT): $(cf_hub_OBJECTS) $(cf_hub_DEPENDENCIES) @rm -f cf-hub$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cf_hub_OBJECTS) $(cf_hub_LDADD) $(LIBS) cf-key$(EXEEXT): $(cf_key_OBJECTS) $(cf_key_DEPENDENCIES) @rm -f cf-key$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cf_key_OBJECTS) $(cf_key_LDADD) $(LIBS) cf-know$(EXEEXT): $(cf_know_OBJECTS) $(cf_know_DEPENDENCIES) @rm -f cf-know$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cf_know_OBJECTS) $(cf_know_LDADD) $(LIBS) cf-monitord$(EXEEXT): $(cf_monitord_OBJECTS) $(cf_monitord_DEPENDENCIES) @rm -f cf-monitord$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cf_monitord_OBJECTS) $(cf_monitord_LDADD) $(LIBS) cf-promises$(EXEEXT): $(cf_promises_OBJECTS) $(cf_promises_DEPENDENCIES) @rm -f cf-promises$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cf_promises_OBJECTS) $(cf_promises_LDADD) $(LIBS) cf-report$(EXEEXT): $(cf_report_OBJECTS) $(cf_report_DEPENDENCIES) @rm -f cf-report$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cf_report_OBJECTS) $(cf_report_LDADD) $(LIBS) cf-runagent$(EXEEXT): $(cf_runagent_OBJECTS) $(cf_runagent_DEPENDENCIES) @rm -f cf-runagent$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cf_runagent_OBJECTS) $(cf_runagent_LDADD) $(LIBS) cf-serverd$(EXEEXT): $(cf_serverd_OBJECTS) $(cf_serverd_DEPENDENCIES) @rm -f cf-serverd$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cf_serverd_OBJECTS) $(cf_serverd_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/agent.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/agentdiagnostic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfkey.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfknow.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfpromises.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfreport.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/env_monitor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-alloc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-alphalist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-args.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-assoc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-attributes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-bootstrap.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-cf3globals.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-cf3lex.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-cf3parse.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-cf_sql.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-cfstream.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-chflags.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-classes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-client_code.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-client_protocol.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-communication.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-comparray.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-constraints.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-conversion.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-crypto.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-dbm_api.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-dbm_berkeley.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-dbm_quick.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-dbm_sqlite3.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-dbm_tokyocab.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-dir.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-dtypes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-enterprise_stubs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-env_context.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-evalfunction.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-exec_tools.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-expand.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-files_copy.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-files_edit.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-files_editline.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-files_hashes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-files_interfaces.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-files_links.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-files_names.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-files_operators.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-files_properties.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-files_repository.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-files_select.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-fncall.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-full-write.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-generic_agent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-granules.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-hashes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-html.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-install.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-instrumentation.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-interfaces.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-item-lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-iteration.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-keyring.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-logging.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-logic_expressions.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-matching.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_access.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_common.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_databases.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_defaults.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_environ.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_exec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_files.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_interfaces.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_knowledge.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_measurement.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_methods.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_outputs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_packages.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_process.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_report.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_services.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-mod_storage.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-modes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-net.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-nfs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-ontology.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-patches.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-pipes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-processes_select.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-promises.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-recursion.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-reporting.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-rlist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-scope.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-selfdiagnostic.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-signals.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-sockaddr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-sort.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-storage_tools.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-string_expressions.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-syntax.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-sysinfo.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-timeout.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-transaction.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-unix.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-vars.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-verify_processes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpromises_la-verify_reports.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/manual.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mon_cpu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mon_disk.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mon_entropy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mon_load.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mon_network.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mon_network_sniffer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mon_processes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mon_temp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/monitor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/runagent.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/server.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/server_transform.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verify_databases.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verify_environments.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verify_exec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verify_files.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verify_interfaces.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verify_measurements.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verify_methods.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verify_packages.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verify_services.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verify_storage.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(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 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< libpromises_la-cf3parse.lo: cf3parse.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-cf3parse.lo -MD -MP -MF $(DEPDIR)/libpromises_la-cf3parse.Tpo -c -o libpromises_la-cf3parse.lo `test -f 'cf3parse.c' || echo '$(srcdir)/'`cf3parse.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-cf3parse.Tpo $(DEPDIR)/libpromises_la-cf3parse.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cf3parse.c' object='libpromises_la-cf3parse.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-cf3parse.lo `test -f 'cf3parse.c' || echo '$(srcdir)/'`cf3parse.c libpromises_la-cf3lex.lo: cf3lex.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-cf3lex.lo -MD -MP -MF $(DEPDIR)/libpromises_la-cf3lex.Tpo -c -o libpromises_la-cf3lex.lo `test -f 'cf3lex.c' || echo '$(srcdir)/'`cf3lex.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-cf3lex.Tpo $(DEPDIR)/libpromises_la-cf3lex.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cf3lex.c' object='libpromises_la-cf3lex.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-cf3lex.lo `test -f 'cf3lex.c' || echo '$(srcdir)/'`cf3lex.c libpromises_la-alloc.lo: alloc.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-alloc.lo -MD -MP -MF $(DEPDIR)/libpromises_la-alloc.Tpo -c -o libpromises_la-alloc.lo `test -f 'alloc.c' || echo '$(srcdir)/'`alloc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-alloc.Tpo $(DEPDIR)/libpromises_la-alloc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='alloc.c' object='libpromises_la-alloc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-alloc.lo `test -f 'alloc.c' || echo '$(srcdir)/'`alloc.c libpromises_la-patches.lo: patches.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-patches.lo -MD -MP -MF $(DEPDIR)/libpromises_la-patches.Tpo -c -o libpromises_la-patches.lo `test -f 'patches.c' || echo '$(srcdir)/'`patches.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-patches.Tpo $(DEPDIR)/libpromises_la-patches.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='patches.c' object='libpromises_la-patches.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-patches.lo `test -f 'patches.c' || echo '$(srcdir)/'`patches.c libpromises_la-attributes.lo: attributes.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-attributes.lo -MD -MP -MF $(DEPDIR)/libpromises_la-attributes.Tpo -c -o libpromises_la-attributes.lo `test -f 'attributes.c' || echo '$(srcdir)/'`attributes.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-attributes.Tpo $(DEPDIR)/libpromises_la-attributes.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='attributes.c' object='libpromises_la-attributes.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-attributes.lo `test -f 'attributes.c' || echo '$(srcdir)/'`attributes.c libpromises_la-install.lo: install.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-install.lo -MD -MP -MF $(DEPDIR)/libpromises_la-install.Tpo -c -o libpromises_la-install.lo `test -f 'install.c' || echo '$(srcdir)/'`install.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-install.Tpo $(DEPDIR)/libpromises_la-install.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='install.c' object='libpromises_la-install.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-install.lo `test -f 'install.c' || echo '$(srcdir)/'`install.c libpromises_la-generic_agent.lo: generic_agent.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-generic_agent.lo -MD -MP -MF $(DEPDIR)/libpromises_la-generic_agent.Tpo -c -o libpromises_la-generic_agent.lo `test -f 'generic_agent.c' || echo '$(srcdir)/'`generic_agent.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-generic_agent.Tpo $(DEPDIR)/libpromises_la-generic_agent.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='generic_agent.c' object='libpromises_la-generic_agent.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-generic_agent.lo `test -f 'generic_agent.c' || echo '$(srcdir)/'`generic_agent.c libpromises_la-dbm_api.lo: dbm_api.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-dbm_api.lo -MD -MP -MF $(DEPDIR)/libpromises_la-dbm_api.Tpo -c -o libpromises_la-dbm_api.lo `test -f 'dbm_api.c' || echo '$(srcdir)/'`dbm_api.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-dbm_api.Tpo $(DEPDIR)/libpromises_la-dbm_api.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dbm_api.c' object='libpromises_la-dbm_api.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-dbm_api.lo `test -f 'dbm_api.c' || echo '$(srcdir)/'`dbm_api.c libpromises_la-dbm_berkeley.lo: dbm_berkeley.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-dbm_berkeley.lo -MD -MP -MF $(DEPDIR)/libpromises_la-dbm_berkeley.Tpo -c -o libpromises_la-dbm_berkeley.lo `test -f 'dbm_berkeley.c' || echo '$(srcdir)/'`dbm_berkeley.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-dbm_berkeley.Tpo $(DEPDIR)/libpromises_la-dbm_berkeley.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dbm_berkeley.c' object='libpromises_la-dbm_berkeley.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-dbm_berkeley.lo `test -f 'dbm_berkeley.c' || echo '$(srcdir)/'`dbm_berkeley.c libpromises_la-dbm_quick.lo: dbm_quick.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-dbm_quick.lo -MD -MP -MF $(DEPDIR)/libpromises_la-dbm_quick.Tpo -c -o libpromises_la-dbm_quick.lo `test -f 'dbm_quick.c' || echo '$(srcdir)/'`dbm_quick.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-dbm_quick.Tpo $(DEPDIR)/libpromises_la-dbm_quick.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dbm_quick.c' object='libpromises_la-dbm_quick.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-dbm_quick.lo `test -f 'dbm_quick.c' || echo '$(srcdir)/'`dbm_quick.c libpromises_la-dbm_tokyocab.lo: dbm_tokyocab.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-dbm_tokyocab.lo -MD -MP -MF $(DEPDIR)/libpromises_la-dbm_tokyocab.Tpo -c -o libpromises_la-dbm_tokyocab.lo `test -f 'dbm_tokyocab.c' || echo '$(srcdir)/'`dbm_tokyocab.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-dbm_tokyocab.Tpo $(DEPDIR)/libpromises_la-dbm_tokyocab.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dbm_tokyocab.c' object='libpromises_la-dbm_tokyocab.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-dbm_tokyocab.lo `test -f 'dbm_tokyocab.c' || echo '$(srcdir)/'`dbm_tokyocab.c libpromises_la-dbm_sqlite3.lo: dbm_sqlite3.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-dbm_sqlite3.lo -MD -MP -MF $(DEPDIR)/libpromises_la-dbm_sqlite3.Tpo -c -o libpromises_la-dbm_sqlite3.lo `test -f 'dbm_sqlite3.c' || echo '$(srcdir)/'`dbm_sqlite3.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-dbm_sqlite3.Tpo $(DEPDIR)/libpromises_la-dbm_sqlite3.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dbm_sqlite3.c' object='libpromises_la-dbm_sqlite3.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-dbm_sqlite3.lo `test -f 'dbm_sqlite3.c' || echo '$(srcdir)/'`dbm_sqlite3.c libpromises_la-dir.lo: dir.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-dir.lo -MD -MP -MF $(DEPDIR)/libpromises_la-dir.Tpo -c -o libpromises_la-dir.lo `test -f 'dir.c' || echo '$(srcdir)/'`dir.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-dir.Tpo $(DEPDIR)/libpromises_la-dir.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dir.c' object='libpromises_la-dir.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-dir.lo `test -f 'dir.c' || echo '$(srcdir)/'`dir.c libpromises_la-dtypes.lo: dtypes.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-dtypes.lo -MD -MP -MF $(DEPDIR)/libpromises_la-dtypes.Tpo -c -o libpromises_la-dtypes.lo `test -f 'dtypes.c' || echo '$(srcdir)/'`dtypes.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-dtypes.Tpo $(DEPDIR)/libpromises_la-dtypes.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dtypes.c' object='libpromises_la-dtypes.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-dtypes.lo `test -f 'dtypes.c' || echo '$(srcdir)/'`dtypes.c libpromises_la-classes.lo: classes.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-classes.lo -MD -MP -MF $(DEPDIR)/libpromises_la-classes.Tpo -c -o libpromises_la-classes.lo `test -f 'classes.c' || echo '$(srcdir)/'`classes.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-classes.Tpo $(DEPDIR)/libpromises_la-classes.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='classes.c' object='libpromises_la-classes.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-classes.lo `test -f 'classes.c' || echo '$(srcdir)/'`classes.c libpromises_la-env_context.lo: env_context.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-env_context.lo -MD -MP -MF $(DEPDIR)/libpromises_la-env_context.Tpo -c -o libpromises_la-env_context.lo `test -f 'env_context.c' || echo '$(srcdir)/'`env_context.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-env_context.Tpo $(DEPDIR)/libpromises_la-env_context.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='env_context.c' object='libpromises_la-env_context.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-env_context.lo `test -f 'env_context.c' || echo '$(srcdir)/'`env_context.c libpromises_la-string_expressions.lo: string_expressions.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-string_expressions.lo -MD -MP -MF $(DEPDIR)/libpromises_la-string_expressions.Tpo -c -o libpromises_la-string_expressions.lo `test -f 'string_expressions.c' || echo '$(srcdir)/'`string_expressions.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-string_expressions.Tpo $(DEPDIR)/libpromises_la-string_expressions.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='string_expressions.c' object='libpromises_la-string_expressions.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-string_expressions.lo `test -f 'string_expressions.c' || echo '$(srcdir)/'`string_expressions.c libpromises_la-logic_expressions.lo: logic_expressions.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-logic_expressions.lo -MD -MP -MF $(DEPDIR)/libpromises_la-logic_expressions.Tpo -c -o libpromises_la-logic_expressions.lo `test -f 'logic_expressions.c' || echo '$(srcdir)/'`logic_expressions.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-logic_expressions.Tpo $(DEPDIR)/libpromises_la-logic_expressions.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='logic_expressions.c' object='libpromises_la-logic_expressions.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-logic_expressions.lo `test -f 'logic_expressions.c' || echo '$(srcdir)/'`logic_expressions.c libpromises_la-files_interfaces.lo: files_interfaces.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-files_interfaces.lo -MD -MP -MF $(DEPDIR)/libpromises_la-files_interfaces.Tpo -c -o libpromises_la-files_interfaces.lo `test -f 'files_interfaces.c' || echo '$(srcdir)/'`files_interfaces.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-files_interfaces.Tpo $(DEPDIR)/libpromises_la-files_interfaces.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='files_interfaces.c' object='libpromises_la-files_interfaces.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-files_interfaces.lo `test -f 'files_interfaces.c' || echo '$(srcdir)/'`files_interfaces.c libpromises_la-files_properties.lo: files_properties.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-files_properties.lo -MD -MP -MF $(DEPDIR)/libpromises_la-files_properties.Tpo -c -o libpromises_la-files_properties.lo `test -f 'files_properties.c' || echo '$(srcdir)/'`files_properties.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-files_properties.Tpo $(DEPDIR)/libpromises_la-files_properties.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='files_properties.c' object='libpromises_la-files_properties.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-files_properties.lo `test -f 'files_properties.c' || echo '$(srcdir)/'`files_properties.c libpromises_la-files_select.lo: files_select.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-files_select.lo -MD -MP -MF $(DEPDIR)/libpromises_la-files_select.Tpo -c -o libpromises_la-files_select.lo `test -f 'files_select.c' || echo '$(srcdir)/'`files_select.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-files_select.Tpo $(DEPDIR)/libpromises_la-files_select.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='files_select.c' object='libpromises_la-files_select.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-files_select.lo `test -f 'files_select.c' || echo '$(srcdir)/'`files_select.c libpromises_la-files_operators.lo: files_operators.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-files_operators.lo -MD -MP -MF $(DEPDIR)/libpromises_la-files_operators.Tpo -c -o libpromises_la-files_operators.lo `test -f 'files_operators.c' || echo '$(srcdir)/'`files_operators.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-files_operators.Tpo $(DEPDIR)/libpromises_la-files_operators.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='files_operators.c' object='libpromises_la-files_operators.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-files_operators.lo `test -f 'files_operators.c' || echo '$(srcdir)/'`files_operators.c libpromises_la-files_repository.lo: files_repository.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-files_repository.lo -MD -MP -MF $(DEPDIR)/libpromises_la-files_repository.Tpo -c -o libpromises_la-files_repository.lo `test -f 'files_repository.c' || echo '$(srcdir)/'`files_repository.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-files_repository.Tpo $(DEPDIR)/libpromises_la-files_repository.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='files_repository.c' object='libpromises_la-files_repository.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-files_repository.lo `test -f 'files_repository.c' || echo '$(srcdir)/'`files_repository.c libpromises_la-files_copy.lo: files_copy.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-files_copy.lo -MD -MP -MF $(DEPDIR)/libpromises_la-files_copy.Tpo -c -o libpromises_la-files_copy.lo `test -f 'files_copy.c' || echo '$(srcdir)/'`files_copy.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-files_copy.Tpo $(DEPDIR)/libpromises_la-files_copy.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='files_copy.c' object='libpromises_la-files_copy.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-files_copy.lo `test -f 'files_copy.c' || echo '$(srcdir)/'`files_copy.c libpromises_la-files_editline.lo: files_editline.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-files_editline.lo -MD -MP -MF $(DEPDIR)/libpromises_la-files_editline.Tpo -c -o libpromises_la-files_editline.lo `test -f 'files_editline.c' || echo '$(srcdir)/'`files_editline.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-files_editline.Tpo $(DEPDIR)/libpromises_la-files_editline.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='files_editline.c' object='libpromises_la-files_editline.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-files_editline.lo `test -f 'files_editline.c' || echo '$(srcdir)/'`files_editline.c libpromises_la-files_edit.lo: files_edit.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-files_edit.lo -MD -MP -MF $(DEPDIR)/libpromises_la-files_edit.Tpo -c -o libpromises_la-files_edit.lo `test -f 'files_edit.c' || echo '$(srcdir)/'`files_edit.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-files_edit.Tpo $(DEPDIR)/libpromises_la-files_edit.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='files_edit.c' object='libpromises_la-files_edit.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-files_edit.lo `test -f 'files_edit.c' || echo '$(srcdir)/'`files_edit.c libpromises_la-files_links.lo: files_links.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-files_links.lo -MD -MP -MF $(DEPDIR)/libpromises_la-files_links.Tpo -c -o libpromises_la-files_links.lo `test -f 'files_links.c' || echo '$(srcdir)/'`files_links.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-files_links.Tpo $(DEPDIR)/libpromises_la-files_links.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='files_links.c' object='libpromises_la-files_links.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-files_links.lo `test -f 'files_links.c' || echo '$(srcdir)/'`files_links.c libpromises_la-files_hashes.lo: files_hashes.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-files_hashes.lo -MD -MP -MF $(DEPDIR)/libpromises_la-files_hashes.Tpo -c -o libpromises_la-files_hashes.lo `test -f 'files_hashes.c' || echo '$(srcdir)/'`files_hashes.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-files_hashes.Tpo $(DEPDIR)/libpromises_la-files_hashes.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='files_hashes.c' object='libpromises_la-files_hashes.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-files_hashes.lo `test -f 'files_hashes.c' || echo '$(srcdir)/'`files_hashes.c libpromises_la-files_names.lo: files_names.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-files_names.lo -MD -MP -MF $(DEPDIR)/libpromises_la-files_names.Tpo -c -o libpromises_la-files_names.lo `test -f 'files_names.c' || echo '$(srcdir)/'`files_names.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-files_names.Tpo $(DEPDIR)/libpromises_la-files_names.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='files_names.c' object='libpromises_la-files_names.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-files_names.lo `test -f 'files_names.c' || echo '$(srcdir)/'`files_names.c libpromises_la-chflags.lo: chflags.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-chflags.lo -MD -MP -MF $(DEPDIR)/libpromises_la-chflags.Tpo -c -o libpromises_la-chflags.lo `test -f 'chflags.c' || echo '$(srcdir)/'`chflags.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-chflags.Tpo $(DEPDIR)/libpromises_la-chflags.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='chflags.c' object='libpromises_la-chflags.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-chflags.lo `test -f 'chflags.c' || echo '$(srcdir)/'`chflags.c libpromises_la-modes.lo: 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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-modes.lo -MD -MP -MF $(DEPDIR)/libpromises_la-modes.Tpo -c -o libpromises_la-modes.lo `test -f 'modes.c' || echo '$(srcdir)/'`modes.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-modes.Tpo $(DEPDIR)/libpromises_la-modes.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='modes.c' object='libpromises_la-modes.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-modes.lo `test -f 'modes.c' || echo '$(srcdir)/'`modes.c libpromises_la-exec_tools.lo: exec_tools.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-exec_tools.lo -MD -MP -MF $(DEPDIR)/libpromises_la-exec_tools.Tpo -c -o libpromises_la-exec_tools.lo `test -f 'exec_tools.c' || echo '$(srcdir)/'`exec_tools.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-exec_tools.Tpo $(DEPDIR)/libpromises_la-exec_tools.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='exec_tools.c' object='libpromises_la-exec_tools.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-exec_tools.lo `test -f 'exec_tools.c' || echo '$(srcdir)/'`exec_tools.c libpromises_la-nfs.lo: nfs.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-nfs.lo -MD -MP -MF $(DEPDIR)/libpromises_la-nfs.Tpo -c -o libpromises_la-nfs.lo `test -f 'nfs.c' || echo '$(srcdir)/'`nfs.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-nfs.Tpo $(DEPDIR)/libpromises_la-nfs.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='nfs.c' object='libpromises_la-nfs.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-nfs.lo `test -f 'nfs.c' || echo '$(srcdir)/'`nfs.c libpromises_la-item-lib.lo: item-lib.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-item-lib.lo -MD -MP -MF $(DEPDIR)/libpromises_la-item-lib.Tpo -c -o libpromises_la-item-lib.lo `test -f 'item-lib.c' || echo '$(srcdir)/'`item-lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-item-lib.Tpo $(DEPDIR)/libpromises_la-item-lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='item-lib.c' object='libpromises_la-item-lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-item-lib.lo `test -f 'item-lib.c' || echo '$(srcdir)/'`item-lib.c libpromises_la-alphalist.lo: alphalist.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-alphalist.lo -MD -MP -MF $(DEPDIR)/libpromises_la-alphalist.Tpo -c -o libpromises_la-alphalist.lo `test -f 'alphalist.c' || echo '$(srcdir)/'`alphalist.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-alphalist.Tpo $(DEPDIR)/libpromises_la-alphalist.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='alphalist.c' object='libpromises_la-alphalist.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-alphalist.lo `test -f 'alphalist.c' || echo '$(srcdir)/'`alphalist.c libpromises_la-cf_sql.lo: cf_sql.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-cf_sql.lo -MD -MP -MF $(DEPDIR)/libpromises_la-cf_sql.Tpo -c -o libpromises_la-cf_sql.lo `test -f 'cf_sql.c' || echo '$(srcdir)/'`cf_sql.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-cf_sql.Tpo $(DEPDIR)/libpromises_la-cf_sql.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cf_sql.c' object='libpromises_la-cf_sql.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-cf_sql.lo `test -f 'cf_sql.c' || echo '$(srcdir)/'`cf_sql.c libpromises_la-client_protocol.lo: client_protocol.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-client_protocol.lo -MD -MP -MF $(DEPDIR)/libpromises_la-client_protocol.Tpo -c -o libpromises_la-client_protocol.lo `test -f 'client_protocol.c' || echo '$(srcdir)/'`client_protocol.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-client_protocol.Tpo $(DEPDIR)/libpromises_la-client_protocol.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='client_protocol.c' object='libpromises_la-client_protocol.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-client_protocol.lo `test -f 'client_protocol.c' || echo '$(srcdir)/'`client_protocol.c libpromises_la-client_code.lo: client_code.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-client_code.lo -MD -MP -MF $(DEPDIR)/libpromises_la-client_code.Tpo -c -o libpromises_la-client_code.lo `test -f 'client_code.c' || echo '$(srcdir)/'`client_code.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-client_code.Tpo $(DEPDIR)/libpromises_la-client_code.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='client_code.c' object='libpromises_la-client_code.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-client_code.lo `test -f 'client_code.c' || echo '$(srcdir)/'`client_code.c libpromises_la-communication.lo: communication.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-communication.lo -MD -MP -MF $(DEPDIR)/libpromises_la-communication.Tpo -c -o libpromises_la-communication.lo `test -f 'communication.c' || echo '$(srcdir)/'`communication.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-communication.Tpo $(DEPDIR)/libpromises_la-communication.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='communication.c' object='libpromises_la-communication.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-communication.lo `test -f 'communication.c' || echo '$(srcdir)/'`communication.c libpromises_la-net.lo: net.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-net.lo -MD -MP -MF $(DEPDIR)/libpromises_la-net.Tpo -c -o libpromises_la-net.lo `test -f 'net.c' || echo '$(srcdir)/'`net.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-net.Tpo $(DEPDIR)/libpromises_la-net.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net.c' object='libpromises_la-net.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-net.lo `test -f 'net.c' || echo '$(srcdir)/'`net.c libpromises_la-sockaddr.lo: sockaddr.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-sockaddr.lo -MD -MP -MF $(DEPDIR)/libpromises_la-sockaddr.Tpo -c -o libpromises_la-sockaddr.lo `test -f 'sockaddr.c' || echo '$(srcdir)/'`sockaddr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-sockaddr.Tpo $(DEPDIR)/libpromises_la-sockaddr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sockaddr.c' object='libpromises_la-sockaddr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-sockaddr.lo `test -f 'sockaddr.c' || echo '$(srcdir)/'`sockaddr.c libpromises_la-recursion.lo: recursion.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-recursion.lo -MD -MP -MF $(DEPDIR)/libpromises_la-recursion.Tpo -c -o libpromises_la-recursion.lo `test -f 'recursion.c' || echo '$(srcdir)/'`recursion.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-recursion.Tpo $(DEPDIR)/libpromises_la-recursion.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='recursion.c' object='libpromises_la-recursion.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-recursion.lo `test -f 'recursion.c' || echo '$(srcdir)/'`recursion.c libpromises_la-processes_select.lo: processes_select.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-processes_select.lo -MD -MP -MF $(DEPDIR)/libpromises_la-processes_select.Tpo -c -o libpromises_la-processes_select.lo `test -f 'processes_select.c' || echo '$(srcdir)/'`processes_select.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-processes_select.Tpo $(DEPDIR)/libpromises_la-processes_select.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='processes_select.c' object='libpromises_la-processes_select.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-processes_select.lo `test -f 'processes_select.c' || echo '$(srcdir)/'`processes_select.c libpromises_la-fncall.lo: fncall.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-fncall.lo -MD -MP -MF $(DEPDIR)/libpromises_la-fncall.Tpo -c -o libpromises_la-fncall.lo `test -f 'fncall.c' || echo '$(srcdir)/'`fncall.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-fncall.Tpo $(DEPDIR)/libpromises_la-fncall.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fncall.c' object='libpromises_la-fncall.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-fncall.lo `test -f 'fncall.c' || echo '$(srcdir)/'`fncall.c libpromises_la-cf3globals.lo: cf3globals.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-cf3globals.lo -MD -MP -MF $(DEPDIR)/libpromises_la-cf3globals.Tpo -c -o libpromises_la-cf3globals.lo `test -f 'cf3globals.c' || echo '$(srcdir)/'`cf3globals.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-cf3globals.Tpo $(DEPDIR)/libpromises_la-cf3globals.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cf3globals.c' object='libpromises_la-cf3globals.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-cf3globals.lo `test -f 'cf3globals.c' || echo '$(srcdir)/'`cf3globals.c libpromises_la-reporting.lo: reporting.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-reporting.lo -MD -MP -MF $(DEPDIR)/libpromises_la-reporting.Tpo -c -o libpromises_la-reporting.lo `test -f 'reporting.c' || echo '$(srcdir)/'`reporting.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-reporting.Tpo $(DEPDIR)/libpromises_la-reporting.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='reporting.c' object='libpromises_la-reporting.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-reporting.lo `test -f 'reporting.c' || echo '$(srcdir)/'`reporting.c libpromises_la-evalfunction.lo: evalfunction.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-evalfunction.lo -MD -MP -MF $(DEPDIR)/libpromises_la-evalfunction.Tpo -c -o libpromises_la-evalfunction.lo `test -f 'evalfunction.c' || echo '$(srcdir)/'`evalfunction.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-evalfunction.Tpo $(DEPDIR)/libpromises_la-evalfunction.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evalfunction.c' object='libpromises_la-evalfunction.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-evalfunction.lo `test -f 'evalfunction.c' || echo '$(srcdir)/'`evalfunction.c libpromises_la-sysinfo.lo: sysinfo.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-sysinfo.lo -MD -MP -MF $(DEPDIR)/libpromises_la-sysinfo.Tpo -c -o libpromises_la-sysinfo.lo `test -f 'sysinfo.c' || echo '$(srcdir)/'`sysinfo.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-sysinfo.Tpo $(DEPDIR)/libpromises_la-sysinfo.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sysinfo.c' object='libpromises_la-sysinfo.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-sysinfo.lo `test -f 'sysinfo.c' || echo '$(srcdir)/'`sysinfo.c libpromises_la-conversion.lo: conversion.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-conversion.lo -MD -MP -MF $(DEPDIR)/libpromises_la-conversion.Tpo -c -o libpromises_la-conversion.lo `test -f 'conversion.c' || echo '$(srcdir)/'`conversion.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-conversion.Tpo $(DEPDIR)/libpromises_la-conversion.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='conversion.c' object='libpromises_la-conversion.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-conversion.lo `test -f 'conversion.c' || echo '$(srcdir)/'`conversion.c libpromises_la-scope.lo: scope.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-scope.lo -MD -MP -MF $(DEPDIR)/libpromises_la-scope.Tpo -c -o libpromises_la-scope.lo `test -f 'scope.c' || echo '$(srcdir)/'`scope.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-scope.Tpo $(DEPDIR)/libpromises_la-scope.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='scope.c' object='libpromises_la-scope.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-scope.lo `test -f 'scope.c' || echo '$(srcdir)/'`scope.c libpromises_la-assoc.lo: assoc.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-assoc.lo -MD -MP -MF $(DEPDIR)/libpromises_la-assoc.Tpo -c -o libpromises_la-assoc.lo `test -f 'assoc.c' || echo '$(srcdir)/'`assoc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-assoc.Tpo $(DEPDIR)/libpromises_la-assoc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='assoc.c' object='libpromises_la-assoc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-assoc.lo `test -f 'assoc.c' || echo '$(srcdir)/'`assoc.c libpromises_la-comparray.lo: comparray.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-comparray.lo -MD -MP -MF $(DEPDIR)/libpromises_la-comparray.Tpo -c -o libpromises_la-comparray.lo `test -f 'comparray.c' || echo '$(srcdir)/'`comparray.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-comparray.Tpo $(DEPDIR)/libpromises_la-comparray.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='comparray.c' object='libpromises_la-comparray.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-comparray.lo `test -f 'comparray.c' || echo '$(srcdir)/'`comparray.c libpromises_la-vars.lo: vars.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-vars.lo -MD -MP -MF $(DEPDIR)/libpromises_la-vars.Tpo -c -o libpromises_la-vars.lo `test -f 'vars.c' || echo '$(srcdir)/'`vars.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-vars.Tpo $(DEPDIR)/libpromises_la-vars.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='vars.c' object='libpromises_la-vars.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-vars.lo `test -f 'vars.c' || echo '$(srcdir)/'`vars.c libpromises_la-args.lo: args.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-args.lo -MD -MP -MF $(DEPDIR)/libpromises_la-args.Tpo -c -o libpromises_la-args.lo `test -f 'args.c' || echo '$(srcdir)/'`args.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-args.Tpo $(DEPDIR)/libpromises_la-args.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='args.c' object='libpromises_la-args.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-args.lo `test -f 'args.c' || echo '$(srcdir)/'`args.c libpromises_la-hashes.lo: hashes.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-hashes.lo -MD -MP -MF $(DEPDIR)/libpromises_la-hashes.Tpo -c -o libpromises_la-hashes.lo `test -f 'hashes.c' || echo '$(srcdir)/'`hashes.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-hashes.Tpo $(DEPDIR)/libpromises_la-hashes.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hashes.c' object='libpromises_la-hashes.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-hashes.lo `test -f 'hashes.c' || echo '$(srcdir)/'`hashes.c libpromises_la-crypto.lo: crypto.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-crypto.lo -MD -MP -MF $(DEPDIR)/libpromises_la-crypto.Tpo -c -o libpromises_la-crypto.lo `test -f 'crypto.c' || echo '$(srcdir)/'`crypto.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-crypto.Tpo $(DEPDIR)/libpromises_la-crypto.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='crypto.c' object='libpromises_la-crypto.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-crypto.lo `test -f 'crypto.c' || echo '$(srcdir)/'`crypto.c libpromises_la-sort.lo: sort.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-sort.lo -MD -MP -MF $(DEPDIR)/libpromises_la-sort.Tpo -c -o libpromises_la-sort.lo `test -f 'sort.c' || echo '$(srcdir)/'`sort.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-sort.Tpo $(DEPDIR)/libpromises_la-sort.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sort.c' object='libpromises_la-sort.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-sort.lo `test -f 'sort.c' || echo '$(srcdir)/'`sort.c libpromises_la-keyring.lo: keyring.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-keyring.lo -MD -MP -MF $(DEPDIR)/libpromises_la-keyring.Tpo -c -o libpromises_la-keyring.lo `test -f 'keyring.c' || echo '$(srcdir)/'`keyring.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-keyring.Tpo $(DEPDIR)/libpromises_la-keyring.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='keyring.c' object='libpromises_la-keyring.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-keyring.lo `test -f 'keyring.c' || echo '$(srcdir)/'`keyring.c libpromises_la-full-write.lo: full-write.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-full-write.lo -MD -MP -MF $(DEPDIR)/libpromises_la-full-write.Tpo -c -o libpromises_la-full-write.lo `test -f 'full-write.c' || echo '$(srcdir)/'`full-write.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-full-write.Tpo $(DEPDIR)/libpromises_la-full-write.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='full-write.c' object='libpromises_la-full-write.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-full-write.lo `test -f 'full-write.c' || echo '$(srcdir)/'`full-write.c libpromises_la-expand.lo: expand.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-expand.lo -MD -MP -MF $(DEPDIR)/libpromises_la-expand.Tpo -c -o libpromises_la-expand.lo `test -f 'expand.c' || echo '$(srcdir)/'`expand.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-expand.Tpo $(DEPDIR)/libpromises_la-expand.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='expand.c' object='libpromises_la-expand.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-expand.lo `test -f 'expand.c' || echo '$(srcdir)/'`expand.c libpromises_la-matching.lo: matching.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-matching.lo -MD -MP -MF $(DEPDIR)/libpromises_la-matching.Tpo -c -o libpromises_la-matching.lo `test -f 'matching.c' || echo '$(srcdir)/'`matching.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-matching.Tpo $(DEPDIR)/libpromises_la-matching.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='matching.c' object='libpromises_la-matching.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-matching.lo `test -f 'matching.c' || echo '$(srcdir)/'`matching.c libpromises_la-selfdiagnostic.lo: selfdiagnostic.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-selfdiagnostic.lo -MD -MP -MF $(DEPDIR)/libpromises_la-selfdiagnostic.Tpo -c -o libpromises_la-selfdiagnostic.lo `test -f 'selfdiagnostic.c' || echo '$(srcdir)/'`selfdiagnostic.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-selfdiagnostic.Tpo $(DEPDIR)/libpromises_la-selfdiagnostic.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='selfdiagnostic.c' object='libpromises_la-selfdiagnostic.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-selfdiagnostic.lo `test -f 'selfdiagnostic.c' || echo '$(srcdir)/'`selfdiagnostic.c libpromises_la-instrumentation.lo: instrumentation.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-instrumentation.lo -MD -MP -MF $(DEPDIR)/libpromises_la-instrumentation.Tpo -c -o libpromises_la-instrumentation.lo `test -f 'instrumentation.c' || echo '$(srcdir)/'`instrumentation.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-instrumentation.Tpo $(DEPDIR)/libpromises_la-instrumentation.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='instrumentation.c' object='libpromises_la-instrumentation.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-instrumentation.lo `test -f 'instrumentation.c' || echo '$(srcdir)/'`instrumentation.c libpromises_la-granules.lo: granules.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-granules.lo -MD -MP -MF $(DEPDIR)/libpromises_la-granules.Tpo -c -o libpromises_la-granules.lo `test -f 'granules.c' || echo '$(srcdir)/'`granules.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-granules.Tpo $(DEPDIR)/libpromises_la-granules.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='granules.c' object='libpromises_la-granules.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-granules.lo `test -f 'granules.c' || echo '$(srcdir)/'`granules.c libpromises_la-timeout.lo: timeout.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-timeout.lo -MD -MP -MF $(DEPDIR)/libpromises_la-timeout.Tpo -c -o libpromises_la-timeout.lo `test -f 'timeout.c' || echo '$(srcdir)/'`timeout.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-timeout.Tpo $(DEPDIR)/libpromises_la-timeout.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='timeout.c' object='libpromises_la-timeout.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-timeout.lo `test -f 'timeout.c' || echo '$(srcdir)/'`timeout.c libpromises_la-promises.lo: promises.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-promises.lo -MD -MP -MF $(DEPDIR)/libpromises_la-promises.Tpo -c -o libpromises_la-promises.lo `test -f 'promises.c' || echo '$(srcdir)/'`promises.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-promises.Tpo $(DEPDIR)/libpromises_la-promises.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='promises.c' object='libpromises_la-promises.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-promises.lo `test -f 'promises.c' || echo '$(srcdir)/'`promises.c libpromises_la-ontology.lo: ontology.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-ontology.lo -MD -MP -MF $(DEPDIR)/libpromises_la-ontology.Tpo -c -o libpromises_la-ontology.lo `test -f 'ontology.c' || echo '$(srcdir)/'`ontology.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-ontology.Tpo $(DEPDIR)/libpromises_la-ontology.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ontology.c' object='libpromises_la-ontology.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-ontology.lo `test -f 'ontology.c' || echo '$(srcdir)/'`ontology.c libpromises_la-constraints.lo: constraints.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-constraints.lo -MD -MP -MF $(DEPDIR)/libpromises_la-constraints.Tpo -c -o libpromises_la-constraints.lo `test -f 'constraints.c' || echo '$(srcdir)/'`constraints.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-constraints.Tpo $(DEPDIR)/libpromises_la-constraints.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='constraints.c' object='libpromises_la-constraints.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-constraints.lo `test -f 'constraints.c' || echo '$(srcdir)/'`constraints.c libpromises_la-iteration.lo: iteration.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-iteration.lo -MD -MP -MF $(DEPDIR)/libpromises_la-iteration.Tpo -c -o libpromises_la-iteration.lo `test -f 'iteration.c' || echo '$(srcdir)/'`iteration.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-iteration.Tpo $(DEPDIR)/libpromises_la-iteration.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='iteration.c' object='libpromises_la-iteration.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-iteration.lo `test -f 'iteration.c' || echo '$(srcdir)/'`iteration.c libpromises_la-rlist.lo: rlist.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-rlist.lo -MD -MP -MF $(DEPDIR)/libpromises_la-rlist.Tpo -c -o libpromises_la-rlist.lo `test -f 'rlist.c' || echo '$(srcdir)/'`rlist.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-rlist.Tpo $(DEPDIR)/libpromises_la-rlist.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rlist.c' object='libpromises_la-rlist.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-rlist.lo `test -f 'rlist.c' || echo '$(srcdir)/'`rlist.c libpromises_la-syntax.lo: syntax.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-syntax.lo -MD -MP -MF $(DEPDIR)/libpromises_la-syntax.Tpo -c -o libpromises_la-syntax.lo `test -f 'syntax.c' || echo '$(srcdir)/'`syntax.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-syntax.Tpo $(DEPDIR)/libpromises_la-syntax.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='syntax.c' object='libpromises_la-syntax.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-syntax.lo `test -f 'syntax.c' || echo '$(srcdir)/'`syntax.c libpromises_la-logging.lo: logging.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-logging.lo -MD -MP -MF $(DEPDIR)/libpromises_la-logging.Tpo -c -o libpromises_la-logging.lo `test -f 'logging.c' || echo '$(srcdir)/'`logging.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-logging.Tpo $(DEPDIR)/libpromises_la-logging.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='logging.c' object='libpromises_la-logging.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-logging.lo `test -f 'logging.c' || echo '$(srcdir)/'`logging.c libpromises_la-signals.lo: signals.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-signals.lo -MD -MP -MF $(DEPDIR)/libpromises_la-signals.Tpo -c -o libpromises_la-signals.lo `test -f 'signals.c' || echo '$(srcdir)/'`signals.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-signals.Tpo $(DEPDIR)/libpromises_la-signals.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='signals.c' object='libpromises_la-signals.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-signals.lo `test -f 'signals.c' || echo '$(srcdir)/'`signals.c libpromises_la-transaction.lo: transaction.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-transaction.lo -MD -MP -MF $(DEPDIR)/libpromises_la-transaction.Tpo -c -o libpromises_la-transaction.lo `test -f 'transaction.c' || echo '$(srcdir)/'`transaction.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-transaction.Tpo $(DEPDIR)/libpromises_la-transaction.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='transaction.c' object='libpromises_la-transaction.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-transaction.lo `test -f 'transaction.c' || echo '$(srcdir)/'`transaction.c libpromises_la-cfstream.lo: cfstream.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-cfstream.lo -MD -MP -MF $(DEPDIR)/libpromises_la-cfstream.Tpo -c -o libpromises_la-cfstream.lo `test -f 'cfstream.c' || echo '$(srcdir)/'`cfstream.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-cfstream.Tpo $(DEPDIR)/libpromises_la-cfstream.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cfstream.c' object='libpromises_la-cfstream.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-cfstream.lo `test -f 'cfstream.c' || echo '$(srcdir)/'`cfstream.c libpromises_la-pipes.lo: pipes.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-pipes.lo -MD -MP -MF $(DEPDIR)/libpromises_la-pipes.Tpo -c -o libpromises_la-pipes.lo `test -f 'pipes.c' || echo '$(srcdir)/'`pipes.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-pipes.Tpo $(DEPDIR)/libpromises_la-pipes.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pipes.c' object='libpromises_la-pipes.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-pipes.lo `test -f 'pipes.c' || echo '$(srcdir)/'`pipes.c libpromises_la-html.lo: html.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-html.lo -MD -MP -MF $(DEPDIR)/libpromises_la-html.Tpo -c -o libpromises_la-html.lo `test -f 'html.c' || echo '$(srcdir)/'`html.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-html.Tpo $(DEPDIR)/libpromises_la-html.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='html.c' object='libpromises_la-html.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-html.lo `test -f 'html.c' || echo '$(srcdir)/'`html.c libpromises_la-interfaces.lo: interfaces.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-interfaces.lo -MD -MP -MF $(DEPDIR)/libpromises_la-interfaces.Tpo -c -o libpromises_la-interfaces.lo `test -f 'interfaces.c' || echo '$(srcdir)/'`interfaces.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-interfaces.Tpo $(DEPDIR)/libpromises_la-interfaces.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='interfaces.c' object='libpromises_la-interfaces.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-interfaces.lo `test -f 'interfaces.c' || echo '$(srcdir)/'`interfaces.c libpromises_la-storage_tools.lo: storage_tools.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-storage_tools.lo -MD -MP -MF $(DEPDIR)/libpromises_la-storage_tools.Tpo -c -o libpromises_la-storage_tools.lo `test -f 'storage_tools.c' || echo '$(srcdir)/'`storage_tools.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-storage_tools.Tpo $(DEPDIR)/libpromises_la-storage_tools.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='storage_tools.c' object='libpromises_la-storage_tools.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-storage_tools.lo `test -f 'storage_tools.c' || echo '$(srcdir)/'`storage_tools.c libpromises_la-verify_reports.lo: verify_reports.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-verify_reports.lo -MD -MP -MF $(DEPDIR)/libpromises_la-verify_reports.Tpo -c -o libpromises_la-verify_reports.lo `test -f 'verify_reports.c' || echo '$(srcdir)/'`verify_reports.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-verify_reports.Tpo $(DEPDIR)/libpromises_la-verify_reports.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='verify_reports.c' object='libpromises_la-verify_reports.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-verify_reports.lo `test -f 'verify_reports.c' || echo '$(srcdir)/'`verify_reports.c libpromises_la-verify_processes.lo: verify_processes.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-verify_processes.lo -MD -MP -MF $(DEPDIR)/libpromises_la-verify_processes.Tpo -c -o libpromises_la-verify_processes.lo `test -f 'verify_processes.c' || echo '$(srcdir)/'`verify_processes.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-verify_processes.Tpo $(DEPDIR)/libpromises_la-verify_processes.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='verify_processes.c' object='libpromises_la-verify_processes.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-verify_processes.lo `test -f 'verify_processes.c' || echo '$(srcdir)/'`verify_processes.c libpromises_la-enterprise_stubs.lo: enterprise_stubs.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-enterprise_stubs.lo -MD -MP -MF $(DEPDIR)/libpromises_la-enterprise_stubs.Tpo -c -o libpromises_la-enterprise_stubs.lo `test -f 'enterprise_stubs.c' || echo '$(srcdir)/'`enterprise_stubs.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-enterprise_stubs.Tpo $(DEPDIR)/libpromises_la-enterprise_stubs.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='enterprise_stubs.c' object='libpromises_la-enterprise_stubs.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-enterprise_stubs.lo `test -f 'enterprise_stubs.c' || echo '$(srcdir)/'`enterprise_stubs.c libpromises_la-bootstrap.lo: bootstrap.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-bootstrap.lo -MD -MP -MF $(DEPDIR)/libpromises_la-bootstrap.Tpo -c -o libpromises_la-bootstrap.lo `test -f 'bootstrap.c' || echo '$(srcdir)/'`bootstrap.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-bootstrap.Tpo $(DEPDIR)/libpromises_la-bootstrap.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bootstrap.c' object='libpromises_la-bootstrap.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-bootstrap.lo `test -f 'bootstrap.c' || echo '$(srcdir)/'`bootstrap.c libpromises_la-mod_defaults.lo: mod_defaults.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_defaults.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_defaults.Tpo -c -o libpromises_la-mod_defaults.lo `test -f 'mod_defaults.c' || echo '$(srcdir)/'`mod_defaults.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_defaults.Tpo $(DEPDIR)/libpromises_la-mod_defaults.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_defaults.c' object='libpromises_la-mod_defaults.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_defaults.lo `test -f 'mod_defaults.c' || echo '$(srcdir)/'`mod_defaults.c libpromises_la-mod_common.lo: mod_common.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_common.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_common.Tpo -c -o libpromises_la-mod_common.lo `test -f 'mod_common.c' || echo '$(srcdir)/'`mod_common.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_common.Tpo $(DEPDIR)/libpromises_la-mod_common.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_common.c' object='libpromises_la-mod_common.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_common.lo `test -f 'mod_common.c' || echo '$(srcdir)/'`mod_common.c libpromises_la-mod_access.lo: mod_access.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_access.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_access.Tpo -c -o libpromises_la-mod_access.lo `test -f 'mod_access.c' || echo '$(srcdir)/'`mod_access.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_access.Tpo $(DEPDIR)/libpromises_la-mod_access.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_access.c' object='libpromises_la-mod_access.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_access.lo `test -f 'mod_access.c' || echo '$(srcdir)/'`mod_access.c libpromises_la-mod_exec.lo: mod_exec.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_exec.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_exec.Tpo -c -o libpromises_la-mod_exec.lo `test -f 'mod_exec.c' || echo '$(srcdir)/'`mod_exec.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_exec.Tpo $(DEPDIR)/libpromises_la-mod_exec.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_exec.c' object='libpromises_la-mod_exec.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_exec.lo `test -f 'mod_exec.c' || echo '$(srcdir)/'`mod_exec.c libpromises_la-mod_methods.lo: mod_methods.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_methods.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_methods.Tpo -c -o libpromises_la-mod_methods.lo `test -f 'mod_methods.c' || echo '$(srcdir)/'`mod_methods.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_methods.Tpo $(DEPDIR)/libpromises_la-mod_methods.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_methods.c' object='libpromises_la-mod_methods.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_methods.lo `test -f 'mod_methods.c' || echo '$(srcdir)/'`mod_methods.c libpromises_la-mod_interfaces.lo: mod_interfaces.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_interfaces.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_interfaces.Tpo -c -o libpromises_la-mod_interfaces.lo `test -f 'mod_interfaces.c' || echo '$(srcdir)/'`mod_interfaces.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_interfaces.Tpo $(DEPDIR)/libpromises_la-mod_interfaces.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_interfaces.c' object='libpromises_la-mod_interfaces.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_interfaces.lo `test -f 'mod_interfaces.c' || echo '$(srcdir)/'`mod_interfaces.c libpromises_la-mod_packages.lo: mod_packages.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_packages.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_packages.Tpo -c -o libpromises_la-mod_packages.lo `test -f 'mod_packages.c' || echo '$(srcdir)/'`mod_packages.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_packages.Tpo $(DEPDIR)/libpromises_la-mod_packages.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_packages.c' object='libpromises_la-mod_packages.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_packages.lo `test -f 'mod_packages.c' || echo '$(srcdir)/'`mod_packages.c libpromises_la-mod_files.lo: mod_files.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_files.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_files.Tpo -c -o libpromises_la-mod_files.lo `test -f 'mod_files.c' || echo '$(srcdir)/'`mod_files.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_files.Tpo $(DEPDIR)/libpromises_la-mod_files.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_files.c' object='libpromises_la-mod_files.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_files.lo `test -f 'mod_files.c' || echo '$(srcdir)/'`mod_files.c libpromises_la-mod_report.lo: mod_report.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_report.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_report.Tpo -c -o libpromises_la-mod_report.lo `test -f 'mod_report.c' || echo '$(srcdir)/'`mod_report.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_report.Tpo $(DEPDIR)/libpromises_la-mod_report.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_report.c' object='libpromises_la-mod_report.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_report.lo `test -f 'mod_report.c' || echo '$(srcdir)/'`mod_report.c libpromises_la-mod_storage.lo: mod_storage.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_storage.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_storage.Tpo -c -o libpromises_la-mod_storage.lo `test -f 'mod_storage.c' || echo '$(srcdir)/'`mod_storage.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_storage.Tpo $(DEPDIR)/libpromises_la-mod_storage.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_storage.c' object='libpromises_la-mod_storage.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_storage.lo `test -f 'mod_storage.c' || echo '$(srcdir)/'`mod_storage.c libpromises_la-mod_knowledge.lo: mod_knowledge.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_knowledge.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_knowledge.Tpo -c -o libpromises_la-mod_knowledge.lo `test -f 'mod_knowledge.c' || echo '$(srcdir)/'`mod_knowledge.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_knowledge.Tpo $(DEPDIR)/libpromises_la-mod_knowledge.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_knowledge.c' object='libpromises_la-mod_knowledge.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_knowledge.lo `test -f 'mod_knowledge.c' || echo '$(srcdir)/'`mod_knowledge.c libpromises_la-mod_measurement.lo: mod_measurement.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_measurement.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_measurement.Tpo -c -o libpromises_la-mod_measurement.lo `test -f 'mod_measurement.c' || echo '$(srcdir)/'`mod_measurement.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_measurement.Tpo $(DEPDIR)/libpromises_la-mod_measurement.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_measurement.c' object='libpromises_la-mod_measurement.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_measurement.lo `test -f 'mod_measurement.c' || echo '$(srcdir)/'`mod_measurement.c libpromises_la-mod_databases.lo: mod_databases.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_databases.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_databases.Tpo -c -o libpromises_la-mod_databases.lo `test -f 'mod_databases.c' || echo '$(srcdir)/'`mod_databases.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_databases.Tpo $(DEPDIR)/libpromises_la-mod_databases.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_databases.c' object='libpromises_la-mod_databases.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_databases.lo `test -f 'mod_databases.c' || echo '$(srcdir)/'`mod_databases.c libpromises_la-mod_services.lo: mod_services.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_services.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_services.Tpo -c -o libpromises_la-mod_services.lo `test -f 'mod_services.c' || echo '$(srcdir)/'`mod_services.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_services.Tpo $(DEPDIR)/libpromises_la-mod_services.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_services.c' object='libpromises_la-mod_services.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_services.lo `test -f 'mod_services.c' || echo '$(srcdir)/'`mod_services.c libpromises_la-mod_process.lo: mod_process.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_process.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_process.Tpo -c -o libpromises_la-mod_process.lo `test -f 'mod_process.c' || echo '$(srcdir)/'`mod_process.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_process.Tpo $(DEPDIR)/libpromises_la-mod_process.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_process.c' object='libpromises_la-mod_process.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_process.lo `test -f 'mod_process.c' || echo '$(srcdir)/'`mod_process.c libpromises_la-mod_environ.lo: mod_environ.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_environ.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_environ.Tpo -c -o libpromises_la-mod_environ.lo `test -f 'mod_environ.c' || echo '$(srcdir)/'`mod_environ.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_environ.Tpo $(DEPDIR)/libpromises_la-mod_environ.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_environ.c' object='libpromises_la-mod_environ.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_environ.lo `test -f 'mod_environ.c' || echo '$(srcdir)/'`mod_environ.c libpromises_la-mod_outputs.lo: mod_outputs.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-mod_outputs.lo -MD -MP -MF $(DEPDIR)/libpromises_la-mod_outputs.Tpo -c -o libpromises_la-mod_outputs.lo `test -f 'mod_outputs.c' || echo '$(srcdir)/'`mod_outputs.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-mod_outputs.Tpo $(DEPDIR)/libpromises_la-mod_outputs.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod_outputs.c' object='libpromises_la-mod_outputs.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-mod_outputs.lo `test -f 'mod_outputs.c' || echo '$(srcdir)/'`mod_outputs.c libpromises_la-unix.lo: unix.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) $(libpromises_la_CFLAGS) $(CFLAGS) -MT libpromises_la-unix.lo -MD -MP -MF $(DEPDIR)/libpromises_la-unix.Tpo -c -o libpromises_la-unix.lo `test -f 'unix.c' || echo '$(srcdir)/'`unix.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libpromises_la-unix.Tpo $(DEPDIR)/libpromises_la-unix.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='unix.c' object='libpromises_la-unix.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpromises_la_CFLAGS) $(CFLAGS) -c -o libpromises_la-unix.lo `test -f 'unix.c' || echo '$(srcdir)/'`unix.c .l.c: $(AM_V_LEX)$(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE) .y.c: $(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) conf.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) conf.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: $(HEADERS) $(SOURCES) conf.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) conf.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) @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) $(HEADERS) conf.h installdirs: for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(sbindir)"; 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) 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) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) 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 cf3lex.c -rm -f cf3parse.c -rm -f cf3parse.h -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ clean-sbinPROGRAMS mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-sbinPROGRAMS 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 uninstall-sbinPROGRAMS .MAKE: all check install install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool clean-sbinPROGRAMS ctags \ distclean distclean-compile distclean-generic distclean-hdr \ 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-sbinPROGRAMS \ 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 uninstall-sbinPROGRAMS cf3.defs.h: cd ./../core/src; svn update ln -fs ../../core/src/cf3.defs.h cf3.defs.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: ���������������������cfengine-3.2.4/src/cf3parse.y�����������������������������������������������������������������������0000644�0001750�0001750�00000053641�11715232734�012724� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ %{ /*******************************************************************/ /* */ /* PARSER for cfengine 3 */ /* */ /*******************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" extern char *yytext; static void fatal_yyerror(const char *s); %} %token ID QSTRING CLASS CATEGORY BUNDLE BODY ASSIGN ARROW NAKEDVAR %% specification: { yyerror("Something defined outside of a block or missing punctuation in input"); } | blocks; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ blocks: block | blocks block; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ block: bundle typeid blockid bundlebody | bundle typeid blockid usearglist bundlebody | body typeid blockid bodybody | body typeid blockid usearglist bodybody; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bundle: BUNDLE { DebugBanner("Bundle"); P.block = "bundle"; P.rval = NULL; P.currentRlist = NULL; P.currentstring = NULL; strcpy(P.blockid,""); strcpy(P.blocktype,""); }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ body: BODY { DebugBanner("Body"); P.block = "body"; strcpy(P.blockid,""); P.currentRlist = NULL; P.currentstring = NULL; strcpy(P.blocktype,""); }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ typeid: ID { strncpy(P.blocktype,P.currentid,CF_MAXVARSIZE); Debug("Found block type %s for %s\n",P.blocktype,P.block); P.useargs = NULL; }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ blockid: ID { strncpy(P.blockid,P.currentid,CF_MAXVARSIZE); Debug("Found identifier %s for %s\n",P.currentid,P.block); }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ usearglist: '(' aitems ')'; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ aitems: aitem | aitem ',' aitems |; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ aitem: ID /* recipient of argument is never a literal */ { AppendRlist(&(P.useargs),P.currentid,CF_SCALAR); }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bundlebody: '{' { if (RelevantBundle(THIS_AGENT,P.blocktype)) { Debug("We a compiling everything here\n"); INSTALL_SKIP = false; } else if (strcmp(THIS_AGENT,P.blocktype) != 0) { Debug("This is for a different agent\n"); INSTALL_SKIP = true; } P.currentbundle = AppendBundle(&BUNDLES,P.blockid,P.blocktype,P.useargs); P.useargs = NULL; } statements '}' { INSTALL_SKIP = false; Debug("End promise bundle\n\n"); }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ statements: statement | statements statement; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ statement: category | classpromises; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bodybody: '{' { P.currentbody = AppendBody(&BODIES,P.blockid,P.blocktype,P.useargs); P.useargs = NULL; strcpy(P.currentid,""); Debug("Starting block\n"); } bodyattribs '}' { Debug("End promise body\n"); }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bodyattribs: bodyattrib /* BODY ONLY */ | bodyattribs bodyattrib; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bodyattrib: class | selections; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ selections: selection /* BODY ONLY */ | selections selection; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ selection: id /* BODY ONLY */ ASSIGN rval { CheckSelection(P.blocktype,P.blockid,P.lval,P.rval,P.rtype); if (!INSTALL_SKIP) { if (P.currentclasses == NULL) { AppendConstraint(&((P.currentbody)->conlist),P.lval,P.rval,P.rtype,"any",P.isbody); } else { AppendConstraint(&((P.currentbody)->conlist),P.lval,P.rval,P.rtype,P.currentclasses,P.isbody); } } else { DeleteRvalItem(P.rval,P.rtype); } if (strcmp(P.blockid,"control") == 0 && strcmp(P.blocktype,"common") == 0) { if (strcmp(P.lval,"inputs") == 0) { if (IsDefinedClass(P.currentclasses)) { if (VINPUTLIST == NULL) { if (P.rtype == CF_LIST) { VINPUTLIST = P.rval; } else { yyerror("inputs promise must have a list as rvalue"); } } else { yyerror("Redefinition of input list (broken promise)"); } } } } P.rval = NULL; } ';' ; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ classpromises: classpromise /* BUNDLE ONLY */ | classpromises classpromise; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ classpromise: class | promises; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ promises: promise /* BUNDLE ONLY */ | promises promise; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ category: CATEGORY /* BUNDLE ONLY */ { Debug("\n* Begin new promise type category %s in function \n\n",P.currenttype); if (strcmp(P.block,"bundle") == 0) { CheckSubType(P.blocktype,P.currenttype); /* FIXME: unused? */ P.currentstype = AppendSubType(P.currentbundle,P.currenttype); } }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ promise: promiser /* BUNDLE ONLY */ ARROW rval /* This is full form with rlist promisees */ { if (P.currentclasses == NULL) { P.currentpromise = AppendPromise(P.currentstype,P.promiser,P.rval,P.rtype,"any",P.blockid,P.blocktype); } else { P.currentpromise = AppendPromise(P.currentstype,P.promiser,P.rval,P.rtype,P.currentclasses,P.blockid,P.blocktype); } } constraints ';' { Debug("End implicit promise %s\n\n",P.promiser); strcpy(P.currentid,""); P.currentRlist = NULL; free(P.promiser); if (P.currentstring) { free(P.currentstring); } P.currentstring = NULL; P.promiser = NULL; P.promisee = NULL; /* reset argptrs etc*/ } | promiser { if (P.currentclasses == NULL) { P.currentpromise = AppendPromise(P.currentstype,P.promiser,NULL,CF_NOPROMISEE,"any",P.blockid,P.blocktype); } else { P.currentpromise = AppendPromise(P.currentstype,P.promiser,NULL,CF_NOPROMISEE,P.currentclasses,P.blockid,P.blocktype); } } constraints ';' { Debug("End full promise with promisee %s\n\n",P.promiser); /* Don't free these */ strcpy(P.currentid,""); P.currentRlist = NULL; free(P.promiser); if (P.currentstring) { free(P.currentstring); } P.currentstring = NULL; P.promiser = NULL; P.promisee = NULL; /* reset argptrs etc*/ } ; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ constraints: constraint /* BUNDLE ONLY */ | constraints ',' constraint |; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ constraint: id /* BUNDLE ONLY */ ASSIGN rval { if (!INSTALL_SKIP) { struct SubTypeSyntax ss = CheckSubType(P.blocktype,P.currenttype); CheckConstraint(P.currenttype,P.blockid,P.lval,P.rval,P.rtype,ss); AppendConstraint(&(P.currentpromise->conlist),P.lval,P.rval,P.rtype,"any",P.isbody); P.rval = NULL; strcpy(P.lval,"no lval"); P.currentRlist = NULL; } else { DeleteRvalItem(P.rval,P.rtype); } }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ class: CLASS { Debug(" New class context \'%s\' :: \n\n",P.currentclasses); }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ id: ID { strncpy(P.lval,P.currentid,CF_MAXVARSIZE); P.currentRlist = NULL; Debug("Recorded LVAL %s\n",P.lval); }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ rval: ID { P.rval = strdup(P.currentid); P.rtype = CF_SCALAR; P.isbody = true; Debug("Recorded IDRVAL %s\n",P.rval); } | QSTRING { P.rval = P.currentstring; P.currentstring = NULL; P.rtype = CF_SCALAR; P.isbody = false; Debug("Recorded scalarRVAL %s\n",P.rval); if (P.currentpromise) { if (LvalWantsBody(P.currentpromise->agentsubtype,P.lval)) { yyerror("An rvalue is quoted, but we expect an unquoted body identifier"); } } } | NAKEDVAR { P.rval = P.currentstring; P.currentstring = NULL; P.rtype = CF_SCALAR; P.isbody = false; Debug("Recorded saclarvariableRVAL %s\n",P.rval); } | list { P.rval = P.currentRlist; P.currentRlist = NULL; P.isbody = false; P.rtype = CF_LIST; } | usefunction { P.isbody = false; P.rval = P.currentfncall[P.arg_nesting+1]; P.rtype = CF_FNCALL; }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ list: '{' litems '}' ; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ litems: litem | litem ',' litems |; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ litem: ID { AppendRlist((struct Rlist **)&P.currentRlist,P.currentid,CF_SCALAR); } | QSTRING { AppendRlist((struct Rlist **)&P.currentRlist,(void *)P.currentstring,CF_SCALAR); free(P.currentstring); P.currentstring = NULL; } | NAKEDVAR { AppendRlist((struct Rlist **)&P.currentRlist,(void *)P.currentstring,CF_SCALAR); free(P.currentstring); P.currentstring = NULL; } | usefunction { Debug("Install function call as list item from level %d\n",P.arg_nesting+1); AppendRlist((struct Rlist **)&P.currentRlist,(void *)P.currentfncall[P.arg_nesting+1],CF_FNCALL); DeleteFnCall(P.currentfncall[P.arg_nesting+1]); }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ functionid: ID { Debug("Found function identifier %s\n",P.currentid); } | NAKEDVAR { strncpy(P.currentid,P.currentstring,CF_MAXVARSIZE); // Make a var look like an ID free(P.currentstring); P.currentstring = NULL; Debug("Found variable in place of a function identifier %s\n",P.currentid); }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ promiser: QSTRING { P.promiser = P.currentstring; P.currentstring = NULL; Debug("Promising object name \'%s\'\n",P.promiser); }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ usefunction: functionid givearglist { Debug("Finished with function call, now at level %d\n\n",P.arg_nesting); }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ givearglist: '(' { if (++P.arg_nesting >= CF_MAX_NESTING) { fatal_yyerror("Nesting of functions is deeper than recommended"); } P.currentfnid[P.arg_nesting] = strdup(P.currentid); Debug("Start FnCall %s args level %d\n",P.currentfnid[P.arg_nesting],P.arg_nesting); } gaitems ')' { Debug("End args level %d\n",P.arg_nesting); P.currentfncall[P.arg_nesting] = NewFnCall(P.currentfnid[P.arg_nesting],P.giveargs[P.arg_nesting]); P.giveargs[P.arg_nesting] = NULL; strcpy(P.currentid,""); free(P.currentfnid[P.arg_nesting]); P.currentfnid[P.arg_nesting] = NULL; P.arg_nesting--; }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ gaitems: gaitem | gaitems ',' gaitem |; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ gaitem: ID { /* currently inside a use function */ AppendRlist(&P.giveargs[P.arg_nesting],P.currentid,CF_SCALAR); } | QSTRING { /* currently inside a use function */ AppendRlist(&P.giveargs[P.arg_nesting],P.currentstring,CF_SCALAR); free(P.currentstring); P.currentstring = NULL; } | NAKEDVAR { /* currently inside a use function */ AppendRlist(&P.giveargs[P.arg_nesting],P.currentstring,CF_SCALAR); free(P.currentstring); P.currentstring = NULL; } | usefunction { /* Careful about recursion */ AppendRlist(&P.giveargs[P.arg_nesting],(void *)P.currentfncall[P.arg_nesting+1],CF_FNCALL); DeleteRvalItem(P.currentfncall[P.arg_nesting+1],CF_FNCALL); }; %% /*****************************************************************/ void yyerror(const char *s) { char *sp = yytext; if (sp == NULL) { fprintf (stderr, "%s> %s:%d,%d: %s, near token \'NULL\'\n",VPREFIX,P.filename,P.line_no,P.line_pos,s); } else if (*sp == '\"' && strlen(sp) > 1) { sp++; } fprintf (stderr, "%s> %s:%d,%d: %s, near token \'%.20s\'\n",VPREFIX,P.filename,P.line_no,P.line_pos,s,sp); ERRORCOUNT++; if (ERRORCOUNT > 10) { FatalError("Too many errors"); } } static void fatal_yyerror(const char *s) { char *sp = yytext; /* Skip quotation mark */ if (sp && *sp == '\"' && sp[1]) { sp++; } FatalError("%s> %s: %d,%d: Fatal error during parsing: %s, near token \'%.20s\'\n", VPREFIX, P.filename, P.line_no, P.line_pos, s, sp ? sp : "NULL"); } /*****************************************************************/ /* EOF */ �����������������������������������������������������������������������������������������������cfengine-3.2.4/src/mon_temp.c�����������������������������������������������������������������������0000644�0001750�0001750�00000017516�11715232734�013007� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #include "cf3.defs.h" #include "cf3.extern.h" #include "monitoring.h" /* Globals */ static bool ACPI; static bool LMSENSORS; /* Prototypes */ static bool GetAcpi(double *cf_this); static bool GetLMSensors(double *cf_this); /* Implementation */ /****************************************************************************** * Motherboard sensors - how to standardize this somehow * We're mainly interested in temperature and power consumption, but only the * temperature is generally available. Several temperatures exist too ... ******************************************************************************/ void MonTempGatherData(double *cf_this) { Debug("GatherSensorData()\n"); switch(VSYSTEMHARDCLASS) { case linuxx: if (ACPI && GetAcpi(cf_this)) { return; } if (LMSENSORS && GetLMSensors(cf_this)) { return; } break; default: break; } } /******************************************************************************/ void MonTempInit(void) { struct stat statbuf; if (cfstat("/proc/acpi/thermal_zone",&statbuf) != -1) { Debug("Found an acpi service\n"); ACPI = true; } if (cfstat("/usr/bin/sensors",&statbuf) != -1) { if (statbuf.st_mode & 0111) { Debug("Found an lmsensor system\n"); LMSENSORS = true; } } } /******************************************************************************/ static bool GetAcpi(double *cf_this) { CFDIR *dirh; FILE *fp; const struct dirent *dirp; int count = 0; char path[CF_BUFSIZE],buf[CF_BUFSIZE],index[4]; double temp = 0; struct Attributes attr; memset(&attr,0,sizeof(attr)); attr.transaction.audit = false; Debug("ACPI temperature\n"); if ((dirh = OpenDirLocal("/proc/acpi/thermal_zone")) == NULL) { CfOut(cf_verbose,"opendir","Can't open directory %s\n",path); return false; } for (dirp = ReadDir(dirh); dirp != NULL; dirp = ReadDir(dirh)) { if (!ConsiderFile(dirp->d_name,path,attr,NULL)) { continue; } snprintf(path,CF_BUFSIZE,"/proc/acpi/thermal_zone/%s/temperature",dirp->d_name); if ((fp = fopen(path,"r")) == NULL) { printf("Couldn't open %s\n",path); continue; } fgets(buf,CF_BUFSIZE-1,fp); sscanf(buf,"%*s %lf",&temp); for (count = 0; count < 4; count++) { snprintf(index,2,"%d",count); if (strstr(dirp->d_name,index)) { switch (count) { case 0: cf_this[ob_temp0] = temp; break; case 1: cf_this[ob_temp1] = temp; break; case 2: cf_this[ob_temp2] = temp; break; case 3: cf_this[ob_temp3] = temp; break; } Debug("Set temp%d to %lf\n",count,temp); } } fclose(fp); } CloseDir(dirh); return true; } /******************************************************************************/ static bool GetLMSensors(double *cf_this) { FILE *pp; struct Item *ip,*list = NULL; double temp = 0; char name[CF_BUFSIZE]; int count; char vbuff[CF_BUFSIZE]; cf_this[ob_temp0] = 0.0; cf_this[ob_temp1] = 0.0; cf_this[ob_temp2] = 0.0; cf_this[ob_temp3] = 0.0; if ((pp = cf_popen("/usr/bin/sensors","r")) == NULL) { LMSENSORS = false; /* Broken */ return false; } CfReadLine(vbuff,CF_BUFSIZE,pp); while (!feof(pp)) { CfReadLine(vbuff,CF_BUFSIZE,pp); if (strstr(vbuff,"Temp")||strstr(vbuff,"temp")) { PrependItem(&list,vbuff,NULL); } } cf_pclose(pp); if (ListLen(list) > 0) { Debug("LM Sensors seemed to return ok data\n"); } else { return false; } /* lmsensor names are hopelessly inconsistent - so try a few things */ for (ip = list; ip != NULL; ip=ip->next) { for (count = 0; count < 4; count++) { snprintf(name,16,"CPU%d Temp:",count); if (strncmp(ip->name,name,strlen(name)) == 0) { sscanf(ip->name,"%*[^:]: %lf",&temp); switch (count) { case 0: cf_this[ob_temp0] = temp; break; case 1: cf_this[ob_temp1] = temp; break; case 2: cf_this[ob_temp2] = temp; break; case 3: cf_this[ob_temp3] = temp; break; } Debug("Set temp%d to %lf from what looks like cpu temperature\n",count,temp); } } } if (cf_this[ob_temp0] != 0) { /* We got something plausible */ return true; } /* Alternative name Core x: */ for (ip = list; ip != NULL; ip=ip->next) { for (count = 0; count < 4; count++) { snprintf(name,16,"Core %d:",count); if (strncmp(ip->name,name,strlen(name)) == 0) { sscanf(ip->name,"%*[^:]: %lf",&temp); switch (count) { case 0: cf_this[ob_temp0] = temp; break; case 1: cf_this[ob_temp1] = temp; break; case 2: cf_this[ob_temp2] = temp; break; case 3: cf_this[ob_temp3] = temp; break; } Debug("Set temp%d to %lf from what looks like core temperatures\n",count,temp); } } } if (cf_this[ob_temp0] != 0) { /* We got something plausible */ return true; } for (ip = list; ip != NULL; ip=ip->next) { if (strncmp(ip->name,"CPU Temp:",strlen("CPU Temp:")) == 0 ) { sscanf(ip->name,"%*[^:]: %lf",&temp); Debug("Setting temp0 to CPU Temp\n"); cf_this[ob_temp0] = temp; } if (strncmp(ip->name,"M/B Temp:",strlen("M/B Temp:")) == 0 ) { sscanf(ip->name,"%*[^:]: %lf",&temp); Debug("Setting temp0 to M/B Temp\n"); cf_this[ob_temp1] = temp; } if (strncmp(ip->name,"Sys Temp:",strlen("Sys Temp:")) == 0 ) { sscanf(ip->name,"%*[^:]: %lf",&temp); Debug("Setting temp0 to Sys Temp\n"); cf_this[ob_temp2] = temp; } if (strncmp(ip->name,"AUX Temp:",strlen("AUX Temp:")) == 0 ) { sscanf(ip->name,"%*[^:]: %lf",&temp); Debug("Setting temp0 to AUX Temp\n"); cf_this[ob_temp3] = temp; } } if (cf_this[ob_temp0] != 0) { /* We got something plausible */ return true; } /* Alternative name Core x: */ for (ip = list; ip != NULL; ip=ip->next) { for (count = 0; count < 4; count++) { snprintf(name,16,"temp%d:",count); if (strncmp(ip->name,name,strlen(name)) == 0) { sscanf(ip->name,"%*[^:]: %lf",&temp); switch (count) { case 0: cf_this[ob_temp0] = temp; break; case 1: cf_this[ob_temp1] = temp; break; case 2: cf_this[ob_temp2] = temp; break; case 3: cf_this[ob_temp3] = temp; break; } Debug("Set temp%d to %lf\n",count,temp); } } } /* Give up? */ DeleteItemList(list); return true; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/mod_knowledge.c������������������������������������������������������������������0000644�0001750�0001750�00000013607�11715232734�014004� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_knowledge.c */ /* */ /*****************************************************************************/ #define CF3_MOD_KNOWLEDGE #include "cf3.defs.h" #include "cf3.extern.h" /***********************************************************/ /* Read this module file backwards, as dependencies have */ /* to be defined first - these arrays declare pairs of */ /* constraints */ /* */ /* lval => rval */ /* */ /* in the form (lval,type,range) */ /* */ /* If the type is cf_body then the range is a pointer */ /* to another array of pairs, like in a body "sub-routine" */ /* */ /***********************************************************/ struct BodySyntax CF_RELATE_BODY[] = { {"forward_relationship",cf_str,"","Name of forward association between promiser topic and associates"}, {"backward_relationship",cf_str,"","Name of backward/inverse association from associates to promiser topic"}, {"associates",cf_slist,"","List of associated topics by this forward relationship"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ struct BodySyntax CF_OCCUR_BODIES[] = { {"represents",cf_slist,"","List of subtopics that explains the type(s) of information represented by the occurrence"}, {"representation",cf_opts,"literal,url,db,file,web,image,portal","How to interpret the promiser string e.g. actual data or reference to data"}, {"web_root",cf_str,"","Base URL of the occurrence when rendered as a web-URL (deprecated)"}, {"path_root",cf_str,"","Base path of the occurrence when locating file (deprecated)"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ struct BodySyntax CF_TOPICS_BODIES[] = { {"association",cf_body,CF_RELATE_BODY,"Declare associated topics"}, {"synonyms",cf_slist,"","A list of words to be treated as equivalents in the defined context"}, {"generalizations",cf_slist,"","A list of words to be treated as super-sets for the current topic, used when reasoning"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ struct BodySyntax CF_THING_BODIES[] = { {"synonyms",cf_slist,"","A list of words to be treated as equivalents in the defined context"}, {"affects",cf_slist,"","Special fixed relation for describing topics that are things"}, {"belongs_to",cf_slist,"","Special fixed relation for describing topics that are things"}, {"caused_by",cf_slist,"","Special fixed relation for describing topics that are things"}, {"causes",cf_slist,"","Special fixed relation for describing topics that are things"}, {"certainty",cf_opts,"certain,uncertain,possible","Selects the level of certainty for the proposed knowledge, for use in inferential reasoning"}, {"determines",cf_slist,"","Special fixed relation for describing topics that are things"}, {"generalizations",cf_slist,"","A list of words to be treated as super-sets for the current topic, used when reasoning"}, {"is_connected_to",cf_slist,"","Special fixed relation for describing topics that are things"}, {"is_located_in",cf_slist,"","Special fixed relation for describing topics that are things"}, {"is_part_of",cf_slist,"","Special fixed relation for describing topics that are things"}, {"needs",cf_slist,"","Special fixed relation for describing topics that are things"}, {"provides",cf_slist,"","Special fixed relation for describing topics that are things"}, {"uses",cf_slist,"","Special fixed relation for describing topics that are things"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ struct BodySyntax CF_INFER_BODIES[] = { {"precedents",cf_slist,"","The foundational vector for a trinary inference"}, {"qualifiers",cf_slist,"","The second vector in a trinary inference"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_KNOWLEDGE_SUBTYPES[] = { {"knowledge","inferences",CF_INFER_BODIES}, {"knowledge","things",CF_THING_BODIES}, {"knowledge","topics",CF_TOPICS_BODIES}, {"knowledge","occurrences",CF_OCCUR_BODIES}, {NULL,NULL,NULL}, }; �������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/bootstrap.c����������������������������������������������������������������������0000644�0001750�0001750�00000027504�11715232734�013204� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ /* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: bootstrap.c */ /* */ /* Created: Sun Jun 26 15:25:40 2011 */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /* Bootstrapping is a tricky sequence of fragile events. We need to map shakey/IP and identify policy hub IP in a special order to bootstrap the license and agents. During commercial bootstrap: - InitGA (generic-agent) loads the public key - The verifylicense function sets the policy hub but fails to verify license yet as there is no key/IP binding - Policy server gets set in workdir/state/am_policy_hub - The agents gets run and start this all over again, but this time the am_policy_hub is defined and caches the key/IP binding - Now the license has a binding, resolves the policy hub's key and succeeds */ /*****************************************************************************/ void CheckAutoBootstrap() { struct stat sb; char name[CF_BUFSIZE]; int repaired = false, have_policy = false, am_appliance = false; CfOut(cf_cmdout, "", "** CFEngine BOOTSTRAP probe initiated"); PrintVersionBanner("CFEngine"); printf("\n"); printf(" -> This host is: %s\n",VSYSNAME.nodename); printf(" -> Operating System Type is %s\n",VSYSNAME.sysname); printf(" -> Operating System Release is %s\n",VSYSNAME.release); printf(" -> Architecture = %s\n",VSYSNAME.machine); printf(" -> Internal soft-class is %s\n",CLASSTEXT[VSYSTEMHARDCLASS]); if (!IsPrivileged()) { CfOut(cf_error,""," !! You need root/administrator permissions to boostrap Cfengine"); FatalError("Insufficient privilege"); } if (IsDefinedClass("redhat")) { SetDocRoot("/var/www/html"); } if (IsDefinedClass("SuSE")) { SetDocRoot("/srv/www/htdocs"); } if (IsDefinedClass("debian")) { SetDocRoot("/var/www"); } snprintf(name,CF_BUFSIZE-1,"%s/inputs/failsafe.cf",CFWORKDIR); MapName(name); if (cfstat(name,&sb) == -1) { CreateFailSafe(name); repaired = true; } snprintf(name,CF_BUFSIZE-1,"%s/inputs/promises.cf",CFWORKDIR); MapName(name); if (cfstat(name,&sb) == -1) { CfOut(cf_cmdout,""," -> No previous policy has been cached on this host"); } else { CfOut(cf_cmdout,""," -> An existing policy was cached on this host in %s/inputs",CFWORKDIR); have_policy = true; } if (strlen(POLICY_SERVER) > 0) { CfOut(cf_cmdout,""," -> Assuming the policy distribution point at: %s:/var/cfengine/masterfiles\n",POLICY_SERVER); } else { if (have_policy) { CfOut(cf_cmdout,""," -> No policy distribution host was discovered - it might be contained in the existing policy, otherwise this will function autonomously\n"); } else if (repaired) { CfOut(cf_cmdout,""," -> No policy distribution host was defined - use --policy-server to set one\n",POLICY_SERVER); } } printf(" -> Attempting to initiate promised autonomous services...\n\n"); am_appliance = IsDefinedClass(CanonifyName(POLICY_SERVER)); snprintf(name,CF_MAXVARSIZE,"ipv4_%s",CanonifyName(POLICY_SERVER)); am_appliance |= IsDefinedClass(name); if (strlen(POLICY_SERVER) == 0) { am_appliance = false; } snprintf(name,sizeof(name),"%s/state/am_policy_hub",CFWORKDIR); MapName(name); if (am_appliance) { NewClass("am_policy_hub"); printf(" ** This host recognizes itself as a CFEngine Policy Hub, with policy distribution and knowledge base.\n"); printf(" -> The system is now converging. Full initialisation and self-analysis could take up to 30 minutes\n\n"); creat(name,0600); } else { unlink(name); } } /********************************************************************/ void SetPolicyServer(char *name) /* * If name contains a string, it's written to file, * if not, name is filled with the contents of file. */ { char file[CF_BUFSIZE]; FILE *fout,*fin; char fileContents[CF_MAXVARSIZE] = {0}; snprintf(file,CF_BUFSIZE-1,"%s/policy_server.dat",CFWORKDIR); MapName(file); if((fin = fopen(file,"r")) != NULL) { fscanf(fin,"%1023s",fileContents); fclose(fin); } // update file if different and we know what to put there if(EMPTY(name) && !EMPTY(fileContents)) { snprintf(name, CF_MAXVARSIZE, "%s", fileContents); } else if (!EMPTY(name) && strcmp(name,fileContents) != 0) { if ((fout = fopen(file,"w")) == NULL) { CfOut(cf_error,"fopen","Unable to write policy server file! (%s)",file); return; } fprintf(fout,"%s",name); fclose(fout); } if (EMPTY(name)) { // avoids "Scalar item in servers => { } in rvalue is out of bounds ..." // when NovaBase is checked with unprivileged (not bootstrapped) cf-promises NewScalar("sys","policy_hub","undefined",cf_str); } else { NewScalar("sys","policy_hub",name,cf_str); } } /********************************************************************/ void CreateFailSafe(char *name) { FILE *fout; if ((fout = fopen(name,"w")) == NULL) { CfOut(cf_error,"fopen","Unable to write failsafe file! (%s)",name); return; } CfOut(cf_cmdout,""," -> No policy failsafe discovered, assume temporary bootstrap vector\n"); fprintf(fout, "body common control\n" "{\n" "bundlesequence => { \"update\" };\n" "}\n\n" "body agent control\n" "{\n" "skipidentify => \"true\";\n" "}\n\n" "bundle agent update\n" "{\n" "classes:\n" " \"have_ppkeys\" expression => fileexists(\"$(sys.workdir)/ppkeys/localhost.pub\");\n" "\ncommands:\n" " !have_ppkeys::\n" " \"$(sys.cf_key)\";\n" "\nfiles:\n" " !windows::\n" " \"$(sys.workdir)/inputs\" \n" " handle => \"update_policy\",\n" " copy_from => u_scp(\"/var/cfengine/masterfiles\"),\n" " depth_search => u_recurse(\"inf\"),\n" " classes => success(\"got_policy\");\n" "\n" " \"$(sys.workdir)/bin/cf-twin\"\n" " comment => \"Make sure we maintain a clone of the agent for updating\",\n" " copy_from => u_cp(\"$(sys.workdir)/bin/cf-agent\"),\n" " perms => u_p(\"755\");\n" "\n" " \"$(sys.workdir)/lib-twin/.\"\n" " comment => \"Make sure we maintain a clone of the cf-twin libraries for updating\",\n" " copy_from => u_cp(\"$(sys.workdir)/lib/.\"),\n" " depth_search => u_recurse(\"1\");\n" "\n" " windows::\n" " \"$(sys.workdir)\\inputs\" \n" " handle => \"windows_update_policy\",\n" " copy_from => u_scp(\"/var/cfengine/masterfiles\"),\n" " depth_search => u_recurse(\"inf\"),\n" " classes => success(\"got_policy\");\n\n" "\n" " \"$(sys.workdir)\\bin-twin\\.\"\n" " comment => \"Make sure we maintain a clone of the binaries and libraries for updating\",\n" " copy_from => u_cp(\"$(sys.workdir)\\bin\\.\"),\n" " depth_search => u_recurse(\"1\");\n" "\n" "\n" "\nprocesses:\n" "!windows.got_policy::\n" "\"cf-execd\" restart_class => \"start_exec\";\n" "am_policy_hub.got_policy::\n" "\"cf-serverd\" restart_class => \"start_server\";\n\n" "\ncommands:\n" "start_exec.!windows::\n" "\"$(sys.cf_execd)\"," "classes => outcome(\"executor\");\n" "start_server::\n" "\"$(sys.cf_serverd)\"\n" "action => ifwin_bg,\n" "classes => outcome(\"server\");\n\n" "\nservices:\n" "windows.got_policy::\n" "\"CfengineNovaExec\"\n" " service_policy => \"start\",\n" " service_method => bootstart,\n" " classes => outcome(\"executor\");\n\n" "reports:\n" " bootstrap_mode.am_policy_hub::\n" " \"This host assumes the role of policy distribution host\";\n" " bootstrap_mode.!am_policy_hub::\n" " \"This autonomous node assumes the role of voluntary client\";\n" " got_policy:: \" -> Updated local policy from policy server\";\n" " !got_policy:: \" !! Failed to pull policy from policy server\";\n" " server_ok:: \" -> Started the server\";\n" " am_policy_hub.!server_ok:: \" !! Failed to start the server\";\n" " executor_ok:: \" -> Started the scheduler\";\n" " !executor_ok:: \" !! Did not start the scheduler\";\n" "}\n" "############################################\n" "body classes outcome(x)\n" "{\n" "promise_repaired => {\"$(x)_ok\"};\n" "}\n" "############################################\n" "body classes success(x)\n" "{\n" "promise_repaired => {\"$(x)\"};\n" "}\n" "############################################\n" "body perms u_p(p)\n" "{\n" "mode => \"$(p)\";\n" "}\n" "#############################################\n" "body copy_from u_scp(from)\n" "{\n" "source => \"$(from)\";\n" "compare => \"digest\";\n" "trustkey => \"true\";\n" "!am_policy_hub::\n" "servers => { \"$(sys.policy_hub)\" };\n" "}\n" "############################################\n" "body action u_background\n" "{\n" "background => \"true\";\n" "}\n" "############################################\n" "body depth_search u_recurse(d)\n" "{\n" "depth => \"$(d)\";\n" "exclude_dirs => { \"\\.svn\" };" "}\n" "############################################\n" "body service_method bootstart\n" "{\n" "service_autostart_policy => \"boot_time\";\n" "}\n" "############################################\n" "body action ifwin_bg\n" "{\n" "windows::\n" "background => \"true\";\n" "}\n" "############################################\n" "body copy_from u_cp(from)\n" "{\n" "source => \"$(from)\";\n" "compare => \"digest\";\n" "copy_backup => \"false\";\n" "}\n" "\n" ); fclose(fout); if(cf_chmod(name, S_IRUSR|S_IWUSR) == -1) { CfOut(cf_error, "cf_chmod", "!! Failed setting permissions on bootstrap policy (%s)", name); } } /********************************************************************/ /* Level */ /********************************************************************/ void SetDocRoot(char *name) { char file[CF_BUFSIZE]; FILE *fout,*fin; struct stat sb; if (LOOKUP) { CfOut(cf_verbose, "","Ignoring document root in lookup mode"); return; } snprintf(file,CF_BUFSIZE-1,"%s/document_root.dat",CFWORKDIR); MapName(file); if (cfstat(file,&sb) == -1 && strlen(name) > 0) { if ((fout = fopen(file,"w")) == NULL) { CfOut(cf_error,"fopen","Unable to write document root file! (%s)",file); return; } fprintf(fout,"%s",name); fclose(fout); CfOut(cf_verbose,""," -> Setting document root for a knowledge base to %s",name); strcpy(DOCROOT,name); NewScalar("sys","doc_root",DOCROOT,cf_str); } else { if ((fin = fopen(file,"r")) == NULL) { } else { file[0] = 0; fscanf(fin,"%255s",file); fclose(fin); CfOut(cf_verbose,""," -> Assuming document root for a knowledge base in %s",file); strcpy(DOCROOT,name); NewScalar("sys","doc_root",DOCROOT,cf_str); } } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/mon_load.c�����������������������������������������������������������������������0000644�0001750�0001750�00000003313�11715232734�012747� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #include "cf3.defs.h" #include "cf3.extern.h" #include "monitoring.h" #ifdef HAVE_SYS_LOADAVG_H # include <sys/loadavg.h> #else # define LOADAVG_5MIN 1 #endif /* Implementation */ #ifdef HAVE_GETLOADAVG void MonLoadGatherData(double *cf_this) { double load[LOADAVG_5MIN], sum = 0.0; int i,n; Debug("GatherLoadData\n\n"); if ((n = getloadavg(load,LOADAVG_5MIN)) == -1) { cf_this[ob_loadavg] = 0.0; } for (i = 0; i < n; ++i) { sum += load[i]; } sum /= (double) n; /* Scale load average by 100 to make it visible */ cf_this[ob_loadavg] = sum; CfOut(cf_verbose,"","Load Average = %.2lf\n",cf_this[ob_loadavg]); } #else void MonLoadGatherData(double *cf_this) { Debug("Average load data is not available.\n"); } #endif ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/exec_tools.c���������������������������������������������������������������������0000644�0001750�0001750�00000014271�11715232734�013330� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: exec_tools.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*************************************************************/ int IsExecutable(const char *file) { #ifdef MINGW return NovaWin_IsExecutable(file); #else return Unix_IsExecutable(file); #endif } /*******************************************************************/ int ShellCommandReturnsZero(char *comm,int useshell) { #ifdef MINGW return NovaWin_ShellCommandReturnsZero(comm,useshell); #else return Unix_ShellCommandReturnsZero(comm,useshell); #endif } /********************************************************************/ int GetExecOutput(char *command,char *buffer,int useshell) /* Buffer initially contains whole exec string */ { int offset = 0; char line[CF_EXPANDSIZE], *sp; FILE *pp; int flatten_newlines = false; Debug("GetExecOutput(%s,%s) - use shell = %d\n",command,buffer,useshell); if (useshell) { pp = cf_popen_sh(command,"r"); } else { pp = cf_popen(command,"r"); } if (pp == NULL) { CfOut(cf_error,"cf_popen","Couldn't open pipe to command %s\n",command); return false; } memset(buffer,0,CF_EXPANDSIZE); while (!feof(pp)) { if (ferror(pp)) /* abortable */ { fflush(pp); break; } CfReadLine(line,CF_EXPANDSIZE,pp); if (ferror(pp)) /* abortable */ { fflush(pp); break; } if (flatten_newlines) { for (sp = line; *sp != '\0'; sp++) { if (*sp == '\n') { *sp = ' '; } } } if (strlen(line)+offset > CF_EXPANDSIZE-10) { CfOut(cf_error,"","Buffer exceeded %d bytes in exec %s\n",CF_EXPANDSIZE,command); break; } if (flatten_newlines) { snprintf(buffer+offset,CF_EXPANDSIZE,"%s ",line); } else { snprintf(buffer+offset,CF_EXPANDSIZE,"%s\n",line); } offset += strlen(line)+1; } if (offset > 0) { Chop(buffer); } Debug("GetExecOutput got: [%s]\n",buffer); cf_pclose(pp); return true; } /**********************************************************************/ void ActAsDaemon(int preserve) { int fd, maxfd; #ifdef HAVE_SETSID setsid(); #endif CloseNetwork(); Cf3CloseLog(); fflush(NULL); fd = open(NULLFILE, O_RDWR, 0); if (fd != -1) { if (dup2(fd,STDIN_FILENO) == -1) { CfOut(cf_error,"dup2","Could not dup"); } if (dup2(fd,STDOUT_FILENO) == -1) { CfOut(cf_error,"dup2","Could not dup"); } dup2(fd,STDERR_FILENO); if (fd > STDERR_FILENO) { close(fd); } } chdir("/"); #ifdef HAVE_SYSCONF maxfd = sysconf(_SC_OPEN_MAX); #else # ifdef _POXIX_OPEN_MAX maxfd = _POSIX_OPEN_MAX; # else maxfd = 1024; # endif #endif for (fd = STDERR_FILENO + 1; fd < maxfd; ++fd) { if (fd != preserve) { close(fd); } } } /**********************************************************************/ /* * We need to be careful escaping commands: * * \ loses its magic inside single quotes, so we should not double it while * being there. * * single quotes start only with ', not with \' */ char *ShEscapeCommand(char *s) { static char buffer[CF_BUFSIZE]; char *spf,*spto; bool in_single_quotes = false; bool after_backslash = false; memset(buffer,0,CF_BUFSIZE); spto = buffer; for (spf = s; *spf != '\0'; spf++) { if (*spf == '\'') { if (in_single_quotes) /* ' in single quotes always terminates */ { in_single_quotes = false; } else { if (!after_backslash) /* \' does not start single quotes */ { in_single_quotes = true; } } } if (*spf == '\\') { if (!after_backslash) /* \\ does not count next character as escaped */ { after_backslash = true; } if (!in_single_quotes) /* Double the backslash outside of single quotes */ { *spto++ = '\\'; } } else { after_backslash = false; } *spto++ = *spf; } return buffer; } /**********************************************************************/ int ArgSplitCommand(char *comm,char arg[CF_MAXSHELLARGS][CF_BUFSIZE]) { char *sp; int i = 0; for (sp = comm; sp < comm+strlen(comm); sp++) { if (i >= CF_MAXSHELLARGS-1) { CfOut(cf_error,"","Too many arguments in embedded script"); FatalError("Use a wrapper"); } while (*sp == ' ' || *sp == '\t') { sp++; } switch (*sp) { case '\0': return(i-1); case '\"': sscanf (++sp,"%[^\"]",arg[i]); break; case '\'': sscanf (++sp,"%[^\']",arg[i]); break; case '`': sscanf (++sp,"%[^`]",arg[i]); break; default: sscanf (sp,"%s",arg[i]); break; } sp += strlen(arg[i]); i++; } return (i); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/alloc.c��������������������������������������������������������������������������0000644�0001750�0001750�00000004244�11715232734�012255� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #include "cf3.defs.h" #include "cf3.extern.h" /*****************************************************************************/ static void *CheckResult(void *ptr, const char *fn, bool check_result) { if (ptr == NULL && check_result) { FatalError("%s: Unable to allocate memory", fn); } return ptr; } /*****************************************************************************/ void *xmalloc(size_t size) { return CheckResult(malloc(size), "xmalloc", size != 0); } /*****************************************************************************/ void *xcalloc(size_t nmemb, size_t size) { return CheckResult(calloc(nmemb, size), "xcalloc", nmemb != 0 && size != 0); } /*****************************************************************************/ void *xrealloc(void *ptr, size_t size) { return CheckResult(realloc(ptr, size), "xrealloc", size != 0); } /*****************************************************************************/ char *xstrdup(const char *str) { return CheckResult(strdup(str), "xstrdup", true); } /*****************************************************************************/ char *xstrndup(const char *str, size_t n) { return CheckResult(strndup(str, n), "xstrndup", true); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/bool.h���������������������������������������������������������������������������0000644�0001750�0001750�00000002521�11707771422�012122� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifndef CFENGINE_BOOL_H #define CFENGINE_BOOL_H #ifdef HAVE_CONFIG_H # include "conf.h" #endif #ifdef HAVE_STDBOOL_H # include <stdbool.h> #else # ifndef HAVE__BOOL # ifdef __cplusplus typedef bool _Bool; # else # define _Bool signed char # endif # endif # define bool _Bool # define false 0 # define true 1 # define __bool_true_false_are_defined 1 #endif #endif �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/reporting.c����������������������������������������������������������������������0000644�0001750�0001750�00000055011�11715232734�013172� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: report.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" char *CFX[][2] = { {"<head>","</head>"}, {"<bundle>","</bundle>"}, {"<block>","</block>"}, {"<blockheader>","</blockheader>"}, {"<blockid>","</blockid>"}, {"<blocktype>","</blocktype>"}, {"<args>","</args>"}, {"<promise>","</promise>"}, {"<class>","</class>"}, {"<subtype>","</subtype>"}, {"<object>","</object>"}, {"<lval>","</lval>"}, {"<rval>","</rval>"}, {"<qstring>","</qstring>"}, {"<rlist>","</rlist>"}, {"<function>","</function>"}, {"\n","\n"}, {NULL,NULL} }; char *CFH[][2] = { {"<html><head>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/cf_enterprise.css\" />\n</head>\n","</html>"}, {"<div id=\"bundle\"><table class=border><tr><td><h2>","</td></tr></h2></table></div>"}, {"<div id=\"block\"><table class=border cellpadding=5 width=800>","</table></div>"}, {"<tr><th>","</th></tr>"}, {"<span class=\"bodyname\">","</span>"}, {"<span class=\"bodytype\">","</span>"}, {"<span class=\"args\">","</span>"}, {"<tr><td><table class=\"border\"><tr><td>","</td></tr></table></td></tr>"}, {"<span class=\"class\">","</span>"}, {"<span class=\"subtype\">","</span>"}, {"<b>","</b>"}, {"<br><span class=\"lval\">........................","</span>"}, {"<span class=\"rval\">","</span>"}, {"<span class=\"qstring\">","</span>"}, {"<span class=\"rlist\">","</span>"}, {"",""}, {"<tr><td>","</td></tr>"}, {NULL,NULL} }; /* Prototypes */ static void ShowControlBodies(void); static void ReportBanner(char *s); static void Indent(int i); static void ShowDataTypes(void); static void ShowBundleTypes(void); static void ShowPromiseTypesFor(char *s); static void ShowBodyParts(struct BodySyntax *bs); static void ShowRange(char *s,enum cfdatatype type); static void ShowBuiltinFunctions(void); /*******************************************************************/ /* Generic */ /*******************************************************************/ void ShowContext(void) { struct Item *ptr; char vbuff[CF_BUFSIZE]; int i; /* Text output */ CfOut(cf_verbose,"",""); for (i = 0; i < CF_ALPHABETSIZE; i++) { ptr = SortItemListNames(VHEAP.list[i]); VHEAP.list[i] = ptr; } if (VERBOSE||DEBUG) { snprintf(vbuff,CF_BUFSIZE,"Host %s's basic classified context",VFQNAME); ReportBanner(vbuff); printf("%s> -> Defined classes = { ",VPREFIX); ListAlphaList(stdout,VHEAP,' '); printf("}\n"); CfOut(cf_verbose,"",""); printf("%s> -> Negated Classes = { ",VPREFIX); for (ptr = VNEGHEAP; ptr != NULL; ptr=ptr->next) { printf("%s ",ptr->name); } printf ("}\n"); } CfOut(cf_verbose,"",""); } /*******************************************************************/ static void ShowControlBodies() { int i; printf("<h1>Control bodies for cfengine components</h1>\n"); printf("<div id=\"bundles\">"); for (i = 0; CF_ALL_BODIES[i].btype != NULL; i++) { printf("<h4>COMPONENT %s</h4>\n", CF_ALL_BODIES[i].btype); printf("<h4>PROMISE TYPE %s</h4>\n",CF_ALL_BODIES[i].subtype); ShowBodyParts(CF_ALL_BODIES[i].bs); } } /*******************************************************************/ void ShowPromises(struct Bundle *bundles,struct Body *bodies) { #if defined(HAVE_NOVA) Nova_StoreUnExpandedPromises(bundles,bodies); #else ShowPromisesInReport(bundles,bodies); #endif } /*******************************************************************/ void ShowPromisesInReport(struct Bundle *bundles, struct Body *bodies) { char rettype; void *retval; char *v; char vbuff[CF_BUFSIZE]; struct Bundle *bp; struct Rlist *rp; struct SubType *sp; struct Promise *pp; struct Body *bdp; if (GetVariable("control_common","version",&retval,&rettype) != cf_notype) { v = (char *)retval; } else { v = "not specified"; } ReportBanner("Promises"); snprintf(vbuff,CF_BUFSIZE-1,"Cfengine Site Policy Summary (version %s)",v); CfHtmlHeader(FREPORT_HTML,vbuff,STYLESHEET,WEBDRIVER,BANNER); fprintf(FREPORT_HTML,"<p>"); for (bp = bundles; bp != NULL; bp=bp->next) { fprintf(FREPORT_HTML,"%s Bundle %s%s%s %s%s%s\n", CFH[cfx_bundle][cfb], CFH[cfx_blocktype][cfb],bp->type,CFH[cfx_blocktype][cfe], CFH[cfx_blockid][cfb],bp->name,CFH[cfx_blockid][cfe]); fprintf(FREPORT_HTML," %s ARGS:%s\n\n",CFH[cfx_line][cfb],CFH[cfx_line][cfe]); fprintf(FREPORT_TXT,"Bundle %s in the context of %s\n\n",bp->name,bp->type); fprintf(FREPORT_TXT," ARGS:\n\n"); for (rp = bp->args; rp != NULL; rp=rp->next) { fprintf(FREPORT_HTML,"%s",CFH[cfx_line][cfb]); fprintf(FREPORT_HTML," scalar arg %s%s%s\n",CFH[cfx_args][cfb],(char *)rp->item,CFH[cfx_args][cfe]); fprintf(FREPORT_HTML,"%s",CFH[cfx_line][cfe]); fprintf(FREPORT_TXT," scalar arg %s\n\n",(char *)rp->item); } fprintf(FREPORT_TXT," {\n"); fprintf(FREPORT_HTML,"%s",CFH[cfx_promise][cfb]); for (sp = bp->subtypes; sp != NULL; sp = sp->next) { fprintf(FREPORT_HTML,"%s",CFH[cfx_line][cfb]); fprintf(FREPORT_HTML,"%s",CFH[cfx_line][cfe]); fprintf(FREPORT_TXT," TYPE: %s\n\n",sp->name); for (pp = sp->promiselist; pp != NULL; pp = pp->next) { ShowPromise(pp,6); } } fprintf(FREPORT_TXT," }\n"); fprintf(FREPORT_TXT,"\n\n"); fprintf(FREPORT_HTML,"%s\n",CFH[cfx_promise][cfe]); fprintf(FREPORT_HTML,"%s\n",CFH[cfx_line][cfe]); fprintf(FREPORT_HTML,"%s\n",CFH[cfx_bundle][cfe]); } /* Now summarize the remaining bodies */ fprintf(FREPORT_HTML,"<h1>All Bodies</h1>"); fprintf(FREPORT_TXT,"\n\nAll Bodies\n\n"); for (bdp = bodies; bdp != NULL; bdp=bdp->next) { fprintf(FREPORT_HTML,"%s%s\n",CFH[cfx_line][cfb],CFH[cfx_block][cfb]); fprintf(FREPORT_HTML,"%s\n",CFH[cfx_promise][cfb]); ShowBody(bdp,3); fprintf(FREPORT_TXT,"\n"); fprintf(FREPORT_HTML,"%s\n",CFH[cfx_promise][cfe]); fprintf(FREPORT_HTML,"%s%s \n ",CFH[cfx_block][cfe],CFH[cfx_line][cfe]); fprintf(FREPORT_HTML,"</p>"); } CfHtmlFooter(FREPORT_HTML,FOOTER); } /*******************************************************************/ void ShowPromise(struct Promise *pp, int indent) { char *v,rettype; void *retval; if (GetVariable("control_common","version",&retval,&rettype) != cf_notype) { v = (char *)retval; } else { v = "not specified"; } #if defined(HAVE_NOVA) Nova_ShowPromise(v, pp, indent); #else ShowPromiseInReport(v, pp, indent); #endif } /*******************************************************************/ void ShowPromiseInReport(const char *version, struct Promise* pp, int indent) { struct Constraint *cp; struct Body *bp; struct Rlist *rp; struct FnCall *fp; double av; double var; double val; time_t last; fprintf(FREPORT_HTML,"%s\n",CFH[cfx_line][cfb]); fprintf(FREPORT_HTML,"%s\n",CFH[cfx_promise][cfb]); fprintf(FREPORT_HTML,"Promise type is %s%s%s, ",CFH[cfx_subtype][cfb],pp->agentsubtype,CFH[cfx_subtype][cfe]); fprintf(FREPORT_HTML,"<a href=\"#class_context\">context</a> is %s%s%s <br><hr>\n\n",CFH[cfx_class][cfb],pp->classes,CFH[cfx_class][cfe]); if (pp->promisee) { fprintf(FREPORT_HTML,"Resource object %s\'%s\'%s promises %s (about %s) to",CFH[cfx_object][cfb],pp->promiser,CFH[cfx_object][cfe],CFH[cfx_object][cfb],pp->agentsubtype); ShowRval(FREPORT_HTML,pp->promisee,pp->petype); fprintf(FREPORT_HTML,"%s\n\n",CFH[cfx_object][cfe]); } else { fprintf(FREPORT_HTML,"Resource object %s\'%s\'%s make the promise to default promisee 'cf-%s' (about %s)...\n\n",CFH[cfx_object][cfb],pp->promiser,CFH[cfx_object][cfe],pp->bundletype,pp->agentsubtype); } Indent(indent); if (pp->promisee != NULL) { fprintf(FREPORT_TXT,"%s promise by \'%s\' -> ",pp->agentsubtype,pp->promiser); ShowRval(FREPORT_TXT,pp->promisee,pp->petype); fprintf(FREPORT_TXT," if context is %s\n\n",pp->classes); } else { fprintf(FREPORT_TXT,"%s promise by \'%s\' (implicit) if context is %s\n\n",pp->agentsubtype,pp->promiser,pp->classes); } for (cp = pp->conlist; cp != NULL; cp = cp->next) { fprintf(FREPORT_HTML,"%s%s%s => ",CFH[cfx_lval][cfb],cp->lval,CFH[cfx_lval][cfe]); Indent(indent+3); fprintf(FREPORT_TXT,"%10s => ",cp->lval); switch (cp->type) { case CF_SCALAR: if ((bp = IsBody(BODIES,(char *)cp->rval))) { ShowBody(bp,15); } else { fprintf(FREPORT_HTML,"%s",CFH[cfx_rval][cfb]); ShowRval(FREPORT_HTML,cp->rval,cp->type); /* literal */ fprintf(FREPORT_HTML,"%s",CFH[cfx_rval][cfe]); ShowRval(FREPORT_TXT,cp->rval,cp->type); /* literal */ } break; case CF_LIST: rp = (struct Rlist *)cp->rval; fprintf(FREPORT_HTML,"%s",CFH[cfx_rval][cfb]); ShowRlist(FREPORT_HTML,rp); fprintf(FREPORT_HTML,"%s",CFH[cfx_rval][cfe]); ShowRlist(FREPORT_TXT,rp); break; case CF_FNCALL: fp = (struct FnCall *)cp->rval; if ((bp = IsBody(BODIES,fp->name))) { ShowBody(bp,15); } else { ShowRval(FREPORT_HTML,cp->rval,cp->type); /* literal */ ShowRval(FREPORT_TXT,cp->rval,cp->type); /* literal */ } break; } if (cp->type != CF_FNCALL) { Indent(indent); fprintf(FREPORT_HTML," , if body <a href=\"#class_context\">context</a> <span class=\"context\">%s</span>\n",cp->classes); fprintf(FREPORT_TXT," if body context %s\n",cp->classes); } } av = 0; var = 0; val = 0; last = 0; if (pp->audit) { Indent(indent); fprintf(FREPORT_HTML,"<p><small>Promise (version %s) belongs to bundle <b>%s</b> (type %s) in \'<i>%s</i>\' near line %d</small></p>\n",version,pp->bundle,pp->bundletype,pp->audit->filename,pp->lineno); } fprintf(FREPORT_HTML,"%s\n",CFH[cfx_promise][cfe]); fprintf(FREPORT_HTML,"%s\n",CFH[cfx_line][cfe]); if (pp->audit) { Indent(indent); fprintf(FREPORT_TXT,"Promise (version %s) belongs to bundle \'%s\' (type %s) in file \'%s\' near line %d\n",version,pp->bundle,pp->bundletype,pp->audit->filename,pp->lineno); fprintf(FREPORT_TXT,"\n\n"); } else { Indent(indent); fprintf(FREPORT_TXT,"Promise (version %s) belongs to bundle \'%s\' (type %s) near line %d\n\n",version,pp->bundle,pp->bundletype,pp->lineno); } } /*******************************************************************/ void ShowScopedVariables() /* WARNING: Not thread safe (access to VSCOPE) */ { struct Scope *ptr; fprintf(FREPORT_HTML,"<div id=\"showvars\">"); for (ptr = VSCOPE; ptr != NULL; ptr=ptr->next) { if (strcmp(ptr->scope,"this") == 0) { continue; } fprintf(FREPORT_HTML,"<h4>\nScope %s:<h4>",ptr->scope); fprintf(FREPORT_TXT,"\nScope %s:\n",ptr->scope); PrintHashes(FREPORT_HTML,ptr->hashtable,1); PrintHashes(FREPORT_TXT,ptr->hashtable,0); } fprintf(FREPORT_HTML,"</div>"); } /*******************************************************************/ void Banner(char *s) { CfOut(cf_verbose,"","***********************************************************\n"); CfOut(cf_verbose,""," %s ",s); CfOut(cf_verbose,"","***********************************************************\n"); } /*******************************************************************/ static void ReportBanner(char *s) { fprintf(FREPORT_TXT,"***********************************************************\n"); fprintf(FREPORT_TXT," %s \n",s); fprintf(FREPORT_TXT,"***********************************************************\n"); } /**************************************************************/ void BannerSubType(char *bundlename,char *type,int pass) { CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,""," =========================================================\n"); CfOut(cf_verbose,""," %s in bundle %s (%d)\n",type,bundlename,pass); CfOut(cf_verbose,""," =========================================================\n"); CfOut(cf_verbose,"","\n"); } /**************************************************************/ void BannerSubSubType(char *bundlename,char *type) { int i; if (strcmp(type,"processes") == 0) { struct Item *ip; /* Just parsed all local classes */ CfOut(cf_verbose,""," ??? Local class context: \n"); for (i = 0; i < CF_ALPHABETSIZE; i++) { for (ip = VADDCLASSES.list[i]; ip != NULL; ip=ip->next) { printf(" %sǹ",ip->name); } } CfOut(cf_verbose,"","\n"); } CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,""," = = = = = = = = = = = = = = = = = = = = = = = = = = = = \n"); CfOut(cf_verbose,""," %s in bundle %s\n",type,bundlename); CfOut(cf_verbose,""," = = = = = = = = = = = = = = = = = = = = = = = = = = = = \n"); CfOut(cf_verbose,"","\n"); } /*******************************************************************/ void DebugBanner(char *s) { Debug("----------------------------------------------------------------\n"); Debug(" %s \n",s); Debug("----------------------------------------------------------------\n"); } /*******************************************************************/ static void Indent(int i) { int j; for (j = 0; j < i; j++) { fputc(' ',FREPORT_TXT); } } /*******************************************************************/ void ShowBody(struct Body *body,int indent) { struct Rlist *rp; struct Constraint *cp; fprintf(FREPORT_TXT,"%s body for type %s",body->name,body->type); fprintf(FREPORT_HTML," %s%s%s ",CFH[cfx_blocktype][cfb],body->type,CFH[cfx_blocktype][cfe]); fprintf(FREPORT_HTML,"%s%s%s",CFH[cfx_blockid][cfb],body->name,CFH[cfx_blockid][cfe]); if (body->args == NULL) { fprintf(FREPORT_HTML,"%s(no parameters)%s\n",CFH[cfx_args][cfb],CFH[cfx_args][cfe]); fprintf(FREPORT_TXT,"(no parameters)\n"); } else { fprintf(FREPORT_HTML,"("); fprintf(FREPORT_TXT,"\n"); for (rp = body->args; rp != NULL; rp=rp->next) { if (rp->type != CF_SCALAR) { FatalError("ShowBody - non-scalar parameter container"); } fprintf(FREPORT_HTML,"%s%s%s,\n",CFH[cfx_args][cfb],(char *)rp->item,CFH[cfx_args][cfe]); Indent(indent); fprintf(FREPORT_TXT,"arg %s\n",(char *)rp->item); } fprintf(FREPORT_HTML,")"); fprintf(FREPORT_TXT,"\n"); } Indent(indent); fprintf(FREPORT_TXT,"{\n"); for (cp = body->conlist; cp != NULL; cp=cp->next) { fprintf(FREPORT_HTML,"%s.....%s%s => ",CFH[cfx_lval][cfb],cp->lval,CFH[cfx_lval][cfe]); Indent(indent); fprintf(FREPORT_TXT,"%s => ",cp->lval); fprintf(FREPORT_HTML,"\'%s",CFH[cfx_rval][cfb]); ShowRval(FREPORT_HTML,cp->rval,cp->type); /* literal */ ShowRval(FREPORT_TXT,cp->rval,cp->type); /* literal */ fprintf(FREPORT_HTML,"\'%s",CFH[cfx_rval][cfe]); if (cp->classes != NULL) { fprintf(FREPORT_HTML," if sub-body context %s%s%s\n",CFH[cfx_class][cfb],cp->classes,CFH[cfx_class][cfe]); fprintf(FREPORT_TXT," if sub-body context %s\n",cp->classes); } else { fprintf(FREPORT_TXT,"\n"); } } Indent(indent); fprintf(FREPORT_TXT,"}\n"); } /*******************************************************************/ void SyntaxTree(void) { printf("<h1>CFENGINE %s SYNTAX</h1><p>",Version()); printf("<table class=\"frame\"><tr><td>\n"); ShowDataTypes(); ShowControlBodies(); ShowBundleTypes(); ShowBuiltinFunctions(); printf("</td></tr></table>\n"); } /*******************************************************************/ /* Level 2 */ /*******************************************************************/ static void ShowDataTypes() { int i; printf("<table class=border><tr><td><h1>Promise datatype legend</h1>\n"); printf("<ol>\n"); for (i = 0; strcmp(CF_DATATYPES[i],"<notype>") != 0; i++) { printf("<li>%s</li>\n",CF_DATATYPES[i]); } printf("</ol></td></tr></table>\n\n"); } /*******************************************************************/ static void ShowBundleTypes() { int i; struct SubTypeSyntax *st; printf("<h1>Bundle types (software components)</h1>\n"); printf("<div id=\"bundles\">"); for (i = 0; CF_ALL_BODIES[i].btype != NULL; i++) { printf("<h4>COMPONENT %s</h4>\n", CF_ALL_BODIES[i].btype); ShowPromiseTypesFor(CF_ALL_BODIES[i].btype); } printf("<h4>EMBEDDED BUNDLE edit_line<h4>\n"); ShowPromiseTypesFor("*"); st = CF_FILES_SUBTYPES; for (i = 0; st[i].btype != NULL; i++) { if (strcmp("edit_line",st[i].btype) == 0) { ShowBodyParts(st[i].bs); } } printf("</div>\n\n"); } /*******************************************************************/ static void ShowPromiseTypesFor(char *s) { int i,j; struct SubTypeSyntax *st; printf("<div id=\"promisetype\">"); printf("<h4>Promise types for %s bundles</h4>\n",s); printf("<table class=border><tr><td>\n"); for (i = 0; i < CF3_MODULES; i++) { st = CF_ALL_SUBTYPES[i]; for (j = 0; st[j].btype != NULL; j++) { if (strcmp(s,st[j].btype) == 0 || strcmp("*",st[j].btype) == 0) { printf("<h4>PROMISE TYPE %s</h4>\n",st[j].subtype); ShowBodyParts(st[j].bs); } } } printf("</td></tr></table>\n"); printf("</div>\n\n"); } /*******************************************************************/ static void ShowBodyParts(struct BodySyntax *bs) { int i; if (bs == NULL) { return; } printf("<div id=\"bodies\"><table class=\"border\">\n"); for (i = 0; bs[i].lval != NULL; i++) { if (bs[i].range == (void *)CF_BUNDLE) { printf("<tr><td>%s</td><td>%s</td><td>(Separate Bundle)</td></tr>\n",bs[i].lval,CF_DATATYPES[bs[i].dtype]); } else if (bs[i].dtype == cf_body) { printf("<tr><td>%s</td><td>%s</td><td>",bs[i].lval,CF_DATATYPES[bs[i].dtype]); ShowBodyParts((struct BodySyntax *)bs[i].range); printf("</td></tr>\n"); } else { printf("<tr><td>%s</td><td>%s</td><td>",bs[i].lval,CF_DATATYPES[bs[i].dtype]); ShowRange((char *)bs[i].range,bs[i].dtype); printf("</td><td>"); printf("<div id=\"description\">%s</div>",bs[i].description); printf("</td></tr>\n"); } } printf("</table></div>\n"); } /*******************************************************************/ static void ShowRange(char *s,enum cfdatatype type) { char *sp; if (strlen(s) == 0) { printf("(arbitrary string)"); return; } switch (type) { case cf_opts: case cf_olist: for (sp = s; *sp != '\0'; sp++) { printf("%c",*sp); if (*sp == ',') { printf("<br>"); } } break; default: for (sp = s; *sp != '\0'; sp++) { printf("%c",*sp); if (*sp == '|') { printf("<br>"); } } } } /*******************************************************************/ static void ShowBuiltinFunctions() { int i; printf("<h1>builtin functions</h1>\n"); printf("<center><table id=functionshow>\n"); printf("<tr><th>Return type</th><th>Function name</th><th>Arguments</th><th>Description</th></tr>\n"); for (i = 0; CF_FNCALL_TYPES[i].name != NULL; i++) { printf("<tr><td>%s</td><td>%s()</td><td>%d args expected</td><td>%s</td></tr>\n", CF_DATATYPES[CF_FNCALL_TYPES[i].dtype], CF_FNCALL_TYPES[i].name, CF_FNCALL_TYPES[i].numargs, CF_FNCALL_TYPES[i].description ); } printf("</table></center>\n"); } /*******************************************************************/ void ShowAllReservedWords() { int i,j,k,l; struct Item *ip,*list = NULL; struct SubTypeSyntax *ss; struct BodySyntax *bs,*bs2; for (i = 0; CF_ALL_BODIES[i].subtype != NULL; i++) { IdempPrependItem(&list,CF_ALL_BODIES[i].subtype,NULL); bs = CF_ALL_BODIES[i].bs; for (l = 0; bs[l].lval != NULL; l++) { IdempPrependItem(&list,bs[l].lval,NULL); } } /* Now check the functional modules - extra level of indirection */ for (i = 0; i < CF3_MODULES; i++) { if ((ss = CF_ALL_SUBTYPES[i]) == NULL) { continue; } for (j = 0; ss[j].subtype != NULL; j++) { if ((bs = ss[j].bs) == NULL) { continue; } IdempPrependItem(&list,ss[j].subtype,NULL); for (l = 0; bs[l].range != NULL; l++) { if (bs[l].dtype == cf_body) { bs2 = (struct BodySyntax *)(bs[l].range); if (bs2 == NULL || bs2 == (void *)CF_BUNDLE) { continue; } for (k = 0; bs2[k].dtype != cf_notype; k++) { /* Either module defined or common */ IdempPrependItem(&list,bs2[k].lval,NULL); } } } } } for (ip = list; ip != NULL; ip=ip->next) { printf(" \"%s\",",ip->name); } DeleteItemList(list); } /*******************************************************************/ void ReportError(char *s) { if (PARSING) { yyerror(s); } else { Chop(s); FatalError("Validation: %s\n",s); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/mod_files.c����������������������������������������������������������������������0000644�0001750�0001750�00000050225�11715232734�013124� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_files.c */ /* */ /*****************************************************************************/ /* This file can act as a template for adding functionality to cfengine 3. All functionality can be added by extending the main array CF_MOD_SUBTYPES[CF3_MODULES] and its array dimension, in mod_common, in the manner shown here. */ #define CF3_MOD_FILES #include "cf3.defs.h" #include "cf3.extern.h" /***********************************************************/ /* Read this module file backwards, as dependencies have */ /* to be defined first - these arrays declare pairs of */ /* constraints */ /* */ /* lval => rval */ /* */ /* in the form (lval,type,range) */ /* */ /* If the type is cf_body then the range is a pointer */ /* to another array of pairs, like in a body "sub-routine" */ /* */ /***********************************************************/ /**************************************************************/ /* editing */ /**************************************************************/ struct BodySyntax CF_LOCATION_BODY[] = { {"before_after",cf_opts,"before,after","Menu option, point cursor before of after matched line"}, {"first_last",cf_opts,"first,last","Menu option, choose first or last occurrence of match in file"}, {"select_line_matching",cf_str,CF_ANYSTRING,"Regular expression for matching file line location"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_EDITCOL_BODY[] = { {"allow_blank_fields",cf_opts,CF_BOOL,"true/false allow blank fields in a line (do not purge)"}, {"extend_fields",cf_opts,CF_BOOL,"true/false add new fields at end of line if necessary to complete edit"}, {"field_operation",cf_opts,"prepend,append,alphanum,delete,set","Menu option policy for editing subfields"}, {"field_separator",cf_str,CF_ANYSTRING,"The regular expression used to separate fields in a line"}, {"field_value",cf_str,CF_ANYSTRING,"Set field value to a fixed value"}, {"select_field",cf_int,"0,99999999","Integer index of the field required 0..n (default starts from 1)"}, {"start_fields_from_zero",cf_opts,CF_BOOL,"If set, the default field numbering starts from 0"}, {"value_separator",cf_str,CF_CHARRANGE,"Character separator for subfields inside the selected field"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_REPLACEWITH_BODY[] = { {"occurrences",cf_opts,"all,first","Menu option to replace all occurrences or just first (NB the latter is non-convergent)"}, {"replace_value",cf_str,CF_ANYSTRING,"Value used to replace regular expression matches in search"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_EDSCOPE_BODY[] = { {"include_start_delimiter",cf_opts,CF_BOOL,"Whether to include the section delimiter"}, {"include_end_delimiter",cf_opts,CF_BOOL,"Whether to include the section delimiter"}, {"select_start",cf_str,CF_ANYSTRING,"Regular expression matching start of edit region"}, {"select_end",cf_str,CF_ANYSTRING,"Regular expression matches end of edit region from start"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_DELETESELECT_BODY[] = { {"delete_if_startwith_from_list",cf_slist,CF_ANYSTRING,"Delete line if it starts with a string in the list"}, {"delete_if_not_startwith_from_list",cf_slist,CF_ANYSTRING,"Delete line if it DOES NOT start with a string in the list"}, {"delete_if_match_from_list",cf_slist,CF_ANYSTRING,"Delete line if it fully matches a regex in the list"}, {"delete_if_not_match_from_list",cf_slist,CF_ANYSTRING,"Delete line if it DOES NOT fully match a regex in the list"}, {"delete_if_contains_from_list",cf_slist,CF_ANYSTRING,"Delete line if a regex in the list match a line fragment"}, {"delete_if_not_contains_from_list",cf_slist,CF_ANYSTRING,"Delete line if a regex in the list DOES NOT match a line fragment"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_INSERTSELECT_BODY[] = { {"insert_if_startwith_from_list",cf_slist,CF_ANYSTRING,"Insert line if it starts with a string in the list"}, {"insert_if_not_startwith_from_list",cf_slist,CF_ANYSTRING,"Insert line if it DOES NOT start with a string in the list"}, {"insert_if_match_from_list",cf_slist,CF_ANYSTRING,"Insert line if it fully matches a regex in the list"}, {"insert_if_not_match_from_list",cf_slist,CF_ANYSTRING,"Insert line if it DOES NOT fully match a regex in the list"}, {"insert_if_contains_from_list",cf_slist,CF_ANYSTRING,"Insert line if a regex in the list match a line fragment"}, {"insert_if_not_contains_from_list",cf_slist,CF_ANYSTRING,"Insert line if a regex in the list DOES NOT match a line fragment"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_INSERTLINES_BODIES[] = { {"expand_scalars",cf_opts,CF_BOOL,"Expand any unexpanded variables"}, {"insert_type",cf_opts,"literal,string,file,preserve_block","Type of object the promiser string refers to"}, {"insert_select",cf_body,CF_INSERTSELECT_BODY,"Insert only if lines pass filter criteria"}, {"location",cf_body,CF_LOCATION_BODY,"Specify where in a file an insertion will be made"}, {"whitespace_policy",cf_olist,"ignore_leading,ignore_trailing,ignore_embedded,exact_match","Criteria for matching and recognizing existing lines"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_DELETELINES_BODIES[] = { {"delete_select",cf_body,CF_DELETESELECT_BODY,"Delete only if lines pass filter criteria"}, {"not_matching",cf_opts,CF_BOOL,"true/false negate match criterion"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_COLUMN_BODIES[] = { {"edit_field",cf_body,CF_EDITCOL_BODY,"Edit line-based file as matrix of fields"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_REPLACE_BODIES[] = { {"replace_with",cf_body,CF_REPLACEWITH_BODY,"Search-replace pattern"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ /* Common to all edit_line promises */ /**************************************************************/ struct BodySyntax CF_COMMON_EDITBODIES[] = { {"select_region",cf_body,CF_EDSCOPE_BODY,"Limit edits to a demarked region of the file"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ /* Main files */ /**************************************************************/ struct BodySyntax CF_ACL_BODY[] = { {"aces",cf_slist,"((user|group):[^:]+:[-=+,rwx()dtTabBpcoD]*(:(allow|deny))?)|((all|mask):[-=+,rwx()]*(:(allow|deny))?)","Native settings for access control entry"}, {"acl_directory_inherit",cf_opts,"nochange,parent,specify,clear","Access control list type for the affected file system"}, {"acl_method",cf_opts,"append,overwrite","Editing method for access control list"}, {"acl_type",cf_opts,"generic,posix,ntfs","Access control list type for the affected file system"}, {"specify_inherit_aces",cf_slist,"((user|group):[^:]+:[-=+,rwx()dtTabBpcoD]*(:(allow|deny))?)|((all|mask):[-=+,rwx()]*(:(allow|deny))?)","Native settings for access control entry"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_CHANGEMGT_BODY[] = { {"hash",cf_opts,"md5,sha1,sha224,sha256,sha384,sha512,best","Hash files for change detection"}, {"report_changes",cf_opts,"all,stats,content,none","Specify criteria for change warnings"}, {"update_hashes",cf_opts,CF_BOOL,"Update hash values immediately after change warning"}, {"report_diffs",cf_opts,CF_BOOL,"Generate reports summarizing the major differences between individual text files"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_RECURSION_BODY[] = { {"depth",cf_int,CF_VALRANGE,"Maximum depth level for search"}, {"exclude_dirs",cf_slist,".*","List of regexes of directory names NOT to include in depth search"}, {"include_basedir",cf_opts,CF_BOOL,"true/false include the start/root dir of the search results"}, {"include_dirs",cf_slist,".*","List of regexes of directory names to include in depth search"}, {"rmdeadlinks",cf_opts,CF_BOOL,"true/false remove links that point to nowhere"}, {"traverse_links",cf_opts,CF_BOOL,"true/false traverse symbolic links to directories (false)"}, {"xdev",cf_opts,CF_BOOL,"true/false exclude directories that are on different devices"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_EDITS_BODY[] = { {"edit_backup",cf_opts,"true,false,timestamp,rotate","Menu option for backup policy on edit changes"}, {"empty_file_before_editing",cf_opts,CF_BOOL,"Baseline memory model of file to zero/empty before commencing promised edits"}, {"max_file_size",cf_int,CF_VALRANGE,"Do not edit files bigger than this number of bytes"}, {"recognize_join",cf_opts,CF_BOOL,"Join together lines that end with a backslash, up to 4kB limit"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_TIDY_BODY[] = { {"dirlinks",cf_opts,"delete,tidy,keep","Menu option policy for dealing with symbolic links to directories during deletion"}, {"rmdirs",cf_opts,CF_BOOL,"true/false whether to delete empty directories during recursive deletion"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_RENAME_BODY[] = { {"disable",cf_opts,CF_BOOL,"true/false automatically rename and remove permissions"}, {"disable_mode",cf_str,CF_MODERANGE,"The permissions to set when a file is disabled"}, {"disable_suffix",cf_str,"","The suffix to add to files when disabling (.cfdisabled)"}, {"newname",cf_str,"","The desired name for the current file"}, {"rotate",cf_int,"0,99","Maximum number of file rotations to keep"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_ACCESS_BODIES[] = { {"bsdflags",cf_slist,CF_BSDFLAGRANGE,"List of menu options for bsd file system flags to set"}, {"groups",cf_slist,CF_USERRANGE,"List of acceptable groups of group ids, first is change target"}, {"mode",cf_str,CF_MODERANGE,"File permissions (like posix chmod)"}, {"owners",cf_slist,CF_USERRANGE,"List of acceptable owners or user ids, first is change target"}, {"rxdirs",cf_opts,CF_BOOL,"true/false add execute flag for directories if read flag is set"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_FILEFILTER_BODY[] = { {"leaf_name",cf_slist,"","List of regexes that match an acceptable name"}, {"path_name",cf_slist,CF_ABSPATHRANGE,"List of pathnames to match acceptable target"}, {"search_mode",cf_slist,CF_MODERANGE,"A list of mode masks for acceptable file permissions"}, {"search_size",cf_irange,"0,inf","Integer range of file sizes"}, {"search_owners",cf_slist,"","List of acceptable user names or ids for the file, or regexes to match"}, {"search_groups",cf_slist,"","List of acceptable group names or ids for the file, or regexes to match"}, {"search_bsdflags",cf_slist,CF_BSDFLAGRANGE,"String of flags for bsd file system flags expected set"}, {"ctime",cf_irange,CF_TIMERANGE,"Range of change times (ctime) for acceptable files"}, {"mtime",cf_irange,CF_TIMERANGE,"Range of modification times (mtime) for acceptable files"}, {"atime",cf_irange,CF_TIMERANGE,"Range of access times (atime) for acceptable files"}, {"exec_regex",cf_str,CF_ANYSTRING,"Matches file if this regular expression matches any full line returned by the command"}, {"exec_program",cf_str,CF_ABSPATHRANGE,"Execute this command on each file and match if the exit status is zero"}, {"file_types",cf_olist,"plain,reg,symlink,dir,socket,fifo,door,char,block","List of acceptable file types from menu choices"}, {"issymlinkto",cf_slist,"","List of regular expressions to match file objects"}, {"file_result",cf_str,"[!*(leaf_name|path_name|file_types|mode|size|owner|group|atime|ctime|mtime|issymlinkto|exec_regex|exec_program|bsdflags)[|&.]*]*","Logical expression combining classes defined by file search criteria"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ /* Copy and link are really the same body and should have non-overlapping patterns so that they are XOR but it's okay that some names overlap (like source) as there is no ambiguity in XOR */ struct BodySyntax CF_LINKTO_BODY[] = { {"copy_patterns",cf_slist,"","A set of patterns that should be copied ansd synchronized instead of linked"}, {"link_children",cf_opts,CF_BOOL,"true/false whether to link all directory's children to source originals"}, {"link_type",cf_opts,CF_LINKRANGE,"The type of link used to alias the file"}, {"source",cf_str,CF_PATHRANGE,"The source file to which the link should point"}, {"when_linking_children",cf_opts,"override_file,if_no_such_file","Policy for overriding existing files when linking directories of children"}, {"when_no_source",cf_opts,"force,delete,nop","Behaviour when the source file to link to does not exist"}, {NULL,cf_notype,NULL,NULL} }; /**************************************************************/ struct BodySyntax CF_COPYFROM_BODY[] = { /* We use CF_PATHRANGE due to collision with LINKTO_BODY and a bug lurking in * a verification stage -- this attribute gets picked instead of another * 'source' */ {"source",cf_str,CF_PATHRANGE,"Reference source file from which to copy"}, {"servers",cf_slist,"[A-Za-z0-9_.:-]+","List of servers in order of preference from which to copy"}, {"collapse_destination_dir",cf_opts,CF_BOOL,"true/false Place files in subdirectories into the root destination directory during copy"}, {"compare",cf_opts,"atime,mtime,ctime,digest,hash,exists,binary","Menu option policy for comparing source and image file attributes"}, {"copy_backup",cf_opts,"true,false,timestamp","Menu option policy for file backup/version control"}, {"encrypt",cf_opts,CF_BOOL,"true/false use encrypted data stream to connect to remote host"}, {"check_root",cf_opts,CF_BOOL,"true/false check permissions on the root directory when depth_search"}, {"copylink_patterns",cf_slist,"","List of patterns matching files that should be copied instead of linked"}, {"copy_size",cf_irange,"0,inf","Integer range of file sizes that may be copied"}, {"findertype",cf_opts,"MacOSX","Menu option for default finder type on MacOSX"}, {"linkcopy_patterns",cf_slist,"","List of patterns matching files that should be replaced with symbolic links"}, {"link_type",cf_opts,CF_LINKRANGE,"Menu option for type of links to use when copying"}, {"force_update",cf_opts,CF_BOOL,"true/false force copy update always"}, {"force_ipv4",cf_opts,CF_BOOL,"true/false force use of ipv4 on ipv6 enabled network"}, {"portnumber",cf_int,"1024,99999","Port number to connect to on server host"}, {"preserve",cf_opts,CF_BOOL,"true/false whether to preserve file permissions on copied file"}, {"purge",cf_opts,CF_BOOL,"true/false purge files on client that do not match files on server when a depth_search is used"}, {"stealth",cf_opts,CF_BOOL,"true/false whether to preserve time stamps on copied file"}, {"timeout",cf_int,"1,3600","Connection timeout, seconds"}, {"trustkey",cf_opts,CF_BOOL,"true/false trust public keys from remote server if previously unknown"}, {"type_check",cf_opts,CF_BOOL,"true/false compare file types before copying and require match"}, {"verify",cf_opts,CF_BOOL,"true/false verify transferred file by hashing after copy (resource penalty)"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the primary set of constraints for a file object */ struct BodySyntax CF_FILES_BODIES[] = { {"acl",cf_body,CF_ACL_BODY,"Criteria for access control lists on file"}, {"changes",cf_body,CF_CHANGEMGT_BODY,"Criteria for change management"}, {"copy_from",cf_body,CF_COPYFROM_BODY,"Criteria for copying file from a source"}, {"create",cf_opts,CF_BOOL,"true/false whether to create non-existing file"}, {"delete",cf_body,CF_TIDY_BODY,"Criteria for deleting files"}, {"depth_search",cf_body,CF_RECURSION_BODY,"Criteria for file depth searches"}, {"edit_line",cf_bundle,CF_BUNDLE,"Line editing model for file"}, {"edit_xml",cf_bundle,CF_BUNDLE,"XML editing model for file"}, {"edit_defaults",cf_body,CF_EDITS_BODY,"Default promise details for file edits"}, {"file_select",cf_body,CF_FILEFILTER_BODY,"Choose which files select in a search"}, {"link_from",cf_body,CF_LINKTO_BODY,"Criteria for linking file from a source"}, {"move_obstructions",cf_opts,CF_BOOL,"true/false whether to move obstructions to file-object creation"}, {"pathtype",cf_opts,"literal,regex,guess","Menu option for interpreting promiser file object"}, {"perms",cf_body,CF_ACCESS_BODIES,"Criteria for setting permissions on a file"}, {"rename",cf_body,CF_RENAME_BODY,"Criteria for renaming files"}, {"repository",cf_str,CF_ABSPATHRANGE,"Name of a repository for versioning"}, {"touch",cf_opts,CF_BOOL,"true/false whether to touch time stamps on file"}, {"transformer",cf_str,CF_ABSPATHRANGE,"Command (with full path) used to transform current file (no shell wrapper used)"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_FILES_SUBTYPES[] = { /* Body lists belonging to "files:" type in Agent */ {"agent","files",CF_FILES_BODIES}, /* Body lists belonging to th edit_line sub-bundle of files: */ {"edit_line","*",CF_COMMON_EDITBODIES}, {"edit_line","delete_lines",CF_DELETELINES_BODIES}, {"edit_line","insert_lines",CF_INSERTLINES_BODIES}, {"edit_line","field_edits",CF_COLUMN_BODIES}, {"edit_line","replace_patterns",CF_REPLACE_BODIES}, {NULL,NULL,NULL}, }; ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/net.c����������������������������������������������������������������������������0000644�0001750�0001750�00000011376�11715232734�011755� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*********************************************************************/ /* */ /* TOOLKITS: network library */ /* */ /*********************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*************************************************************************/ int SendTransaction(int sd,char *buffer,int len,char status) { char work[CF_BUFSIZE]; int wlen; memset(work, 0, sizeof(work)); if (len == 0) { wlen = strlen(buffer); } else { wlen = len; } if (wlen > CF_BUFSIZE-CF_INBAND_OFFSET) { CfOut(cf_error, "", "SenTransaction: wlen (%d) > %d - %d", wlen, CF_BUFSIZE, CF_INBAND_OFFSET); FatalError("SendTransaction software failure"); } snprintf(work,CF_INBAND_OFFSET,"%c %d",status,wlen); memcpy(work+CF_INBAND_OFFSET,buffer,wlen); Debug("Transaction Send[%s][Packed text]\n",work); if (SendSocketStream(sd,work,wlen+CF_INBAND_OFFSET,0) == -1) { return -1; } return 0; } /*************************************************************************/ int ReceiveTransaction(int sd,char *buffer,int *more) { char proto[CF_INBAND_OFFSET+1]; char status = 'x'; unsigned int len = 0; memset(proto,0,CF_INBAND_OFFSET+1); if (RecvSocketStream(sd,proto,CF_INBAND_OFFSET,0) == -1) /* Get control channel */ { return -1; } sscanf(proto,"%c %u",&status,&len); Debug("Transaction Receive [%s][%s]\n",proto,proto+CF_INBAND_OFFSET); if (len > CF_BUFSIZE - CF_INBAND_OFFSET) { CfOut(cf_error,"","Bad transaction packet -- too long (%c %d) Proto = %s ",status,len,proto); return -1; } if (strncmp(proto,"CAUTH",5) == 0) { Debug("Version 1 protocol connection attempted - no you don't!!\n"); return -1; } if (more != NULL) { switch(status) { case 'm': *more = true; break; default: *more = false; } } return RecvSocketStream(sd,buffer,len,0); } /*************************************************************************/ int RecvSocketStream(int sd,char buffer[CF_BUFSIZE],int toget,int nothing) { int already, got; static int fraction; Debug("RecvSocketStream(%d)\n",toget); if (toget > CF_BUFSIZE-1) { CfOut(cf_error,"","Bad software request for overfull buffer"); return -1; } for (already = 0; already != toget; already += got) { got = recv(sd,buffer+already,toget-already,0); if (got == -1 && errno == EINTR) { continue; } if (got == -1) { CfOut(cf_verbose,"recv","Couldn't recv"); return -1; } if (got == 0) /* doesn't happen unless sock is closed */ { Debug("Transmission empty or timed out...\n"); fraction = 0; buffer[already] = '\0'; return already; } Debug(" (Concatenated %d from stream)\n",got); if (strncmp(buffer,"AUTH",4) == 0 && (already == CF_BUFSIZE)) { fraction = 0; buffer[already] = '\0'; return already; } } buffer[toget] = '\0'; return toget; } /*************************************************************************/ int SendSocketStream(int sd,char buffer[CF_BUFSIZE],int tosend,int flags) { int sent,already=0; do { Debug("Attempting to send %d bytes\n",tosend-already); sent = send(sd,buffer+already,tosend-already,flags); if (sent == -1 && errno == EINTR) { continue; } if (sent == -1) { CfOut(cf_verbose,"send","Couldn't send"); return -1; } Debug("SendSocketStream, sent %d\n",sent); already += sent; } while (already < tosend); return already; } /*************************************************************************/ ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/storage_tools.c������������������������������������������������������������������0000644�0001750�0001750�00000011076�11715232734�014050� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: storage_tools.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #ifdef HAVE_SYS_STATFS_H #include <sys/statfs.h> #endif #ifdef HAVE_SYS_VFS_H #include <sys/vfs.h> #endif #ifdef HAVE_SYS_STATVFS_H #include <sys/statvfs.h> #endif #ifndef MINGW static off_t Unix_GetDiskUsage(char *file, enum cfsizes type); #endif /* NOT MINGW */ /************************************************************************/ off_t GetDiskUsage(char *file,enum cfsizes type) { #ifdef MINGW return NovaWin_GetDiskUsage(file, type); #else return Unix_GetDiskUsage(file, type); #endif } /************************************************************************/ /* Unix implementations */ /************************************************************************/ #ifndef MINGW static off_t Unix_GetDiskUsage(char *file,enum cfsizes type) { #if defined SOLARIS || defined OSF || defined UNIXWARE || defined OPENBSD || (defined(__NetBSD__) && __NetBSD_Version__ >= 200040000) struct statvfs buf; #elif defined ULTRIX struct fs_data buf; #else struct statfs buf; #endif off_t used = 0, avail = 0; int capacity = 0; memset(&buf,0,sizeof(buf)); #if defined ULTRIX if (getmnt(NULL,&buf, sizeof(struct fs_data), STAT_ONE, file) == -1) { CfOut(cf_error,"getmnt","Couldn't get filesystem info for %s\n",file); return CF_INFINITY; } #elif defined SOLARIS || defined OSF || defined UNIXWARE || (defined(__NetBSD__) && __NetBSD_Version__ >= 200040000) if (statvfs(file,&buf) != 0) { CfOut(cf_error,"statvfs","Couldn't get filesystem info for %s\n",file); return CF_INFINITY; } #elif defined IRIX || defined SCO || defined CFCRAY || (defined(__NetBSD__) && __NetBSD_Version__ >= 200040000) if (statfs (file, &buf, sizeof (struct statfs), 0) != 0) { CfOut(cf_error,"statfs","Couldn't get filesystem info for %s\n",file); return CF_INFINITY; } #else if (statfs(file, &buf) != 0) { CfOut(cf_error,"statfs","Couldn't get filesystem info for %s\n",file); return CF_INFINITY; } #endif #if defined ULTRIX used = buf.fd_btot - buf.fd_bfree; avail = buf.fd_bfreen; #endif #if defined SOLARIS used = (buf.f_blocks - buf.f_bfree) * buf.f_frsize; avail = buf.f_bavail * buf.f_frsize; #endif #if defined NETBSD || defined FREEBSD || defined OPENBSD || defined SUNOS || defined HPuUX || defined DARWIN used = (buf.f_blocks - buf.f_bfree) * buf.f_bsize; avail = buf.f_bavail * buf.f_bsize; #endif #if defined OSF used = (buf.f_blocks - buf.f_bfree) * buf.f_frsize; avail = buf.f_bavail * buf.f_frsize; #endif #if defined AIX || defined SCO || defined CFCRAY used = (buf.f_blocks - buf.f_bfree) * (float)buf.f_bsize; avail = buf.f_bfree * (float)buf.f_bsize; #endif #if defined LINUX used = (buf.f_blocks - buf.f_bfree) * (float)buf.f_bsize; avail = buf.f_bavail * (float)buf.f_bsize; #endif #if defined IRIX /* Float fix by arjen@sara.nl */ used = (buf.f_blocks - buf.f_bfree) * (float)buf.f_bsize; avail = buf.f_bfree * (float)buf.f_bsize; #endif capacity = (double) (avail) / (double) (avail + used) * 100; Debug2("GetDiskUsage(%s) = %d/%d\n",file,avail,capacity); /* Free kilobytes */ if (type == cfabs) { return avail; } else { return capacity; } } #endif /* NOT MINGW */ ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/files_edit.c���������������������������������������������������������������������0000644�0001750�0001750�00000021767�11715232734�013303� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: files_edit.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*****************************************************************************/ struct edit_context *NewEditContext(char *filename,struct Attributes a,struct Promise *pp) { struct edit_context *ec; if (!IsAbsoluteFileName(filename)) { CfOut(cf_error,"","Relative file name %s was marked for editing but has no invariant meaning\n",filename); return NULL; } if ((ec = malloc(sizeof(struct edit_context))) == NULL) { return NULL; } ec->filename = filename; ec->file_start = NULL; ec->file_classes = NULL; ec->num_edits = 0; ec->empty_first = a.edits.empty_before_use; if (!LoadFileAsItemList(&(ec->file_start),filename,a,pp)) { free(ec); return NULL; } if (a.edits.empty_before_use) { CfOut(cf_verbose,""," -> Build file model from a blank slate (emptying)\n"); DeleteItemList(ec->file_start); ec->file_start = NULL; } EDIT_MODEL = true; return ec; } /*****************************************************************************/ void FinishEditContext(struct edit_context *ec,struct Attributes a,struct Promise *pp) { struct Item *ip; EDIT_MODEL = false; if (DONTDO || a.transaction.action == cfa_warn) { if (ec && !CompareToFile(ec->file_start,ec->filename,a,pp) && ec->num_edits > 0) { cfPS(cf_error,CF_WARN,"",pp,a," -> Should edit file %s but only a warning promised",ec->filename); } return; } else if (ec && ec->num_edits > 0) { if (CompareToFile(ec->file_start,ec->filename,a,pp)) { if (ec) { cfPS(cf_verbose,CF_NOP,"",pp,a," -> No edit changes to file %s need saving",ec->filename); } } else { SaveItemListAsFile(ec->file_start,ec->filename,a,pp); } } else { if (ec) { cfPS(cf_verbose,CF_NOP,"",pp,a," -> No edit changes to file %s need saving",ec->filename); } } if (ec != NULL) { for (ip = ec->file_classes; ip != NULL; ip = ip->next) { NewClass(ip->name); } DeleteItemList(ec->file_classes); DeleteItemList(ec->file_start); } } /*********************************************************************/ /* Level */ /*********************************************************************/ int LoadFileAsItemList(struct Item **liststart,char *file,struct Attributes a,struct Promise *pp) { FILE *fp; struct stat statbuf; char line[CF_BUFSIZE],concat[CF_BUFSIZE]; int join = false; if (cfstat(file,&statbuf) == -1) { CfOut(cf_verbose,"stat"," ** Information: the proposed file \"%s\" could not be loaded",file); return false; } if (a.edits.maxfilesize != 0 && statbuf.st_size > a.edits.maxfilesize) { CfOut(cf_inform,""," !! File %s is bigger than the limit edit.max_file_size = %d > %d bytes\n",file,statbuf.st_size,a.edits.maxfilesize); return(false); } if (! S_ISREG(statbuf.st_mode)) { cfPS(cf_inform,CF_INTERPT,"",pp,a,"%s is not a plain file\n",file); return false; } if ((fp = fopen(file,"r")) == NULL) { cfPS(cf_inform,CF_INTERPT,"fopen",pp,a,"Couldn't read file %s for editing\n",file); return false; } memset(line,0,CF_BUFSIZE); memset(concat,0,CF_BUFSIZE); while(!feof(fp)) { CfReadLine(line,CF_BUFSIZE-1,fp); if (a.edits.joinlines && *(line+strlen(line)-1) == '\\') { join = true; } else { join = false; } if (join) { *(line+strlen(line)-1) = '\0'; JoinSuffix(concat,line); } else { JoinSuffix(concat,line); if (!feof(fp) || (strlen(concat) != 0)) { AppendItem(liststart,concat,NULL); } concat[0] = '\0'; join = false; } line[0] = '\0'; } fclose(fp); return (true); } /*********************************************************************/ int SaveItemListAsFile(struct Item *liststart,char *file,struct Attributes a,struct Promise *pp) { struct Item *ip; struct stat statbuf; char new[CF_BUFSIZE],backup[CF_BUFSIZE]; FILE *fp; mode_t mask; char stamp[CF_BUFSIZE]; time_t stamp_now; #ifdef WITH_SELINUX int selinux_enabled=0; security_context_t scontext=NULL; selinux_enabled = (is_selinux_enabled() > 0); if (selinux_enabled) { /* get current security context */ getfilecon(file, &scontext); } #endif stamp_now = time((time_t *)NULL); if (cfstat(file,&statbuf) == -1) { cfPS(cf_error,CF_FAIL,"stat",pp,a," !! Can no longer access file %s, which needed editing!\n",file); return false; } strcpy(backup,file); if (a.edits.backup == cfa_timestamp) { snprintf(stamp,CF_BUFSIZE,"_%d_%s", CFSTARTTIME,CanonifyName(cf_ctime(&stamp_now))); strcat(backup,stamp); } strcat(backup,".cf-before-edit"); strcpy(new,file); strcat(new,".cf-after-edit"); unlink(new); /* Just in case of races */ if ((fp = fopen(new,"w")) == NULL) { cfPS(cf_error,CF_FAIL,"fopen",pp,a,"Couldn't write file %s after editing\n",new); return false; } for (ip = liststart; ip != NULL; ip=ip->next) { fprintf(fp,"%s\n",ip->name); } if (fclose(fp) == -1) { cfPS(cf_error,CF_FAIL,"fclose",pp,a,"Unable to close file while writing","fclose"); return false; } cfPS(cf_inform,CF_CHG,"",pp,a," -> Edited file %s \n",file); if (cf_rename(file,backup) == -1) { cfPS(cf_error,CF_FAIL,"cf_rename",pp,a," !! Can't rename %s to %s - so promised edits could not be moved into place\n",file,backup); return false; } if (a.edits.backup != cfa_nobackup) { if (ArchiveToRepository(backup,a,pp)) { unlink(backup); } } else { unlink(backup); } if (cf_rename(new,file) == -1) { cfPS(cf_error,CF_FAIL,"cf_rename",pp,a," !! Can't rename %s to %s - so promised edits could not be moved into place\n",new,file); return false; } mask = umask(0); cf_chmod(file,statbuf.st_mode); /* Restore file permissions etc */ chown(file,statbuf.st_uid,statbuf.st_gid); umask(mask); #ifdef WITH_SELINUX if (selinux_enabled) { /* restore file context */ setfilecon(file,scontext); } #endif return true; } /*********************************************************************/ int AppendIfNoSuchLine(char *filename, char *line) /* Appends line to the file with path filename if it is not already there. line should not contain newline. Returns true if the line is there on exit, false on error. */ { FILE *fread,*fappend; char lineCp[CF_MAXVARSIZE], lineBuf[CF_MAXVARSIZE]; int lineExists = false; int result = false; size_t written = 0; if ((fread = fopen(filename,"rw")) == NULL) { CfOut(cf_error,"fopen","!! Cannot open the file \"%s\" for read", filename); return false; } while(CfReadLine(lineBuf,sizeof(lineBuf),fread)) // strips newlines automatically { if(strcmp(line,lineBuf) == 0) { lineExists = true; result = true; break; } } fclose(fread); if(!lineExists) // we are at EOF and line does not exist already { if((fappend = fopen(filename,"a")) == NULL) { CfOut(cf_error,"fopen","!! Cannot open the file \"%s\" for append", filename); return false; } if(line[strlen(line) - 1] == '\n') { snprintf(lineCp,sizeof(lineCp),"%s",line); } else { snprintf(lineCp,sizeof(lineCp),"%s\n",line); } written = fwrite(lineCp, sizeof(char), strlen(lineCp), fappend); if(written == strlen(lineCp)) { result = true; } else { CfOut(cf_error, "fwrite", "!! Could not write %d characters to \"%s\" (wrote %d)", strlen(lineCp), filename, written); result = false; } fclose(fappend); } return result; } ���������cfengine-3.2.4/src/unix.c���������������������������������������������������������������������������0000644�0001750�0001750�00000046105�11715232734�012150� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: unix.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #ifdef HAVE_SYS_UIO_H # include <sys/uio.h> #endif #ifndef MINGW #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN # ifdef _SIZEOF_ADDR_IFREQ # define SIZEOF_IFREQ(x) _SIZEOF_ADDR_IFREQ(x) # else # define SIZEOF_IFREQ(x) \ ((x).ifr_addr.sa_len > sizeof(struct sockaddr) ? \ (sizeof(struct ifreq) - sizeof(struct sockaddr) + \ (x).ifr_addr.sa_len) : sizeof(struct ifreq)) # endif #else # define SIZEOF_IFREQ(x) sizeof(struct ifreq) #endif /*****************************************************************************/ /* newly created, used in timeout.c and transaction.c */ int Unix_GracefulTerminate(pid_t pid) { int res; if ((res = kill(pid,SIGINT)) == -1) { sleep(1); res = 0; if ((res = kill(pid,SIGTERM)) == -1) { sleep(5); res = 0; if ((res = kill(pid,SIGKILL)) == -1) { sleep(1); } } } return (res == 0); } /*************************************************************/ int Unix_GetCurrentUserName(char *userName, int userNameLen) { struct passwd *user_ptr; memset(userName, 0, userNameLen); user_ptr = getpwuid(getuid()); if(user_ptr == NULL) { CfOut(cf_error,"getpwuid","Could not get user name of current process, using \"UNKNOWN\""); strncpy(userName, "UNKNOWN", userNameLen - 1); return false; } strncpy(userName, user_ptr->pw_name, userNameLen - 1); return true; } /*************************************************************/ char *Unix_GetErrorStr(void) { return strerror(errno); } /*************************************************************/ /* from exec_tools.c */ int Unix_IsExecutable(const char *file) { struct stat sb; gid_t grps[NGROUPS]; int i,n; if (cfstat(file,&sb) == -1) { CfOut(cf_error,"","Proposed executable file \"%s\" doesn't exist",file); return false; } if (sb.st_mode & 02) { CfOut(cf_error,""," !! SECURITY ALERT: promised executable \"%s\" is world writable! ",file); CfOut(cf_error,""," !! SECURITY ALERT: cfengine will not execute this - requires human inspection"); return false; } if (getuid() == sb.st_uid || getuid() == 0) { if (sb.st_mode & 0100) { return true; } } else if (getgid() == sb.st_gid) { if (sb.st_mode & 0010) { return true; } } else { if (sb.st_mode & 0001) { return true; } if ((n = getgroups(NGROUPS,grps)) > 0) { for (i = 0; i < n; i++) { if (grps[i] == sb.st_gid) { if (sb.st_mode & 0010) { return true; } } } } } return false; } /*******************************************************************/ /* from exec_tools.c */ int Unix_ShellCommandReturnsZero(char *comm,int useshell) { int status, i, argc = 0; pid_t pid; char arg[CF_MAXSHELLARGS][CF_BUFSIZE]; char **argv; char esc_command[CF_BUFSIZE]; if (!useshell) { /* Build argument array */ for (i = 0; i < CF_MAXSHELLARGS; i++) { memset (arg[i],0,CF_BUFSIZE); } argc = ArgSplitCommand(comm,arg); if (argc == -1) { CfOut(cf_error,"","Too many arguments in %s\n",comm); return false; } } if ((pid = fork()) < 0) { FatalError("Failed to fork new process"); } else if (pid == 0) /* child */ { ALARM_PID = -1; if (useshell) { strncpy(esc_command,ShEscapeCommand(comm),CF_BUFSIZE-1); if (execl("/bin/sh","sh","-c",esc_command,NULL) == -1) { CfOut(cf_error,"execl","Command %s failed",esc_command); exit(1); } } else { argv = (char **) malloc((argc+1)*sizeof(char *)); if (argv == NULL) { FatalError("Out of memory"); } for (i = 0; i < argc; i++) { argv[i] = arg[i]; } argv[i] = (char *) NULL; if (execv(arg[0],argv) == -1) { CfOut(cf_error,"execv","Command %s failed (%d args)",argv[0],argc - 1); exit(1); } free((char *)argv); } } else /* parent */ { #ifndef HAVE_WAITPID pid_t wait_result; #endif ALARM_PID = pid; #ifdef HAVE_WAITPID while(waitpid(pid,&status,0) < 0) { if (errno != EINTR) { return -1; } } return (WEXITSTATUS(status) == 0); #else while ((wait_result = wait(&status)) != pid) { if (wait_result <= 0) { CfOut(cf_inform,"wait"," !! Wait for child failed\n"); return false; } } if (WIFSIGNALED(status)) { return false; } if (! WIFEXITED(status)) { return false; } return (WEXITSTATUS(status) == 0); #endif } return false; } /**********************************************************************************/ /* from verify_processes.c */ int Unix_DoAllSignals(struct Item *siglist,struct Attributes a,struct Promise *pp) { struct Item *ip; struct Rlist *rp; pid_t pid; int killed = false; Debug("DoSignals(%s)\n",pp->promiser); if (siglist == NULL) { return 0; } if (a.signals == NULL) { CfOut(cf_verbose,""," -> No signals to send for %s\n",pp->promiser); return 0; } for (ip = siglist; ip != NULL; ip=ip->next) { pid = ip->counter; for (rp = a.signals; rp != NULL; rp=rp->next) { int signal = Signal2Int(rp->item); if (!DONTDO) { if (signal == SIGKILL || signal == SIGTERM) { killed = true; } if (kill((pid_t)pid,signal) < 0) { cfPS(cf_verbose,CF_FAIL,"kill",pp,a," !! Couldn't send promised signal \'%s\' (%d) to pid %d (might be dead)\n",rp->item,signal,pid); } else { cfPS(cf_inform,CF_CHG,"",pp,a," -> Signalled '%s' (%d) to process %d (%s)\n", rp->item, signal, pid, ip->name); } } else { CfOut(cf_error,""," -> Need to keep signal promise \'%s\' in process entry %s",rp->item,ip->name); } } } return killed; } /*******************************************************************/ /* from verify_processes.c */ int Unix_LoadProcessTable(struct Item **procdata) { FILE *prp; char pscomm[CF_MAXLINKSIZE], vbuff[CF_BUFSIZE], *sp; struct Item *rootprocs = NULL; struct Item *otherprocs = NULL; const char *psopts = GetProcessOptions(); snprintf(pscomm,CF_MAXLINKSIZE,"%s %s",VPSCOMM[VSYSTEMHARDCLASS],psopts); CfOut(cf_verbose,"","Observe process table with %s\n",pscomm); if ((prp = cf_popen(pscomm,"r")) == NULL) { CfOut(cf_error,"popen","Couldn't open the process list with command %s\n",pscomm); return false; } while (!feof(prp)) { memset(vbuff,0,CF_BUFSIZE); CfReadLine(vbuff,CF_BUFSIZE,prp); for (sp = vbuff+strlen(vbuff)-1; sp > vbuff && isspace(*sp); sp--) { *sp = '\0'; } if (ForeignZone(vbuff)) { continue; } AppendItem(procdata,vbuff,""); } cf_pclose(prp); /* Now save the data */ snprintf(vbuff,CF_MAXVARSIZE,"%s/state/cf_procs",CFWORKDIR); RawSaveItemList(*procdata,vbuff); CopyList(&rootprocs,*procdata); CopyList(&otherprocs,*procdata); while (DeleteItemNotContaining(&rootprocs,"root")) { } while (DeleteItemContaining(&otherprocs,"root")) { } if (otherprocs) { PrependItem(&rootprocs,otherprocs->name,NULL); } snprintf(vbuff,CF_MAXVARSIZE,"%s/state/cf_rootprocs",CFWORKDIR); RawSaveItemList(rootprocs,vbuff); DeleteItemList(rootprocs); snprintf(vbuff,CF_MAXVARSIZE,"%s/state/cf_otherprocs",CFWORKDIR); RawSaveItemList(otherprocs,vbuff); DeleteItemList(otherprocs); return true; } /*********************************************************************/ /* from files_operators.c */ void Unix_CreateEmptyFile(char *name) { int tempfd; if (unlink(name) == -1) { Debug("Pre-existing object %s could not be removed or was not there\n",name); } if ((tempfd = open(name, O_CREAT|O_EXCL|O_WRONLY,0600)) < 0) { CfOut(cf_error,"open","Couldn't open a file %s\n",name); } close(tempfd); } /******************************************************************/ static bool IgnoreInterface(int ifaceidx, struct sockaddr_in *inaddr) { /* FreeBSD jails */ #ifdef HAVE_JAIL_GET struct iovec fbsd_jparams[4]; struct in_addr fbsd_jia; int fbsd_lastjid = 0; *(const void **)&fbsd_jparams[0].iov_base = "lastjid"; fbsd_jparams[0].iov_len = sizeof("lastjid"); fbsd_jparams[1].iov_base = &fbsd_lastjid; fbsd_jparams[1].iov_len = sizeof(fbsd_lastjid); *(const void **)&fbsd_jparams[2].iov_base = "ip4.addr"; fbsd_jparams[2].iov_len = sizeof("ip4.addr"); fbsd_jparams[3].iov_len = sizeof(struct in_addr); fbsd_jparams[3].iov_base = &fbsd_jia; while ((fbsd_lastjid = jail_get(fbsd_jparams, 4, 0)) > 0) { if (fbsd_jia.s_addr == inaddr->sin_addr.s_addr) { CfOut(cf_verbose,"","Interface %d belongs to a FreeBSD jail %s\n", ifaceidx, inet_ntoa(fbsd_jia)); return true; } } #endif return false; } /******************************************************************/ void Unix_GetInterfaceInfo(enum cfagenttype ag) { int fd,len,i,j,first_address = false,ipdefault = false; struct ifreq ifbuf[CF_IFREQ],ifr, *ifp; struct ifconf list; struct sockaddr_in *sin; struct hostent *hp; char *sp, workbuf[CF_BUFSIZE]; char ip[CF_MAXVARSIZE]; char name[CF_MAXVARSIZE]; char last_name[CF_BUFSIZE]; Debug("Unix_GetInterfaceInfo()\n"); memset(ifbuf, 0, sizeof(ifbuf)); last_name[0] = '\0'; if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { CfOut(cf_error,"socket","Couldn't open socket"); exit(1); } list.ifc_len = sizeof(ifbuf); list.ifc_req = ifbuf; #ifdef SIOCGIFCONF if (ioctl(fd, SIOCGIFCONF, &list) == -1 || (list.ifc_len < (sizeof(struct ifreq)))) #else if (ioctl(fd, OSIOCGIFCONF, &list) == -1 || (list.ifc_len < (sizeof(struct ifreq)))) #endif { CfOut(cf_error,"ioctl","Couldn't get interfaces - old kernel? Try setting CF_IFREQ to 1024"); exit(1); } last_name[0] = '\0'; for (j = 0,len = 0,ifp = list.ifc_req; len < list.ifc_len; len+=SIZEOF_IFREQ(*ifp),j++,ifp=(struct ifreq *)((char *)ifp+SIZEOF_IFREQ(*ifp))) { if (ifp->ifr_addr.sa_family == 0) { continue; } if (ifp->ifr_name == NULL || strlen(ifp->ifr_name) == 0) { continue; } /* Skip virtual network interfaces for Linux, which seems to be a problem */ if (strstr(ifp->ifr_name,":")) { if (VSYSTEMHARDCLASS == linuxx) { CfOut(cf_verbose,"","Skipping apparent virtual interface %d: %s\n",j+1,ifp->ifr_name); continue; } } else { CfOut(cf_verbose,"","Interface %d: %s\n",j+1,ifp->ifr_name); } // Ignore the loopback if (strcmp(ifp->ifr_name,"lo") == 0) { continue; } if (strncmp(last_name,ifp->ifr_name,sizeof(ifp->ifr_name)) == 0) { first_address = false; } else { strncpy(last_name,ifp->ifr_name,sizeof(ifp->ifr_name)); if (!first_address) { NewScalar("sys","interface",last_name,cf_str); first_address = true; } } snprintf(workbuf,CF_BUFSIZE, "net_iface_%s", CanonifyName(ifp->ifr_name)); NewClass(workbuf); if (ifp->ifr_addr.sa_family == AF_INET) { strncpy(ifr.ifr_name,ifp->ifr_name,sizeof(ifp->ifr_name)); if (ioctl(fd,SIOCGIFFLAGS,&ifr) == -1) { CfOut(cf_error,"ioctl","No such network device"); //close(fd); //return; continue; } if ((ifr.ifr_flags & IFF_BROADCAST) && !(ifr.ifr_flags & IFF_LOOPBACK)) { sin=(struct sockaddr_in *)&ifp->ifr_addr; if (IgnoreInterface(j + 1, sin)) { CfOut(cf_verbose, "", "Ignoring interface %d", j + 1); continue; } Debug("Adding hostip %s..\n",inet_ntoa(sin->sin_addr)); NewClass(inet_ntoa(sin->sin_addr)); if ((hp = gethostbyaddr((char *)&(sin->sin_addr.s_addr),sizeof(sin->sin_addr.s_addr),AF_INET)) == NULL) { Debug("No hostinformation for %s not found\n", inet_ntoa(sin->sin_addr)); } else { if (hp->h_name != NULL) { Debug("Adding hostname %s..\n",hp->h_name); NewClass(hp->h_name); if (hp->h_aliases != NULL) { for (i=0; hp->h_aliases[i] != NULL; i++) { CfOut(cf_verbose,"","Adding alias %s..\n",hp->h_aliases[i]); NewClass(hp->h_aliases[i]); } } } } if (strcmp(inet_ntoa(sin->sin_addr),"0.0.0.0") == 0) { // Maybe we need to do something windows specific here? CfOut(cf_verbose,""," !! Cannot discover hardware IP, using DNS value"); strcpy(ip,"ipv4_"); strcat(ip,VIPADDRESS); AppendItem(&IPADDRESSES,VIPADDRESS,""); for (sp = ip+strlen(ip)-1; (sp > ip); sp--) { if (*sp == '.') { *sp = '\0'; NewClass(ip); } } strcpy(ip,VIPADDRESS); i = 3; for (sp = ip+strlen(ip)-1; (sp > ip); sp--) { if (*sp == '.') { *sp = '\0'; snprintf(name,CF_MAXVARSIZE-1,"ipv4_%d[%s]",i--,CanonifyName(VIPADDRESS)); NewScalar("sys",name,ip,cf_str); } } //close(fd); //return; continue; } strncpy(ip,"ipv4_",CF_MAXVARSIZE); strncat(ip,inet_ntoa(sin->sin_addr),CF_MAXVARSIZE-6); NewClass(ip); if (!ipdefault) { ipdefault = true; NewScalar("sys","ipv4",inet_ntoa(sin->sin_addr),cf_str); strcpy(VIPADDRESS,inet_ntoa(sin->sin_addr)); } AppendItem(&IPADDRESSES,inet_ntoa(sin->sin_addr),""); for (sp = ip+strlen(ip)-1; (sp > ip); sp--) { if (*sp == '.') { *sp = '\0'; NewClass(ip); } } strcpy(ip,inet_ntoa(sin->sin_addr)); if (ag != cf_know) { snprintf(name,CF_MAXVARSIZE-1,"ipv4[%s]",CanonifyName(ifp->ifr_name)); } else { snprintf(name,CF_MAXVARSIZE-1,"ipv4[interface_name]"); } NewScalar("sys",name,ip,cf_str); i = 3; for (sp = ip+strlen(ip)-1; (sp > ip); sp--) { if (*sp == '.') { *sp = '\0'; if (ag != cf_know) { snprintf(name,CF_MAXVARSIZE-1,"ipv4_%d[%s]",i--,CanonifyName(ifp->ifr_name)); } else { snprintf(name,CF_MAXVARSIZE-1,"ipv4_%d[interface_name]",i--); } NewScalar("sys",name,ip,cf_str); } } } } } close(fd); } /*******************************************************************/ void Unix_FindV6InterfaceInfo(void) { FILE *pp = NULL; char buffer[CF_BUFSIZE]; /* Whatever the manuals might say, you cannot get IPV6 interface configuration from the ioctls. This seems to be implemented in a non standard way across OSes BSDi has done getifaddrs(), solaris 8 has a new ioctl, Stevens book shows the suggestion which has not been implemented... */ CfOut(cf_verbose,"","Trying to locate my IPv6 address\n"); switch (VSYSTEMHARDCLASS) { case cfnt: /* NT cannot do this */ return; case irix: case irix4: case irix64: if ((pp = cf_popen("/usr/etc/ifconfig -a","r")) == NULL) { CfOut(cf_verbose,"","Could not find interface info\n"); return; } break; case hp: if ((pp = cf_popen("/usr/sbin/ifconfig -a","r")) == NULL) { CfOut(cf_verbose,"","Could not find interface info\n"); return; } break; case aix: if ((pp = cf_popen("/etc/ifconfig -a","r")) == NULL) { CfOut(cf_verbose,"","Could not find interface info\n"); return; } break; default: if ((pp = cf_popen("/sbin/ifconfig -a","r")) == NULL) { CfOut(cf_verbose,"","Could not find interface info\n"); return; } } /* Don't know the output format of ifconfig on all these .. hope for the best*/ while (!feof(pp)) { fgets(buffer,CF_BUFSIZE-1,pp); if (ferror(pp)) /* abortable */ { break; } if (StrStr(buffer,"inet6")) { struct Item *ip,*list = NULL; char *sp; list = SplitStringAsItemList(buffer,' '); for (ip = list; ip != NULL; ip=ip->next) { for (sp = ip->name; *sp != '\0'; sp++) { if (*sp == '/') /* Remove CIDR mask */ { *sp = '\0'; } } if (IsIPV6Address(ip->name) && (strcmp(ip->name,"::1") != 0)) { CfOut(cf_verbose,"","Found IPv6 address %s\n",ip->name); AppendItem(&IPADDRESSES,ip->name,""); NewClass(ip->name); } } DeleteItemList(list); } } cf_pclose(pp); } #endif /* NOT MINGW */ �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/cfknow.c�������������������������������������������������������������������������0000644�0001750�0001750�00000070627�11715232734�012462� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: cfknow.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" int main (int argc,char *argv[]); void CheckOpts(int argc,char **argv); void ThisAgentInit(void); void KeepKnowControlPromises(void); void KeepKnowledgePromise(struct Promise *pp); void VerifyTopicPromise(struct Promise *pp); void VerifyThingsPromise(struct Promise *pp); void VerifyOccurrencePromises(struct Promise *pp); void VerifyInferencePromise(struct Promise *pp); void WriteKMDB(void); void GenerateManual(void); void CfGenerateStories(char *query,enum storytype type); void VerifyOccurrenceGroup(char *file,struct Promise *pp); void CfGenerateTestData(int count); void CfRemoveTestData(void); void CfUpdateTestData(void); void ShowSingletons(void); void ShowWords(void); /*******************************************************************/ /* GLOBAL VARIABLES */ /*******************************************************************/ extern struct BodySyntax CFK_CONTROLBODY[]; enum typesequence { kp_classes, kp_things, kp_topics, kp_occur, kp_reports, kp_none }; char *TYPESEQUENCE[] = { "classes", "things", "topics", "occurrences", "reports", NULL }; char BUILD_DIR[CF_BUFSIZE]; char TOPIC_CMD[CF_MAXVARSIZE]; int WORDS = false; int HTML = false; int WRITE_KMDB = false; int GENERATE_MANUAL = false; char MANDIR[CF_BUFSIZE]; struct Occurrence *OCCURRENCES = NULL; struct Inference *INFERENCES = NULL; /*******************************************************************/ /* Command line options */ /*******************************************************************/ const char *ID = "The knowledge management agent is capable of building\n" "and analysing a semantic knowledge network. It can\n" "configure a relational database to contain an ISO\n" "standard topic map and permit regular-expression based\n" "searching of the map. Analysis of the semantic network\n" "can be performed providing graphical output of the data,\n" "and cf-know can assemble and converge the reference manual\n" "for the current version of the Cfengine software."; const struct option OPTIONS[15] = { { "help",no_argument,0,'h' }, { "build",no_argument,0,'b'}, { "debug",optional_argument,0,'d' }, { "verbose",no_argument,0,'v' }, { "version",no_argument,0,'V' }, { "file",required_argument,0,'f' }, { "manual",no_argument,0,'m'}, { "manpage",no_argument,0,'M'}, { "stories",required_argument,0,'z'}, { "syntax",required_argument,0,'S'}, { "topics",no_argument,0,'T'}, { "test",required_argument,0,'t'}, { "removetest",no_argument,0,'r'}, { "updatetest",no_argument,0,'u'}, { NULL,0,0,'\0' } }; const char *HINTS[15] = { "Print the help message", "Build and store topic map in the CFDB", "Set debugging level 0,1,2,3", "Output verbose information about the behaviour of the agent", "Output the version of the software", "Specify an alternative input file than the default", "Generate reference manual from internal data", "Generate reference manpage from internal data", "Look up stories for a given topic on the command line", "Print a syntax summary of the optional keyword or this cfengine version", "Show all topic names in CFEngine", "Generate test data", "Remove test data", "Update test data", NULL }; /*****************************************************************************/ int main(int argc,char *argv[]) { CheckOpts(argc,argv); GenericInitialize(argc,argv,"knowledge"); ThisAgentInit(); KeepKnowControlPromises(); if (strlen(TOPIC_CMD) == 0) { int complete; double percent; KeepPromiseBundles(); WriteKMDB(); GenerateManual(); ShowWords(); ShowSingletons(); complete = (double)CF_TOPICS*(CF_TOPICS-1); percent = 100.0 * (double)CF_EDGES/(double)complete; CfOut(cf_inform,""," -> Association density yields %d/%d = %.4lf%%\n",CF_EDGES,complete,percent); percent = 100.0 * (double)CF_OCCUR/(double)CF_TOPICS; CfOut(cf_inform,""," -> Hit probability (efficiency) yields %d/%d = %.4lf%%\n",CF_OCCUR,CF_TOPICS,percent); } return 0; } /*****************************************************************************/ /* Level 1 */ /*****************************************************************************/ void CheckOpts(int argc,char **argv) { extern char *optarg; char arg[CF_BUFSIZE]; int optindex = 0; int c; LOOKUP = false; while ((c=getopt_long(argc,argv,"hbd:vVf:mMz:St:ruT",OPTIONS,&optindex)) != EOF) { switch ((char) c) { case 'f': if (optarg && strlen(optarg) < 5) { snprintf(arg,CF_MAXVARSIZE," -f used but argument \"%s\" incorrect",optarg); FatalError(arg); } strncpy(VINPUTFILE,optarg,CF_BUFSIZE-1); VINPUTFILE[CF_BUFSIZE-1] = '\0'; MINUSF = true; break; case 'd': switch ((optarg==NULL) ? '3' : *optarg) { case '1': D1 = true; DEBUG = true; break; case '2': D2 = true; DEBUG = true; break; default: DEBUG = true; break; } break; case 'z': #ifdef HAVE_CONSTELLATION strcpy(TOPIC_CMD,optarg); CfGenerateStories(TOPIC_CMD,cfi_cause); #endif exit(0); break; case 'b': WRITE_KMDB = true; break; case 'v': VERBOSE = true; break; case 'V': PrintVersionBanner("cf-know"); exit(0); case 'h': Syntax("cf-know - cfengine's knowledge agent",OPTIONS,HINTS,ID); exit(0); case 'M': ManPage("cf-know - cfengine's knowledge agent",OPTIONS,HINTS,ID); exit(0); case 'H': HTML = 1; break; case 'S': if (optarg) { SyntaxCompletion(optarg); exit(0); } break; case 'm': GENERATE_MANUAL = true; break; case 't': if (atoi(optarg)) { CfGenerateTestData(atoi(optarg)); exit(0); } break; case 'r': CfRemoveTestData(); exit(0); case 'u': CfUpdateTestData(); exit(0); case 'T': WORDS = true; break; default: Syntax("cf-know - knowledge agent",OPTIONS,HINTS,ID); exit(1); } } if (argv[optind] != NULL) { CfOut(cf_error,"","Unexpected argument with no preceding option: %s\n",argv[optind]); } } /*****************************************************************************/ void ThisAgentInit() { strcpy(WEBDRIVER,""); strcpy(LICENSE_COMPANY,""); strcpy(MANDIR,"."); strcpy(SQL_DATABASE,"cf_kmdb"); strcpy(GRAPHDIR,""); SHOWREPORTS = false; if (InsertTopic("any","any")) { struct Rlist *list = NULL; PrependRScalar(&list,"Description",CF_SCALAR); AddOccurrence(&OCCURRENCES,"The generic knowledge context - any time, any place, anywhere",list,cfk_literal,"any"); DeleteRlist(list); } } /*****************************************************************************/ void KeepKnowControlPromises() { struct Constraint *cp; struct Rlist *rp; char rettype; void *retval; for (cp = ControlBodyConstraints(cf_know); cp != NULL; cp=cp->next) { if (IsExcluded(cp->classes)) { continue; } if (GetVariable("control_knowledge",cp->lval,&retval,&rettype) == cf_notype) { CfOut(cf_error,""," !! Unknown lval %s in knowledge control body",cp->lval); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_tm_prefix].lval) == 0) { CfOut(cf_error,"","The topic map prefix has been deprecated"); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_builddir].lval) == 0) { strncpy(BUILD_DIR,retval,CF_BUFSIZE); if (strlen(MANDIR) < 2) /* MANDIR defaults to BUILDDIR */ { strncpy(MANDIR,retval,CF_BUFSIZE); } continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_sql_type].lval) == 0) { SQL_TYPE = Str2dbType(retval); CfOut(cf_verbose,""," -> Option %s has been deprecated in this release",cp->lval); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_sql_database].lval) == 0) { strncpy(SQL_DATABASE,retval,CF_MAXVARSIZE); CfOut(cf_verbose,""," -> Option %s has been deprecated in this release",cp->lval); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_sql_owner].lval) == 0) { strncpy(SQL_OWNER,retval,CF_MAXVARSIZE); CfOut(cf_verbose,""," -> Option %s has been deprecated in this release",cp->lval); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_sql_passwd].lval) == 0) { strncpy(SQL_PASSWD,retval,CF_MAXVARSIZE); CfOut(cf_verbose,""," -> Option %s has been deprecated in this release",cp->lval); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_sql_server].lval) == 0) { strncpy(SQL_SERVER,retval,CF_MAXVARSIZE); CfOut(cf_verbose,""," -> Option %s has been deprecated in this release",cp->lval); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_sql_connect_db].lval) == 0) { strncpy(SQL_CONNECT_NAME,retval,CF_MAXVARSIZE); CfOut(cf_verbose,""," -> Option %s has been deprecated in this release",cp->lval); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_query_engine].lval) == 0) { CfOut(cf_verbose,""," -> Option %s has been deprecated in this release",cp->lval); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_htmlbanner].lval) == 0) { CfOut(cf_verbose,""," -> Option %s has been deprecated in this release",cp->lval); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_htmlfooter].lval) == 0) { CfOut(cf_verbose,""," -> Option %s has been deprecated in this release",cp->lval); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_stylesheet].lval) == 0) { CfOut(cf_verbose,""," -> Option %s has been deprecated in this release",cp->lval); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_query_output].lval) == 0) { CfOut(cf_verbose,""," -> Option %s has been deprecated in this release",cp->lval); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_graph_output].lval) == 0) { CfOut(cf_verbose,""," -> Option %s has been deprecated in this release",cp->lval); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_views].lval) == 0) { CfOut(cf_verbose,""," -> Option %s has been deprecated in this release",cp->lval); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_graph_dir].lval) == 0) { strncpy(GRAPHDIR,retval,CF_MAXVARSIZE); CfOut(cf_verbose,"","SET graph_directory = %s\n",GRAPHDIR); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_genman].lval) == 0) { GENERATE_MANUAL = GetBoolean(retval); CfOut(cf_verbose,"","SET generate_manual = %d\n",GENERATE_MANUAL); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_mandir].lval) == 0) { strncpy(MANDIR,retval,CF_MAXVARSIZE); CfOut(cf_verbose,"","SET manual_source_directory = %s\n",MANDIR); continue; } if (strcmp(cp->lval,CFK_CONTROLBODY[cfk_docroot].lval) == 0) { CfOut(cf_verbose,""," -> Option %s has been deprecated in this release",cp->lval); continue; } } } /*****************************************************************************/ void KeepPromiseBundles() { struct Bundle *bp; struct SubType *sp; struct Promise *pp; struct Rlist *rp,*params; struct FnCall *fp; char rettype,*name; void *retval; int ok = true; enum typesequence type; if (GetVariable("control_common","bundlesequence",&retval,&rettype) == cf_notype) { CfOut(cf_error,""," !! No bundlesequence in the common control body"); exit(1); } for (rp = (struct Rlist *)retval; rp != NULL; rp=rp->next) { switch (rp->type) { case CF_SCALAR: name = (char *)rp->item; params = NULL; break; case CF_FNCALL: fp = (struct FnCall *)rp->item; name = (char *)fp->name; params = (struct Rlist *)fp->args; break; default: name = NULL; params = NULL; CfOut(cf_error,""," !! Illegal item found in bundlesequence: "); ShowRval(stdout,rp->item,rp->type); printf(" = %c\n",rp->type); ok = false; break; } if (!(GetBundle(name,"knowledge")||(GetBundle(name,"common")))) { CfOut(cf_error,""," !! Bundle \"%s\" listed in the bundlesequence was not found\n",name); ok = false; } } if (!ok) { FatalError("Errors in knowledge bundles"); } /* If all is okay, go ahead and evaluate */ for (type = 0; TYPESEQUENCE[type] != NULL; type++) { for (rp = (struct Rlist *)retval; rp != NULL; rp=rp->next) { switch (rp->type) { case CF_FNCALL: fp = (struct FnCall *)rp->item; name = (char *)fp->name; params = (struct Rlist *)fp->args; break; default: name = (char *)rp->item; params = NULL; break; } if ((bp = GetBundle(name,"knowledge")) || (bp = GetBundle(name,"common"))) { BannerBundle(bp,params); AugmentScope(bp->name,bp->args,params); DeletePrivateClassContext(); // Each time we change bundle } if ((sp = GetSubTypeForBundle(TYPESEQUENCE[type],bp)) == NULL) { continue; } BannerSubType(bp->name,sp->name,1); for (pp = sp->promiselist; pp != NULL; pp=pp->next) { ExpandPromise(cf_know,bp->name,pp,KeepKnowledgePromise); } } } } /*********************************************************************/ /* Level */ /*********************************************************************/ void KeepKnowledgePromise(struct Promise *pp) { if (pp->done) { return; } if (strcmp("classes",pp->agentsubtype) == 0) { CfOut(cf_verbose,""," ! Class promises do not have any effect here.\n"); return; } if (strcmp("inferences",pp->agentsubtype) == 0) { VerifyInferencePromise(pp); return; } if (strcmp("things",pp->agentsubtype) == 0) { VerifyThingsPromise(pp); return; } if (strcmp("topics",pp->agentsubtype) == 0) { VerifyTopicPromise(pp); return; } if (strcmp("occurrences",pp->agentsubtype) == 0) { VerifyOccurrencePromises(pp); return; } if (strcmp("reports",pp->agentsubtype) == 0) { VerifyReportPromise(pp); return; } } /*********************************************************************/ void CfGenerateStories(char *query,enum storytype type) { #ifdef HAVE_CONSTELLATION Constellation_CfGenerateStories(query,type); #endif } /*********************************************************************/ void CfGenerateTestData(int count) { #ifdef HAVE_NOVA Nova_GenerateTestData(count); #endif } /*********************************************************************/ void CfUpdateTestData(void) { #ifdef HAVE_NOVA Nova_UpdateTestData(); #endif } /*********************************************************************/ void CfRemoveTestData(void) { #ifdef HAVE_NOVA Nova_RemoveTestData(); #endif } /*********************************************************************/ void ShowWords() { struct Topic *tp; struct Item *ip,*list = NULL; int slot; if (!WORDS) { return; } for (slot = 0; slot < CF_HASHTABLESIZE; slot++) { for (tp = TOPICHASH[slot]; tp != NULL; tp=tp->next) { IdempPrependItem(&list,tp->topic_name,tp->topic_context); } } list = SortItemListNames(list); for (ip = list; ip != NULL; ip=ip->next) { printf("%s::%s\n",ip->classes,ip->name); } } /*********************************************************************/ void ShowSingletons() { struct Topic *tp; struct Item *ip,*list = NULL; int slot; if (VERBOSE || DEBUG) { for (slot = 0; slot < CF_HASHTABLESIZE; slot++) { for (tp = TOPICHASH[slot]; tp != NULL; tp=tp->next) { if (tp->associations == NULL) { PrependItem(&list,tp->topic_name,tp->topic_context); } } } list = SortItemListNames(list); for (ip = list; ip != NULL; ip=ip->next) { printf(" ! Warning, topic \"%s::%s\" is a singleton with no connection to the map\n",ip->classes,ip->name); } } } /*********************************************************************/ /* Level */ /*********************************************************************/ void VerifyInferencePromise(struct Promise *pp) { struct Attributes a = {0}; struct Rlist *rpp,*rpq; if (!IsDefinedClass(pp->classes)) { CfOut(cf_verbose,""," -> Skipping inference for \"%s\" as class \"%s\" is not defined",pp->promiser,pp->classes); return; } a = GetInferencesAttributes(pp); for (rpp = a.precedents; rpp != NULL; rpp=rpp->next) { for (rpq = a.qualifiers; rpq != NULL; rpq=rpq->next) { CfOut(cf_verbose,""," -> Add inference: (%s,%s,%s)\n",rpp->item,rpq->item,pp->promiser); AddInference(&INFERENCES,pp->promiser,rpp->item,rpq->item); } } } /*********************************************************************/ void VerifyThingsPromise(struct Promise *pp) { char id[CF_BUFSIZE]; struct Attributes a = {0}; struct Topic *tp = NULL, *otp; struct Rlist *rp,*rps,*contexts; char *handle = (char *)GetConstraint("handle",pp,CF_SCALAR); a = GetThingsAttributes(pp); CfOut(cf_verbose,""," -> Attempting to install thing-topic %s::%s \n",pp->classes,pp->promiser); // Add a standard reserved word contexts = SplitContextExpression(pp->classes,pp); for (rp = contexts; rp != NULL; rp = rp->next) { if ((tp = InsertTopic(pp->promiser,rp->item)) == NULL) { return; } CfOut(cf_verbose,""," -> New thing \"%s\" about context \"%s\"",pp->promiser,rp->item); if (a.fwd_name && a.bwd_name) { CfOut(cf_verbose,""," -> New thing \"%s\" has a relation \"%s/%s\"",pp->promiser,a.fwd_name,a.bwd_name); AddTopicAssociation(tp,&(tp->associations),a.fwd_name,a.bwd_name,a.associates,true,rp->item,pp->promiser); } // Handle all synonyms as associations if (handle) { char synonym[CF_BUFSIZE]; snprintf(synonym,CF_BUFSIZE-1,"handles::%s",handle); otp = IdempInsertTopic(synonym); PrependRScalar(&(a.synonyms),otp->topic_name,CF_SCALAR); } // Handle all synonyms as associations if (a.synonyms) { for (rps = a.synonyms; rps != NULL; rps=rps->next) { otp = IdempInsertTopic(rps->item); CfOut(cf_verbose,""," ---> %s is a synonym for %s",rps->item,tp->topic_name); } AddTopicAssociation(tp,&(tp->associations),KM_SYNONYM,KM_SYNONYM,a.synonyms,true,rp->item,pp->promiser); } // Handle all generalizations as associations if (a.general) { for (rps = a.general; rps != NULL; rps=rps->next) { otp = IdempInsertTopic(rps->item); CfOut(cf_verbose,""," ---> %s is a generalization for %s",rps->item,tp->topic_name); } AddTopicAssociation(tp,&(tp->associations),KM_GENERALIZES_B,KM_GENERALIZES_F,a.general,true,rp->item,pp->promiser); } // Treat comments as occurrences of information. if (pp->ref) { struct Rlist *list = NULL; snprintf(id,CF_MAXVARSIZE,"%s.%s",pp->classes,CanonifyName(pp->promiser)); PrependRScalar(&list,"description",CF_SCALAR); AddOccurrence(&OCCURRENCES,pp->ref,list,cfk_literal,id); DeleteRlist(list); } if (handle) { struct Rlist *list = NULL; PrependRScalar(&list,handle,CF_SCALAR); AddTopicAssociation(tp,&(tp->associations),"is the promise of","stands for",list,true,rp->item,pp->promiser); DeleteRlist(list); list = NULL; snprintf(id,CF_MAXVARSIZE,"%s.%s",pp->classes,handle); PrependRScalar(&list,"description",CF_SCALAR); AddOccurrence(&OCCURRENCES,pp->ref,list,cfk_literal,id); DeleteRlist(list); } } DeleteRlist(contexts); } /*********************************************************************/ void VerifyTopicPromise(struct Promise *pp) { char id[CF_BUFSIZE]; struct Attributes a = {0}; struct Topic *tp = NULL, *otp; struct Rlist *rp,*rps,*contexts; char *handle = (char *)GetConstraint("handle",pp,CF_SCALAR); a = GetTopicsAttributes(pp); CfOut(cf_verbose,""," -> Attempting to install topic %s::%s \n",pp->classes,pp->promiser); // Add a standard reserved word contexts = SplitContextExpression(pp->classes,pp); for (rp = contexts; rp != NULL; rp = rp->next) { if ((tp = InsertTopic(pp->promiser,rp->item)) == NULL) { return; } CfOut(cf_verbose,""," -> New topic promise for \"%s\" about context \"%s\"",pp->promiser,rp->item); if (a.fwd_name && a.bwd_name) { AddTopicAssociation(tp,&(tp->associations),a.fwd_name,a.bwd_name,a.associates,true,rp->item,pp->promiser); } // Handle all synonyms as associations if (a.synonyms) { for (rps = a.synonyms; rps != NULL; rps=rps->next) { otp = IdempInsertTopic(rps->item); CfOut(cf_verbose,""," ---> %s is a synonym for %s",rps->item,tp->topic_name); } AddTopicAssociation(tp,&(tp->associations),KM_SYNONYM,KM_SYNONYM,a.synonyms,true,rp->item,pp->promiser); } // Handle all generalizations as associations if (a.general) { for (rps = a.general; rps != NULL; rps=rps->next) { otp = IdempInsertTopic(rps->item); CfOut(cf_verbose,""," ---> %s is a generalization for %s",rps->item,tp->topic_name); } AddTopicAssociation(tp,&(tp->associations),KM_GENERALIZES_B,KM_GENERALIZES_F,a.general,true,rp->item,pp->promiser); } if (handle) { char synonym[CF_BUFSIZE]; snprintf(synonym,CF_BUFSIZE-1,"handles::%s",handle); otp = IdempInsertTopic(synonym); PrependRScalar(&(a.synonyms),otp->topic_name,CF_SCALAR); } // Treat comments as occurrences of information. if (pp->ref) { struct Rlist *list = NULL; snprintf(id,CF_MAXVARSIZE,"%s.%s",pp->classes,CanonifyName(pp->promiser)); PrependRScalar(&list,"description",CF_SCALAR); AddOccurrence(&OCCURRENCES,pp->ref,list,cfk_literal,id); DeleteRlist(list); } if (handle) { struct Rlist *list = NULL; PrependRScalar(&list,handle,CF_SCALAR); AddTopicAssociation(tp,&(tp->associations),"is the promise of","stands for",list,true,rp->item,pp->promiser); DeleteRlist(list); list = NULL; snprintf(id,CF_MAXVARSIZE,"%s.%s",pp->classes,handle); PrependRScalar(&list,"description",CF_SCALAR); AddOccurrence(&OCCURRENCES,pp->ref,list,cfk_literal,id); DeleteRlist(list); } } DeleteRlist(contexts); } /*********************************************************************/ void VerifyOccurrencePromises(struct Promise *pp) { struct Attributes a = {0}; char name[CF_BUFSIZE]; enum representations rep_type; struct Rlist *contexts,*rp; a = GetOccurrenceAttributes(pp); if (a.rep_type) { rep_type = String2Representation(a.rep_type); } else { rep_type = cfk_url; } if (a.represents == NULL) { if (rep_type == cfk_literal) { CfOut(cf_error,""," ! Occurrence of text information \"%s\" does not promise any topics to represent",pp->promiser); } else { CfOut(cf_error,""," ! Occurrence or reference to information \"%s\" does not promise any topics to represent",pp->promiser); } return; } contexts = SplitContextExpression(pp->classes,pp); for (rp = contexts; rp != NULL; rp = rp->next) { CfOut(cf_verbose,""," -> New occurrence promise for \"%s\" about context \"%s\"",pp->promiser,rp->item); switch (rep_type) { case cfk_file: if (a.web_root == NULL || a.path_root == NULL) { CfOut(cf_error,""," !! File pattern but no complete url mapping path_root -> web_root"); return; } strncpy(name,a.path_root,CF_BUFSIZE-1); if (!JoinPath(name,pp->promiser)) { CfOut(cf_error,""," !! Unable to form pathname in search for local files"); return; } // FIXME - this should pass rp->item instead of pp->classes if we want to keep this LocateFilePromiserGroup(name,pp,VerifyOccurrenceGroup); break; default: AddOccurrence(&OCCURRENCES,pp->promiser,a.represents,rep_type,rp->item); break; } } DeleteRlist(contexts); } /*********************************************************************/ void WriteKMDB() { #ifdef HAVE_NOVA if (WRITE_KMDB) { Nova_StoreKMDB(TOPICHASH,OCCURRENCES,INFERENCES); } #endif } /*********************************************************************/ void GenerateManual() { if (GENERATE_MANUAL) { TexinfoManual(MANDIR); } } /*********************************************************************/ void VerifyOccurrenceGroup(char *file,struct Promise *pp) { struct Attributes a = {0}; enum representations rep_type; struct stat sb; char *sp,url[CF_BUFSIZE]; struct Rval retval; a = GetOccurrenceAttributes(pp); if (a.rep_type) { rep_type = String2Representation(a.rep_type); } else { rep_type = cfk_url; } if (cfstat(file,&sb) == -1) { CfOut(cf_verbose,""," !! File %s matched but could not be read",file); return; } if (a.path_root == NULL || a.web_root == NULL) { CfOut(cf_error,""," !! No pathroot/webroot defined in representation"); PromiseRef(cf_error,pp); return; } Chop(a.path_root); DeleteSlash(a.path_root); sp = file + strlen(a.path_root) + 1; FullTextMatch(pp->promiser,sp); retval = ExpandPrivateRval("this",a.represents,CF_LIST); DeleteScope("match"); if (strlen(a.web_root) > 0) { snprintf(url,CF_BUFSIZE-1,"%s/%s",a.web_root,sp); } else { snprintf(url,CF_BUFSIZE-1,"%s",sp); } AddOccurrence(&OCCURRENCES,url,retval.item,cfk_url,pp->classes); CfOut(cf_verbose,""," -> File %s matched and being logged at %s",file,url); DeleteRlist((struct Rlist *)retval.item); } ���������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/verify_measurements.c������������������������������������������������������������0000644�0001750�0001750�00000007673�11715232734�015270� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: verify_measurements.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int CheckMeasureSanity(struct Attributes a,struct Promise *pp); /*****************************************************************************/ void VerifyMeasurementPromise(double *this,struct Promise *pp) { struct Attributes a = {{0}}; if (pp->done) { if (pp->ref) { CfOut(cf_verbose,"","Skipping static observation %s (%s), already done",pp->promiser,pp->ref); } else { CfOut(cf_verbose,"","Skipping static observation %s, already done",pp->promiser); } return; } PromiseBanner(pp); a = GetMeasurementAttributes(pp); /* if (strcmp(a.measure.history_type,"weekly") == 0) { *(pp->donep) = true; } */ if (!CheckMeasureSanity(a,pp)) { return; } VerifyMeasurement(this,a,pp); } /*****************************************************************************/ static int CheckMeasureSanity(struct Attributes a,struct Promise *pp) { int retval = true; if (!IsAbsPath(pp->promiser)) { cfPS(cf_error,CF_INTERPT,"",pp,a,"The promiser \"%s\" of a measurement was not an absolute path",pp->promiser); PromiseRef(cf_error,pp); retval = false; } if (a.measure.data_type == cf_notype) { cfPS(cf_error,CF_INTERPT,"",pp,a,"The promiser \"%s\" did not specify a data type\n",pp->promiser); PromiseRef(cf_error,pp); retval = false; } else { if (a.measure.history_type && strcmp(a.measure.history_type,"weekly") == 0) { switch (a.measure.data_type) { case cf_counter: case cf_str: case cf_int: case cf_real: break; default: cfPS(cf_error,CF_INTERPT,"",pp,a,"The promiser \"%s\" cannot have history type weekly as it is not a number\n",pp->promiser); PromiseRef(cf_error,pp); retval = false; break; } } } if (a.measure.select_line_matching && a.measure.select_line_number != CF_NOINT) { cfPS(cf_error,CF_INTERPT,"",pp,a,"The promiser \"%s\" cannot select both a line by pattern and by number\n",pp->promiser); PromiseRef(cf_error,pp); retval = false; } if (!a.measure.extraction_regex) { CfOut(cf_verbose,"","No extraction regex, so assuming whole line is the value"); } else { if (!strchr(a.measure.extraction_regex,'(') && !strchr(a.measure.extraction_regex,')')) { cfPS(cf_error,CF_INTERPT,"",pp,a,"The extraction_regex must contain a single backreference for the extraction\n"); retval = false; } } return retval; } ���������������������������������������������������������������������cfengine-3.2.4/src/conversion.c���������������������������������������������������������������������0000644�0001750�0001750�00000076033�11715232734�013355� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: conversion.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int IsSpace(char *remainder); /*****************************************************************************/ void IPString2KeyDigest(char *ipv4,char *result) { CF_DB *dbp; CF_DBC *dbcp; char *key; char name[CF_BUFSIZE]; void *value; struct CfKeyHostSeen entry; int ksize,vsize; unsigned char digest[EVP_MAX_MD_SIZE+1]; result[0] = '\0'; if (strcmp(ipv4,"127.0.0.1") == 0 || strcmp(ipv4,"::1") == 0 || strcmp(ipv4,VIPADDRESS) == 0) { if (PUBKEY) { HashPubKey(PUBKEY,digest,CF_DEFAULT_DIGEST); snprintf(result,CF_MAXVARSIZE,"%s",HashPrint(CF_DEFAULT_DIGEST,digest)); } return; } snprintf(name,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,CF_LASTDB_FILE); MapName(name); if (!OpenDB(name,&dbp)) { return; } if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan last-seen database"); CloseDB(dbp); return; } /* Initialize the key/data return pair. */ memset(&entry, 0, sizeof(entry)); /* Walk through the database and print out the key/data pairs. */ while(NextDB(dbp,dbcp,&key,&ksize,&value,&vsize)) { if (value != NULL) { memcpy(&entry,value,sizeof(entry)); // Warning this is not 1:1 if (strcmp(ipv4,MapAddress((char *)entry.address)) == 0) { CfOut(cf_verbose,""," -> Matched IP %s to key %s",ipv4,key+1); strncpy(result,key+1,CF_MAXVARSIZE-1); break; } } } DeleteDBCursor(dbp,dbcp); CloseDB(dbp); if(EMPTY(result)) { CfOut(cf_verbose, "", "!! Unable to find a key for ip %s", ipv4); } } /***************************************************************/ char *MapAddress(char *unspec_address) { /* Is the address a mapped ipv4 over ipv6 address */ if (strncmp(unspec_address,"::ffff:",7) == 0) { return (char *)(unspec_address+7); } else { return unspec_address; } } /***************************************************************************/ char *EscapeQuotes(char *s, char *out, int outSz) { char *spt,*spf; int i = 0; memset(out,0,outSz); for (spf = s, spt = out; (i < outSz - 2) && (*spf != '\0'); spf++,spt++,i++) { switch (*spf) { case '\'': case '\"': *spt++ = '\\'; *spt = *spf; i+=3; break; default: *spt = *spf; i++; break; } } return out; } /***************************************************************************/ char *EscapeJson(char *s, char *out, int outSz) { char *spt,*spf; int i = 0; memset(out,0,outSz); for (spf = s, spt = out; (i < outSz - 2) && (*spf != '\0'); spf++,spt++,i++) { switch (*spf) { case '\"': case '\\': case '/': *spt++ = '\\'; *spt = *spf; i+=2; break; case '\n': *spt++ = '\\'; *spt = 'n'; i+=2; break; case '\t': *spt++ = '\\'; *spt = 't'; i+=2; break; case '\r': *spt++ = '\\'; *spt = 'r'; i+=2; break; case '\b': *spt++ = '\\'; *spt = 'b'; i+=2; break; case '\f': *spt++ = '\\'; *spt = 'f'; i+=2; break; default: *spt = *spf; i++; break; } } return out; } /***************************************************************************/ char *EscapeRegex(char *s, char *out, int outSz) { char *spt,*spf; int i = 0; memset(out,0,outSz); for (spf = s, spt = out; (i < outSz - 2) && (*spf != '\0'); spf++,spt++,i++) { switch (*spf) { case '\\': case '.': case '|': case '*': case '?': case '+': case '(': case ')': case '{': case '}': case '[': case ']': case '^': case '$': *spt++ = '\\'; *spt = *spf; i+=2; break; default: *spt = *spf; i++; break; } } return out; } /***************************************************************************/ enum cfhypervisors Str2Hypervisors(char *s) { static char *names[] = { "xen", "kvm", "esx", "test", "xen_net", "kvm_net", "esx_net", "test_net", "zone", "ec2", "eucalyptus", NULL }; int i; if (s == NULL) { return cfv_virt_test; } for (i = 0; names[i] != NULL; i++) { if (s && strcmp(s,names[i]) == 0) { return (enum cfhypervisors) i; } } return (enum cfhypervisors) i; } /***************************************************************************/ enum cfenvironment_state Str2EnvState(char *s) { static char *names[] = { "create", "delete", "running", "suspended", "down", NULL }; int i; if (s == NULL) { return cfvs_create; } for (i = 0; names[i] != NULL; i++) { if (s && strcmp(s,names[i]) == 0) { return (enum cfenvironment_state) i; } } return (enum cfenvironment_state) i; } /***************************************************************************/ enum insert_match String2InsertMatch(char *s) { static char *names[] = { "ignore_leading","ignore_trailing","ignore_embedded", "exact_match", NULL }; int i; for (i = 0; names[i] != NULL; i++) { if (s && strcmp(s,names[i]) == 0) { return i; } } return cf_exact_match; } /***************************************************************************/ int SyslogPriority2Int(char *s) { int i; static char *types[] = { "emergency","alert","critical","error", "warning","notice","info","debug", NULL }; for (i = 0; types[i] != NULL; i++) { if (s && strcmp(s,types[i]) == 0) { return i; } } return 3; } /***************************************************************************/ enum cfdbtype Str2dbType(char *s) { int i; static char *types[] = { "mysql","postgres", NULL }; for (i = 0; types[i] != NULL; i++) { if (s && strcmp(s,types[i]) == 0) { return (enum cfdbtype) i; } } return cfd_notype; } /***************************************************************************/ enum package_actions Str2PackageAction(char *s) { int i; static char *types[] = { "add","delete","reinstall","update","addupdate","patch","verify", NULL }; for (i = 0; types[i] != NULL; i++) { if (s && strcmp(s,types[i]) == 0) { return (enum package_actions) i; } } return cfa_pa_none; } /***************************************************************************/ enum version_cmp Str2PackageSelect(char *s) { int i; static char *types[] = { "==","!=",">","<",">=","<=", NULL}; for (i = 0; types[i] != NULL; i++) { if (s && strcmp(s,types[i]) == 0) { return (enum version_cmp) i; } } return cfa_cmp_none; } /***************************************************************************/ enum action_policy Str2ActionPolicy(char *s) { int i; static char *types[] = { "individual","bulk",NULL}; for (i = 0; types[i] != NULL; i++) { if (s && strcmp(s,types[i]) == 0) { return (enum version_cmp) i; } } return cfa_no_ppolicy; } /***************************************************************************/ char *Rlist2String(struct Rlist *list,char *sep) { char line[CF_BUFSIZE]; struct Rlist *rp; line[0] = '\0'; for(rp = list; rp != NULL; rp=rp->next) { strcat(line,(char *)rp->item); if (rp->next) { strcat(line,sep); } } return strdup(line); } /***************************************************************************/ int Signal2Int(char *s) { int i = 0; struct Item *ip, *names = SplitString(CF_SIGNALRANGE,','); for (ip = names; ip != NULL; ip=ip->next) { if (strcmp(s,ip->name) == 0) { break; } i++; } DeleteItemList(names); switch (i) { case cfa_hup: return SIGHUP; case cfa_int: return SIGINT; case cfa_trap: return SIGTRAP; case cfa_kill: return SIGKILL; case cfa_pipe: return SIGPIPE; case cfa_cont: return SIGCONT; case cfa_abrt: return SIGABRT; case cfa_stop: return SIGSTOP; case cfa_quit: return SIGQUIT; case cfa_term: return SIGTERM; case cfa_child: return SIGCHLD; case cfa_usr1: return SIGUSR1; case cfa_usr2: return SIGUSR2; case cfa_bus: return SIGBUS; case cfa_segv: return SIGSEGV; default: return -1; } } /***************************************************************************/ enum cfreport String2ReportLevel(char *s) { int i; static char *types[] = { "inform","verbose","error","log",NULL }; for (i = 0; types[i] != NULL; i++) { if (s && strcmp(s,types[i]) == 0) { return (enum cfreport) i; } } return cf_noreport; } /***************************************************************************/ enum cfhashes String2HashType(char *typestr) { int i; for (i = 0; CF_DIGEST_TYPES[i][0] != NULL; i++) { if (typestr && strcmp(typestr,CF_DIGEST_TYPES[i][0]) == 0) { return (enum cfhashes)i; } } return cf_nohash; } /****************************************************************************/ enum cflinktype String2LinkType(char *s) { int i; static char *types[] = { "symlink","hardlink","relative","absolute",NULL }; for (i = 0; types[i] != NULL; i++) { if (s && strcmp(s,types[i]) == 0) { return (enum cflinktype) i; } } return cfa_symlink; } /****************************************************************************/ enum cfcomparison String2Comparison(char *s) { int i; static char *types[] = {"atime","mtime","ctime","digest","hash","binary","exists",NULL}; for (i = 0; types[i] != NULL; i++) { if (s && strcmp(s,types[i]) == 0) { return (enum cfcomparison) i; } } return cfa_nocomparison; } /****************************************************************************/ enum representations String2Representation(char *s) { int i; static char *types[] = {"url","web","file","db","literal","image","portal",NULL}; for (i = 0; types[i] != NULL; i++) { if (s && strcmp(s,types[i]) == 0) { return (enum representations) i; } } return cfk_none; } /****************************************************************************/ enum cfsbundle Type2Cfs(char *name) { int i; for (i = 0; i < (int)cfs_nobtype; i++) { if (name && strcmp(CF_REMACCESS_SUBTYPES[i].subtype,name)==0) { break; } } return (enum cfsbundle)i; } /****************************************************************************/ enum cfdatatype Typename2Datatype(char *name) /* convert abstract data type names: int, ilist etc */ { int i; Debug("typename2type(%s)\n",name); for (i = 0; i < (int)cf_notype; i++) { if (name && strcmp(CF_DATATYPES[i],name)==0) { break; } } return (enum cfdatatype)i; } /****************************************************************************/ enum cfagenttype Agent2Type(char *name) /* convert abstract data type names: int, ilist etc */ { int i; Debug("Agent2Type(%s)\n",name); for (i = 0; i < (int)cf_notype; i++) { if (name && strcmp(CF_AGENTTYPES[i],name)==0) { break; } } return (enum cfagenttype)i; } /****************************************************************************/ enum cfdatatype GetControlDatatype(char *varname,struct BodySyntax *bp) { int i = 0; for (i = 0; bp[i].range != NULL; i++) { if (varname && strcmp(bp[i].lval,varname) == 0) { return bp[i].dtype; } } return cf_notype; } /****************************************************************************/ int GetBoolean(char *s) { struct Item *list = SplitString(CF_BOOL,','), *ip; int count = 0; for (ip = list; ip != NULL; ip=ip->next) { if (strcmp(s,ip->name) == 0) { break; } count++; } DeleteItemList(list); if (count % 2) { return false; } else { return true; } } /****************************************************************************/ long Str2Int(char *s) { long a = CF_NOINT; char c = 'X'; char remainder[CF_BUFSIZE]; char output[CF_BUFSIZE]; if (s == NULL) { return CF_NOINT; } if (strcmp(s,"inf") == 0) { return (long)CF_INFINITY; } if (strcmp(s,"now") == 0) { return (long)CFSTARTTIME; } remainder[0] = '\0'; sscanf(s,"%ld%c%s",&a,&c,remainder); // Test whether remainder is space only if (a == CF_NOINT || !IsSpace(remainder)) { if (THIS_AGENT_TYPE == cf_common) { CfOut(cf_inform,""," !! Error reading assumed integer value \"%s\" => \"%s\" (found remainder \"%s\")\n",s,"non-value",remainder); if (strchr(s,'$')) { CfOut(cf_inform,""," !! The variable might not yet be expandable - not necessarily an error"); } } } else { switch (c) { case 'k': a = 1000 * a; break; case 'K': a = 1024 * a; break; case 'm': a = 1000 * 1000 * a; break; case 'M': a = 1024 * 1024 * a; break; case 'g': a = 1000 * 1000 * 1000 * a; break; case 'G': a = 1024 * 1024 * 1024 * a; break; case '%': if (a < 0 || a > 100) { CfOut(cf_error,"","Percentage out of range (%d)",a); return CF_NOINT; } else { /* Represent percentages internally as negative numbers */ a = -a; } break; case ' ': break; default: break; } } return a; } /****************************************************************************/ long TimeCounter2Int(const char *s) { long d = 0, h = 0, m = 0; char output[CF_BUFSIZE]; if (s == NULL) { return CF_NOINT; } if (strchr(s, '-')) { if (sscanf(s, "%ld-%ld:%ld", &d, &h, &m) != 3) { snprintf(output, CF_BUFSIZE, "Unable to parse TIME 'ps' field, expected dd-hh:mm, got '%s'", s); ReportError(output); } } else { if (sscanf(s, "%ld:%ld", &h, &m) != 2) { snprintf(output, CF_BUFSIZE, "Unable to parse TIME 'ps' field, expected hH:mm, got '%s'", s); ReportError(output); } } return 60 * (m + 60 * (h + 24 * d)); } /****************************************************************************/ long TimeAbs2Int(char *s) { time_t cftime; int i; char mon[4],h[3],m[3]; long month = 0,day = 0,hour = 0,min = 0, year = 0; static long days[] = {31,28,31,30,31,30,31,31,30,31,30,31}; if (s == NULL) { return CF_NOINT; } year = Str2Int(VYEAR); if (year % 4 == 0) /* leap years */ { days[1] = 29; } if (strstr(s,":")) /* Hr:Min */ { sscanf(s,"%2[^:]:%2[^:]:",h,m); month = Month2Int(VMONTH); day = Str2Int(VDAY); hour = Str2Int(h); min = Str2Int(m); } else /* date Month */ { sscanf(s,"%3[a-zA-Z] %ld",mon,&day); month = Month2Int(mon); if (Month2Int(VMONTH) < month) { /* Wrapped around */ year--; } } Debug("(%s)\n%ld=%s,%ld=%s,%ld,%ld,%ld\n",s,year,VYEAR,month,VMONTH,day,hour,min); cftime = 0; cftime += min * 60; cftime += hour * 3600; cftime += (day - 1) * 24 * 3600; cftime += 24 * 3600 * ((year-1970)/4); /* Leap years */ for (i = 0; i < month - 1; i++) { cftime += days[i] * 24 * 3600; } cftime += (year - 1970) * 365 * 24 * 3600; Debug("Time %s CORRESPONDS %s\n",s,cf_ctime(&cftime)); return (long) cftime; } /****************************************************************************/ long Months2Seconds(int m) { static long days[] = {31,28,31,30,31,30,31,31,30,31,30,31}; long tot_days = 0; int this_month,i,month,year; if (m == 0) { return 0; } this_month = Month2Int(VMONTH); year = Str2Int(VYEAR); for (i = 0; i < m; i++) { month = (this_month - i) % 12; while (month < 0) { month += 12; year--; } if ((year % 4) && (month == 1)) { tot_days += 29; } else { tot_days += days[month]; } } return (long) tot_days * 3600 * 24; } /*********************************************************************/ enum cfinterval Str2Interval(char *string) { static char *text[3] = { "hourly", "daily", NULL }; int i; for (i = 0; text[i] != NULL; i++) { if (string && (strcmp(text[i],string) == 0)) { return i; } } return cfa_nointerval; } /*********************************************************************/ int Day2Number(char *datestring) { int i = 0; for (i = 0; i < 7; i++) { if (strncmp(datestring,DAY_TEXT[i],3) == 0) { return i; } } return -1; } /****************************************************************************/ void UtcShiftInterval(time_t t, char *out, int outSz) /* 00 - 06, 06 - 12, 12 - 18, 18 - 24*/ { char buf[CF_MAXVARSIZE]; int hr = 0, fromHr = 0, toHr = 0; cf_strtimestamp_utc(t,buf); sscanf(buf+11,"%d", &hr); buf[11] = '\0'; if(hr < 6) { fromHr = 0; toHr = 6; } else if(hr < 12) { fromHr = 6; toHr = 12; } else if(hr < 18) { fromHr = 12; toHr = 18; } else { fromHr = 18; toHr = 24; } snprintf(out, outSz, "%s %02d-%02d", buf, fromHr, toHr); } /****************************************************************************/ mode_t Str2Mode(char *s) { int a = CF_UNDEFINED; char output[CF_BUFSIZE]; if (s == NULL) { return 0; } sscanf(s,"%o",&a); if (a == CF_UNDEFINED) { snprintf(output,CF_BUFSIZE,"Error reading assumed octal value %s\n",s); ReportError(output); } return (mode_t)a; } /****************************************************************************/ double Str2Double(char *s) { double a = CF_NODOUBLE; char remainder[CF_BUFSIZE]; char output[CF_BUFSIZE]; char c = 'X'; if (s == NULL) { return CF_NODOUBLE; } remainder[0] = '\0'; sscanf(s,"%lf%c%s",&a,&c,remainder); if (a == CF_NODOUBLE || !IsSpace(remainder)) { snprintf(output,CF_BUFSIZE,"Error reading assumed real value %s (anomalous remainder %s)\n",s,remainder); ReportError(output); } else { switch (c) { case 'k': a = 1000 * a; break; case 'K': a = 1024 * a; break; case 'm': a = 1000 * 1000 * a; break; case 'M': a = 1024 * 1024 * a; break; case 'g': a = 1000 * 1000 * 1000 * a; break; case 'G': a = 1024 * 1024 * 1024 * a; break; case '%': if (a < 0 || a > 100) { CfOut(cf_error,"","Percentage out of range (%d)",a); return CF_NOINT; } else { /* Represent percentages internally as negative numbers */ a = -a; } break; case ' ': break; default: break; } } return a; } /****************************************************************************/ void IntRange2Int(char *intrange,long *min,long *max,struct Promise *pp) { struct Item *split; long lmax = CF_LOWINIT, lmin = CF_HIGHINIT; char output[CF_BUFSIZE]; /* Numeric types are registered by range separated by comma str "min,max" */ if (intrange == NULL) { *min = CF_NOINT; *max = CF_NOINT; return; } split = SplitString(intrange,','); sscanf(split->name,"%ld",&lmin); if (strcmp(split->next->name,"inf") == 0) { lmax = (long)CF_INFINITY; } else { sscanf(split->next->name,"%ld",&lmax); } DeleteItemList(split); if (lmin == CF_HIGHINIT || lmax == CF_LOWINIT) { PromiseRef(cf_error,pp); snprintf(output,CF_BUFSIZE,"Could not make sense of integer range [%s]",intrange); FatalError(output); } *min = lmin; *max = lmax; } /*********************************************************************/ enum cf_acl_method Str2AclMethod(char *string) { static char *text[3] = { "append", "overwrite", NULL }; int i; for (i = 0; i < 2; i++) { if (string && (strcmp(text[i],string) == 0)) { return i; } } return cfacl_nomethod; } /*********************************************************************/ enum cf_acl_type Str2AclType(char *string) { static char *text[4] = { "generic","posix", "ntfs", NULL }; int i; for (i = 0; i < 3; i++) { if (string && (strcmp(text[i],string) == 0)) { return i; } } return cfacl_notype; } /*********************************************************************/ enum cf_acl_inherit Str2AclInherit(char *string) { static char *text[5] = { "nochange", "specify", "parent", "clear", NULL }; int i; for (i = 0; i < 4; i++) { if (string && (strcmp(text[i],string) == 0)) { return i; } } return cfacl_noinherit; } /*********************************************************************/ enum cf_acl_inherit Str2ServicePolicy(char *string) { static char *text[4] = { "start", "stop", "disable", NULL }; int i; for (i = 0; i < 3; i++) { if (string && (strcmp(text[i],string) == 0)) { return i; } } return cfsrv_nostatus; } /*********************************************************************/ char *Dtype2Str(enum cfdatatype dtype) { switch(dtype) { case cf_str: return "s"; case cf_slist: return "sl"; case cf_int: return "i"; case cf_ilist: return "il"; case cf_real: return "r"; case cf_rlist: return "rl"; case cf_opts: return "m"; case cf_olist: return "ml"; default: return "D?"; } } /*********************************************************************/ /* Level */ /*********************************************************************/ int Month2Int(char *string) { return MonthLen2Int(string,10); // no month names longer than 10 chars } /*************************************************************/ int MonthLen2Int(char *string, int len) { int i; if (string == NULL) { return -1; } for (i = 0; i < 12; i++) { if (strncmp(MONTH_TEXT[i],string,strlen(string))==0) { return i+1; break; } } return -1; } /*********************************************************************/ void TimeToDateStr(time_t t, char *outStr, int outStrSz) /** * Formats a time as "30 Sep 2010". */ { char month[CF_SMALLBUF],day[CF_SMALLBUF],year[CF_SMALLBUF]; char tmp[CF_SMALLBUF]; snprintf(tmp,sizeof(tmp),"%s",cf_ctime(&t)); sscanf(tmp,"%*s %5s %3s %*s %5s",month,day,year); snprintf(outStr,outStrSz,"%s %s %s",day,month,year); } /*********************************************************************/ const char *GetArg0(const char *execstr) { const char *sp; static char arg[CF_BUFSIZE]; int i = 0; for (sp = execstr; *sp != ' ' && *sp != '\0'; sp++) { i++; if (*sp == '\"') { DeEscapeQuotedString(sp,arg); return arg; } } memset(arg,0,CF_MAXVARSIZE); strncpy(arg,execstr,i); arg[i] = '\0'; return arg; } /*************************************************************/ void CommPrefix(char *execstr,char *comm) { char *sp; for (sp = execstr; *sp != ' ' && *sp != '\0'; sp++) { } if (sp - 10 >= execstr) { sp -= 10; /* copy 15 most relevant characters of command */ } else { sp = execstr; } memset(comm,0,20); strncpy(comm,sp,15); } /*************************************************************/ int NonEmptyLine(char *line) { char *sp; for (sp = line; *sp != '\0'; sp++) { if (!isspace((int)*sp)) { return true; } } return false; } /*************************************************************/ char *Item2String(struct Item *ip) { struct Item *currItem; int stringSz = 0; char *buf; // compute required buffer size for(currItem = ip; currItem != NULL; currItem = currItem->next) { stringSz += strlen(currItem->name); stringSz++; // newline space } // we automatically get \0-termination because we are not appending a \n after the last item buf = calloc(1, stringSz); if(buf == NULL) { FatalError("Memory allocation in ItemToString()"); } // do the copy for(currItem = ip; currItem != NULL; currItem = currItem->next) { strcat(buf, currItem->name); if(currItem->next != NULL) // no newline after last item { strcat(buf, "\n"); } } return buf; } /*******************************************************************/ static int IsSpace(char *remainder) { char *sp; for (sp = remainder; *sp != '\0'; sp++) { if (!isspace(*sp)) { return false; } } return true; } /*******************************************************************/ int IsNumber(char *s) { char *sp; for (sp = s; *sp != '\0'; sp++) { if (!isdigit(*sp)) { return false; } } return true; } /*******************************************************************/ int IsRealNumber(char *s) { double a = CF_NODOUBLE; sscanf(s,"%lf",&a); if (a == CF_NODOUBLE) { return false; } return true; } /********************************************************************/ enum cfd_menu String2Menu(char *s) { static char *menus[] = { "delta", "full", "relay", NULL }; int i; for (i = 0; menus[i] != NULL; i++) { if (strcmp(s,menus[i]) == 0) { return i; } } return cfd_menu_error; } /*******************************************************************/ /* Unix-only functions */ /*******************************************************************/ #ifndef MINGW /****************************************************************************/ /* Rlist to Uid/Gid lists */ /****************************************************************************/ struct UidList *Rlist2UidList(struct Rlist *uidnames,struct Promise *pp) { struct UidList *uidlist = NULL; struct Rlist *rp; char username[CF_MAXVARSIZE]; uid_t uid; for (rp = uidnames; rp != NULL; rp=rp->next) { username[0] = '\0'; uid = Str2Uid(rp->item,username,pp); AddSimpleUidItem(&uidlist,uid,username); } if (uidlist == NULL) { AddSimpleUidItem(&uidlist,CF_SAME_OWNER,NULL); } return (uidlist); } /*********************************************************************/ struct GidList *Rlist2GidList(struct Rlist *gidnames,struct Promise *pp) { struct GidList *gidlist = NULL; struct Rlist *rp; char groupname[CF_MAXVARSIZE]; gid_t gid; for (rp = gidnames; rp != NULL; rp=rp->next) { groupname[0] = '\0'; gid = Str2Gid(rp->item,groupname,pp); AddSimpleGidItem(&gidlist,gid,groupname); } if (gidlist == NULL) { AddSimpleGidItem(&gidlist,CF_SAME_GROUP,NULL); } return(gidlist); } /*********************************************************************/ uid_t Str2Uid(char *uidbuff,char *usercopy,struct Promise *pp) { struct Item *ip, *tmplist; struct passwd *pw; int offset,uid = -2,tmp = -2; char *machine,*user,*domain; if (uidbuff[0] == '+') /* NIS group - have to do this in a roundabout */ { /* way because calling getpwnam spoils getnetgrent */ offset = 1; if (uidbuff[1] == '@') { offset++; } setnetgrent(uidbuff+offset); tmplist = NULL; while (getnetgrent(&machine,&user,&domain)) { if (user != NULL) { AppendItem(&tmplist,user,NULL); } } endnetgrent(); for (ip = tmplist; ip != NULL; ip=ip->next) { if ((pw = getpwnam(ip->name)) == NULL) { CfOut(cf_inform,""," !! Unknown user in promise \'%s\'\n",ip->name); if (pp != NULL) { PromiseRef(cf_inform,pp); } uid = CF_UNKNOWN_OWNER; /* signal user not found */ } else { uid = pw->pw_uid; if (usercopy != NULL) { strcpy(usercopy,ip->name); } } } DeleteItemList(tmplist); return uid; } if (isdigit((int)uidbuff[0])) { sscanf(uidbuff,"%d",&tmp); uid = (uid_t)tmp; } else { if (strcmp(uidbuff,"*") == 0) { uid = CF_SAME_OWNER; /* signals wildcard */ } else if ((pw = getpwnam(uidbuff)) == NULL) { CfOut(cf_inform,""," !! Unknown user %s in promise\n",uidbuff); uid = CF_UNKNOWN_OWNER; /* signal user not found */ if (usercopy != NULL) { strcpy(usercopy,uidbuff); } } else { uid = pw->pw_uid; } } return uid; } /*********************************************************************/ gid_t Str2Gid(char *gidbuff,char *groupcopy,struct Promise *pp) { struct group *gr; int gid = -2, tmp = -2; if (isdigit((int)gidbuff[0])) { sscanf(gidbuff,"%d",&tmp); gid = (gid_t)tmp; } else { if (strcmp(gidbuff,"*") == 0) { gid = CF_SAME_GROUP; /* signals wildcard */ } else if ((gr = getgrnam(gidbuff)) == NULL) { CfOut(cf_inform,""," !! Unknown group \'%s\' in promise\n",gidbuff); if (pp) { PromiseRef(cf_inform,pp); } gid = CF_UNKNOWN_GROUP; } else { gid = gr->gr_gid; strcpy(groupcopy,gidbuff); } } return gid; } #endif /* NOT MINGW */ �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/mon_network.c��������������������������������������������������������������������0000644�0001750�0001750�00000014106�11715232734�013523� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #include "cf3.defs.h" #include "cf3.extern.h" #include "monitoring.h" /* Globals */ static struct Item *ALL_INCOMING; static struct Item *ALL_OUTGOING; /* Implementation */ static void SetNetworkEntropyClasses(const char *service, const char *direction, const struct Item *list) { const struct Item *ip; struct Item *addresses = NULL; double entropy; for (ip = list; ip != NULL; ip=ip->next) { if (strlen(ip->name) > 0) { char local[CF_BUFSIZE]; char remote[CF_BUFSIZE]; char vbuff[CF_BUFSIZE]; char *sp; if (strncmp(ip->name,"tcp",3) == 0) { sscanf(ip->name,"%*s %*s %*s %s %s",local,remote); /* linux-like */ } else { sscanf(ip->name,"%s %s",local,remote); /* solaris-like */ } strncpy(vbuff,remote,CF_BUFSIZE-1); for (sp = vbuff+strlen(vbuff)-1; isdigit((int)*sp); sp--) { } *sp = '\0'; if (!IsItemIn(addresses,vbuff)) { AppendItem(&addresses,vbuff,""); } IncrementItemListCounter(addresses,vbuff); } } entropy = MonEntropyCalculate(addresses); MonEntropyClassesSet(service, direction, entropy); DeleteItemList(addresses); } /******************************************************************************/ void MonNetworkGatherData(double *cf_this) { FILE *pp; char local[CF_BUFSIZE],remote[CF_BUFSIZE],comm[CF_BUFSIZE]; struct Item *in[ATTR],*out[ATTR]; char *sp; int i; char vbuff[CF_BUFSIZE]; Debug("GatherSocketData()\n"); for (i = 0; i < ATTR; i++) { in[i] = out[i] = NULL; } if (ALL_INCOMING != NULL) { DeleteItemList(ALL_INCOMING); ALL_INCOMING = NULL; } if (ALL_OUTGOING != NULL) { DeleteItemList(ALL_OUTGOING); ALL_OUTGOING = NULL; } sscanf(VNETSTAT[VSYSTEMHARDCLASS],"%s",comm); strcat(comm," -n"); if ((pp = cf_popen(comm,"r")) == NULL) { return; } while (!feof(pp)) { memset(local,0,CF_BUFSIZE); memset(remote,0,CF_BUFSIZE); CfReadLine(vbuff,CF_BUFSIZE,pp); if (strstr(vbuff,"UNIX")) { break; } if (!strstr(vbuff,".")) { continue; } /* Different formats here ... ugh.. */ if (strncmp(vbuff,"tcp",3) == 0) { sscanf(vbuff,"%*s %*s %*s %s %s",local,remote); /* linux-like */ } else { sscanf(vbuff,"%s %s",local,remote); /* solaris-like */ } if (strlen(local) == 0) { continue; } for (sp = local+strlen(local); (*sp != '.') && (sp > local); sp--) { } sp++; if ((strlen(sp) < 5) &&!IsItemIn(ALL_INCOMING,sp)) { PrependItem(&ALL_INCOMING,sp,NULL); } for (sp = remote+strlen(remote); (sp >= remote) && !isdigit((int)*sp); sp--) { } sp++; if ((strlen(sp) < 5) && !IsItemIn(ALL_OUTGOING,sp)) { PrependItem(&ALL_OUTGOING,sp,NULL); } for (i = 0; i < ATTR; i++) { char *spend; for (spend = local+strlen(local)-1; isdigit((int)*spend); spend--) { } spend++; if (strcmp(spend,ECGSOCKS[i].portnr) == 0) { cf_this[ECGSOCKS[i].in]++; AppendItem(&in[i],vbuff,""); } for (spend = remote+strlen(remote)-1; (sp >= remote) && isdigit((int)*spend); spend--) { } spend++; if (strcmp(spend,ECGSOCKS[i].portnr) == 0) { cf_this[ECGSOCKS[i].out]++; AppendItem(&out[i],vbuff,""); } } } cf_pclose(pp); /* Now save the state for ShowState() cf2 version alert function IFF the state is not smaller than the last or at least 40 minutes older. This mirrors the persistence of the maxima classes */ for (i = 0; i < ATTR; i++) { struct stat statbuf; time_t now = time(NULL); Debug("save incoming %s\n",ECGSOCKS[i].name); snprintf(vbuff,CF_MAXVARSIZE,"%s/state/cf_incoming.%s",CFWORKDIR,ECGSOCKS[i].name); if (cfstat(vbuff,&statbuf) != -1) { if ((ByteSizeList(in[i]) < statbuf.st_size) && (now < statbuf.st_mtime+40*60)) { CfOut(cf_verbose,"","New state %s is smaller, retaining old for 40 mins longer\n",ECGSOCKS[i].name); DeleteItemList(in[i]); continue; } } SetNetworkEntropyClasses(ECGSOCKS[i].name,"in",in[i]); RawSaveItemList(in[i],vbuff); DeleteItemList(in[i]); Debug("Saved in netstat data in %s\n",vbuff); } for (i = 0; i < ATTR; i++) { struct stat statbuf; time_t now = time(NULL); Debug("save outgoing %s\n",ECGSOCKS[i].name); snprintf(vbuff,CF_MAXVARSIZE,"%s/state/cf_outgoing.%s",CFWORKDIR,ECGSOCKS[i].name); if (cfstat(vbuff,&statbuf) != -1) { if ((ByteSizeList(out[i]) < statbuf.st_size) && (now < statbuf.st_mtime+40*60)) { CfOut(cf_verbose,"","New state %s is smaller, retaining old for 40 mins longer\n",ECGSOCKS[i].name); DeleteItemList(out[i]); continue; } } SetNetworkEntropyClasses(ECGSOCKS[i].name,"out",out[i]); RawSaveItemList(out[i],vbuff); Debug("Saved out netstat data in %s\n",vbuff); DeleteItemList(out[i]); } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/string_expressions.c�������������������������������������������������������������0000644�0001750�0001750�00000014617�11715232734�015140� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifdef HAVE_CONFIG_H # include <conf.h> #endif #include <stdlib.h> #include <string.h> #include <stdio.h> #include "bool.h" #include "string_expressions.h" #include "cf3.defs.h" #include "prototypes3.h" /* <qname> */ static StringParseResult ParseQname(const char *expr, int start, int end) { StringParseResult lhs, rhs; StringExpression *ret, *subret, *dot; lhs = ParseStringExpression(expr, start, end); if (!lhs.result) { return lhs; } if (lhs.position == end || expr[lhs.position] != '.') { return lhs; } rhs = ParseStringExpression(expr, lhs.position + 1, end); if (!rhs.result) { FreeStringExpression(lhs.result); return rhs; } dot = calloc(1, sizeof(StringExpression)); dot->op = LITERAL; dot->val.literal.literal = strdup("."); subret = calloc(1, sizeof(StringExpression)); subret->op = CONCAT; subret->val.concat.lhs = dot; subret->val.concat.rhs = rhs.result; ret = calloc(1, sizeof(StringExpression)); ret->op = CONCAT; ret->val.concat.lhs = lhs.result; ret->val.concat.rhs = subret; return (StringParseResult) { ret, rhs.position }; } /* <var-ref> */ static StringParseResult ParseVarRef(const char *expr, int start, int end) { if (start + 1 < end && expr[start] == '$') { if (expr[start+1] == '(' || expr[start+1] == '{') { char closing_bracket = expr[start+1] == '(' ? ')' : '}'; StringParseResult res = ParseQname(expr, start + 2, end); if (res.result) { if (res.position < end && expr[res.position] == closing_bracket) { StringExpression *ret = calloc(1, sizeof(StringExpression)); ret->op = VARREF; ret->val.varref.name = res.result; return (StringParseResult) { ret, res.position + 1 }; } else { FreeStringExpression(res.result); return (StringParseResult) { NULL, res.position }; } } else { return res; } } else { return (StringParseResult) { NULL, start + 1 }; } } else { return (StringParseResult) { NULL, start }; } } /* <token> */ static bool ValidTokenCharacter(char c) { if (c >= 'a' && c <= 'z') { return true; } if (c >= 'A' && c <= 'Z') { return true; } if (c >= '0' && c <= '9') { return true; } if (c == '_' || c == '[' || c == ']') { return true; } return false; } static StringParseResult ParseToken(const char *expr, int start, int end) { int endlit = start; while (endlit < end && ValidTokenCharacter(expr[endlit])) { endlit++; } if (endlit > start) { StringExpression *ret = calloc(1, sizeof(StringExpression)); ret->op = LITERAL; ret->val.literal.literal = strndup(expr + start, endlit - start); return (StringParseResult) { ret, endlit }; } else { return (StringParseResult) { NULL, endlit }; } } /* <term> */ static StringParseResult ParseTerm(const char *expr, int start, int end) { StringParseResult res = ParseToken(expr, start, end); if (res.result) { return res; } else { return ParseVarRef(expr, start, end); } } /* <name> */ StringParseResult ParseStringExpression(const char *expr, int start, int end) { StringParseResult lhs = ParseTerm(expr, start, end); if (lhs.result) { StringParseResult rhs = ParseStringExpression(expr, lhs.position, end); if (rhs.result) { StringExpression *ret = calloc(1, sizeof(StringExpression)); ret->op = CONCAT; ret->val.concat.lhs = lhs.result; ret->val.concat.rhs = rhs.result; return (StringParseResult) { ret, rhs.position }; } else { return lhs; } } else { return lhs; } } /* Evaluation */ static char *EvalConcat(const StringExpression *expr, VarRefEvaluator evalfn, void *param) { char *lhs, *rhs; lhs = EvalStringExpression(expr->val.concat.lhs, evalfn, param); if (!lhs) { return NULL; } rhs = EvalStringExpression(expr->val.concat.rhs, evalfn, param); if (!rhs) { free(lhs); return NULL; } char *res = malloc(strlen(lhs) + strlen(rhs) + 1); sprintf(res, "%s%s", lhs, rhs); free(lhs); free(rhs); return res; } static char *EvalVarRef(const StringExpression *expr, VarRefEvaluator evalfn, void *param) { char *name, *eval; name = EvalStringExpression(expr->val.varref.name, evalfn, param); if (!name) { return NULL; } eval = (*evalfn)(name, param); free(name); return eval; } char *EvalStringExpression(const StringExpression *expr, VarRefEvaluator evalfn, void *param) { switch (expr->op) { case CONCAT: return EvalConcat(expr, evalfn, param); case LITERAL: return strdup(expr->val.literal.literal); case VARREF: return EvalVarRef(expr, evalfn, param); default: FatalError("Unknown type of string expression" "encountered during evaluation: %d", expr->op); } } /* Freeing results */ void FreeStringExpression(StringExpression *expr) { if (!expr) { return; } switch (expr->op) { case CONCAT: FreeStringExpression(expr->val.concat.lhs); FreeStringExpression(expr->val.concat.rhs); break; case LITERAL: free(expr->val.literal.literal); break; case VARREF: FreeStringExpression(expr->val.varref.name); break; default: FatalError("Unknown type of string expression encountered: %d", expr->op); } free(expr); } �����������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/mod_measurement.c����������������������������������������������������������������0000644�0001750�0001750�00000010047�11715232734�014345� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_process.c */ /* */ /*****************************************************************************/ /* This file can act as a template for adding functionality to cfengine 3. All functionality can be added by extending the main array CF_MOD_SUBTYPES[CF3_MODULES] and its array dimension, in mod_common, in the manner shown here. */ #define CF3_MOD_MEASUREMENT #include "cf3.defs.h" #include "cf3.extern.h" /***********************************************************/ /* Read this module file backwards, as dependencies have */ /* to be defined first - these arrays declare pairs of */ /* constraints */ /* */ /* lval => rval */ /* */ /* in the form (lval,type,range) */ /* */ /* If the type is cf_body then the range is a pointer */ /* to another array of pairs, like in a body "sub-routine" */ /* */ /***********************************************************/ struct BodySyntax CF_MATCHVALUE_BODY[] = { /* Row models */ {"select_line_matching",cf_str,CF_ANYSTRING,"Regular expression for matching line location"}, {"select_line_number",cf_int,CF_VALRANGE,"Read from the n-th line of the output (fixed format)"}, {"extraction_regex",cf_str,"","Regular expression that should contain a single backreference for extracting a value"}, {"track_growing_file",cf_opts,CF_BOOL,"If true, cfengine remembers the position to which is last read when opening the file, and resets to the start if the file has since been truncated"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ struct BodySyntax CF_MEASURE_BODIES[] = { {"stream_type",cf_opts,"pipe,file","The datatype being collected."}, {"data_type",cf_opts,"counter,int,real,string,slist","The datatype being collected."}, {"history_type",cf_opts,"weekly,scalar,static,log","Whether the data can be seen as a time-series or just an isolated value"}, {"units",cf_str,"","The engineering dimensions of this value or a note about its intent used in plots"}, {"match_value",cf_body,CF_MATCHVALUE_BODY,"Criteria for extracting the measurement from a datastream"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_MEASUREMENT_SUBTYPES[] = { {"monitor","measurements",CF_MEASURE_BODIES}, {NULL,NULL,NULL}, }; �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/dbm_berkeley.c�������������������������������������������������������������������0000644�0001750�0001750�00000022061�11715232734�013604� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: dbm_berkeley.c */ /* */ /*****************************************************************************/ /* * Implementation of the Cfengine DBM API using Berkeley DB. */ #include "cf3.defs.h" #include "cf3.extern.h" #ifdef BDB static DBT *BDB_NewDBKey(char *name); static DBT *BDB_NewDBComplexKey(char *key,int size); static void BDB_DeleteDBKey(DBT *key); static DBT *BDB_NewDBValue(const void *ptr,int size); static void BDB_DeleteDBValue(DBT *value); /*****************************************************************************/ int BDB_OpenDB(char *filename,DB **dbp) { int ret; if ((ret = db_create(dbp,NULL,0)) != 0) { CfOut(cf_error, "", "BDB_OpenDB: Couldn't get database environment for %s: %s\n", filename, db_strerror(ret)); return false; } #ifdef CF_OLD_DB if ((ret = ((*dbp)->open)(*dbp,filename,NULL,DB_BTREE,DB_CREATE,0644)) != 0) #else if ((ret = ((*dbp)->open)(*dbp,NULL,filename,NULL,DB_BTREE,DB_CREATE,0644)) != 0) #endif { CfOut(cf_error, "", "BDB_OpenDB: Couldn't open database %s: %s\n", filename, db_strerror(ret)); return false; } return true; } /*****************************************************************************/ int BDB_CloseDB(DB *dbp) { int ret; if ((ret = dbp->close(dbp, 0)) == 0) { return true; } else { CfOut(cf_error, "", "BDB_CloseDB: Unable to close database: %s\n", db_strerror(ret)); return false; } } /*****************************************************************************/ int BDB_ValueSizeDB(DB *dbp, char *key) { DBT *db_key, value; int retv; int ret; db_key = BDB_NewDBKey(key); memset(&value,0,sizeof(DBT)); if ((ret = dbp->get(dbp,NULL,db_key,&value,0)) == 0) { retv = value.size; } else { retv = -1; if (ret == DB_NOTFOUND || ret == DB_KEYEMPTY) { Debug("Key %s does not exist in database.\n", key); } else { CfOut(cf_error, "", "BDB_ValueSizeDB: Error trying to read database: %s\n", db_strerror(ret)); } } BDB_DeleteDBKey(db_key); return retv; } /*****************************************************************************/ int BDB_ReadComplexKeyDB(DB *dbp,char *name,int keysize,void *ptr,int size) { DBT *key,value; int ret; bool retval = false; key = BDB_NewDBValue(name,keysize); memset(&value,0,sizeof(DBT)); if ((ret = dbp->get(dbp,NULL,key,&value,0)) == 0) { memset(ptr,0,size); if (value.data) { if (size < value.size) { memcpy(ptr,value.data,size); } else { memcpy(ptr,value.data,value.size); } Debug("READ %s\n",name); retval = true; } } else { if (ret == DB_NOTFOUND || ret == DB_KEYEMPTY) { Debug("Key %.*s does not exist in database", keysize, name); } else { CfOut(cf_error, "", "BDB_ReadComplexKeyDB: Error trying to read database: %s\n", db_strerror(ret)); } } BDB_DeleteDBValue(key); return retval; } /*****************************************************************************/ int BDB_RevealDB(DB *dbp,char *name,void **result,int *rsize) { DBT *key,value; int ret; bool retval = false; key = BDB_NewDBKey(name); memset(&value,0,sizeof(DBT)); if ((ret = dbp->get(dbp,NULL,key,&value,0)) == 0) { if (value.data) { *rsize = value.size; *result = value.data; retval = true; } } else { if (ret == DB_NOTFOUND || ret == DB_KEYEMPTY) { Debug("Key %s does not exist in database", name); } else { CfOut(cf_error, "", "Error trying to read database: %s\n", db_strerror(ret)); } } BDB_DeleteDBKey(key); return retval; } /*****************************************************************************/ int BDB_WriteComplexKeyDB(DB *dbp,char *name,int keysize,const void *ptr,int size) { DBT *key,*value; int ret; key = BDB_NewDBValue(name,keysize); value = BDB_NewDBValue(ptr,size); if ((ret = dbp->put(dbp,NULL,key,value,0)) == 0) { Debug("WriteDB => %s\n",name); BDB_DeleteDBValue(key); BDB_DeleteDBValue(value); return true; } else { CfOut(cf_error, "", "BDB_WriteComplexKeyDB: Error trying to write database: %s\n", db_strerror(ret)); BDB_DeleteDBKey(key); BDB_DeleteDBValue(value); return false; } } /*****************************************************************************/ int BDB_DeleteComplexKeyDB(DB *dbp,char *name,int size) { DBT *key; int ret; key = BDB_NewDBValue(name,size); if ((ret = dbp->del(dbp,NULL,key,0)) == 0) { BDB_DeleteDBKey(key); return true; } else { if (ret == DB_NOTFOUND || ret == DB_KEYEMPTY) { Debug("Trying to remove from database non-existing key %.*s\n", size, name); } else { CfOut(cf_error, "", "BDB_DeleteComplexKeyDB: " "Unable to remove key %.*s from database: %s\n", size, name, db_strerror(ret)); } BDB_DeleteDBKey(key); return false; } } /*****************************************************************************/ int BDB_NewDBCursor(CF_DB *dbp,CF_DBC **dbcpp) { int ret; if ((ret = dbp->cursor(dbp,NULL,dbcpp,0)) == 0) { return true; } else { CfOut(cf_error, "", "BDB_NewDBCursor: Error establishing cursor for hash database: %s\n", db_strerror(ret)); return false; } } /*****************************************************************************/ int BDB_NextDB(CF_DB *dbp,CF_DBC *dbcp,char **key,int *ksize,void **value,int *vsize) { DBT dbvalue,dbkey; int ret; memset(&dbkey,0,sizeof(DBT)); memset(&dbvalue,0,sizeof(DBT)); ret = dbcp->c_get(dbcp,&dbkey,&dbvalue,DB_NEXT); *ksize = dbkey.size; *vsize = dbvalue.size; *key = dbkey.data; *value = dbvalue.data; if (ret == 0) { return true; } else { if (ret != DB_NOTFOUND && ret != DB_KEYEMPTY) { CfOut(cf_error, "", "BDB_NextDB: Unable to read database: %s\n", db_strerror(ret)); } return false; } } /*****************************************************************************/ int BDB_DeleteDBCursor(CF_DB *dbp,CF_DBC *dbcp) { int ret; if ((ret = dbcp->c_close(dbcp)) == 0) { return true; } else { CfOut(cf_error, "", "BDB_DeleteDBCursor: Unable to close cursor: %s\n", db_strerror(ret)); return false; } } /*****************************************************************************/ /* Level 2 */ /*****************************************************************************/ static DBT *BDB_NewDBKey(char *name) { char *dbkey; DBT *key; if ((dbkey = malloc(strlen(name)+1)) == NULL) { FatalError("NewChecksumKey malloc error"); } if ((key = (DBT *)malloc(sizeof(DBT))) == NULL) { FatalError("DBT malloc error"); } memset(key,0,sizeof(DBT)); memset(dbkey,0,strlen(name)+1); strncpy(dbkey,name,strlen(name)); key->data = (void *)dbkey; key->size = strlen(name)+1; return key; } /*****************************************************************************/ static void BDB_DeleteDBKey(DBT *key) { free((char *)key->data); free((char *)key); } /*****************************************************************************/ static DBT *BDB_NewDBValue(const void *ptr,int size) { void *val; DBT *value; if ((val = (void *)malloc(size)) == NULL) { FatalError("BDB_NewDBKey malloc error"); } if ((value = (DBT *) malloc(sizeof(DBT))) == NULL) { FatalError("DBT Value malloc error"); } memset(value,0,sizeof(DBT)); memcpy(val,ptr,size); value->data = val; value->size = size; return value; } /*****************************************************************************/ static void BDB_DeleteDBValue(DBT *value) { free((char *)value->data); free((char *)value); } #endif �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/files_copy.c���������������������������������������������������������������������0000644�0001750�0001750�00000020737�11715232734�013324� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: files_copy.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*****************************************************************************/ void *CopyFileSources(char *destination,struct Attributes attr,struct Promise *pp) { char *source = attr.copy.source; char *server = pp->this_server; char vbuff[CF_BUFSIZE]; struct stat ssb,dsb; struct timespec start; char eventname[CF_BUFSIZE]; Debug("CopyFileSources(%s,%s)", source, destination); if (pp->conn != NULL && !pp->conn->authenticated) { cfPS(cf_verbose,CF_FAIL,"",pp,attr,"No authenticated source %s in files.copyfrom promise\n",source); return NULL; } if (cf_stat(attr.copy.source,&ssb,attr,pp) == -1) { cfPS(cf_inform,CF_FAIL,"",pp,attr,"Can't stat %s in files.copyfrom promise\n",source); return NULL; } start = BeginMeasure(); strncpy(vbuff,destination,CF_BUFSIZE-4); if (S_ISDIR(ssb.st_mode)) /* could be depth_search */ { AddSlash(vbuff); strcat(vbuff,"."); } if (!MakeParentDirectory(vbuff,attr.move_obstructions)) { cfPS(cf_inform,CF_FAIL,"",pp,attr,"Can't make directories for %s in files.copyfrom promise\n",vbuff); return NULL; } if (S_ISDIR(ssb.st_mode)) /* could be depth_search */ { if (attr.copy.purge) { CfOut(cf_verbose,""," !! (Destination purging enabled)\n"); } CfOut(cf_verbose,""," ->> Entering %s\n",source); SetSearchDevice(&ssb,pp); SourceSearchAndCopy(source,destination,attr.recursion.depth,attr,pp); if (cfstat(destination,&dsb) != -1) { if (attr.copy.check_root) { VerifyCopiedFileAttributes(destination,&dsb,&ssb,attr,pp); } } } else { VerifyCopy(source,destination,attr,pp); } snprintf(eventname,CF_BUFSIZE-1,"Copy(%s:%s > %s)",server,source,destination); EndMeasure(eventname,start); if (attr.transaction.background) { ServerDisconnection(pp->conn); } else { ServerNotBusy(pp->conn); } return NULL; } /*****************************************************************************/ /* Local low level */ /*****************************************************************************/ void CheckForFileHoles(struct stat *sstat,struct Promise *pp) /* Need a transparent way of getting this into CopyReg() */ /* Use a public member in struct Image */ { if (pp == NULL) { return; } #if !defined(IRIX) && !defined(MINGW) if (sstat->st_size > sstat->st_blocks * DEV_BSIZE) #else # ifdef HAVE_ST_BLOCKS if (sstat->st_size > sstat->st_blocks * DEV_BSIZE) # else if (sstat->st_size > ST_NBLOCKS((*sstat)) * DEV_BSIZE) # endif #endif { pp->makeholes = 1; /* must have a hole to get checksum right */ } pp->makeholes = 0; } /*********************************************************************/ int CopyRegularFileDisk(char *source,char *new,struct Attributes attr,struct Promise *pp) { int sd, dd, buf_size; char *buf, *cp; int n_read, *intp; long n_read_total = 0; int last_write_made_hole = 0; if ((sd = open(source,O_RDONLY|O_BINARY)) == -1) { CfOut(cf_inform,"open","Can't copy %s!\n",source); unlink(new); return false; } unlink(new); /* To avoid link attacks */ if ((dd = open(new,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0600)) == -1) { cfPS(cf_inform,CF_FAIL,"open",pp,attr,"Copy %s possible security violation (race) or permission denied (Not copied)\n",new); close(sd); unlink(new); return false; } buf_size = ST_BLKSIZE(dstat); buf = (char *) malloc(buf_size + sizeof(int)); while (true) { if ((n_read = read(sd,buf,buf_size)) == -1) { if (errno == EINTR) { continue; } close(sd); close(dd); free(buf); return false; } if (n_read == 0) { break; } n_read_total += n_read; intp = 0; if (pp && pp->makeholes) { buf[n_read] = 1; /* Sentinel to stop loop. */ /* Find first non-zero *word*, or the word with the sentinel. */ intp = (int *) buf; while (*intp++ == 0) { } /* Find the first non-zero *byte*, or the sentinel. */ cp = (char *) (intp - 1); while (*cp++ == 0) { } /* If we found the sentinel, the whole input block was zero, and we can make a hole. */ if (cp > buf + n_read) { /* Make a hole. */ if (lseek (dd, (off_t) n_read, SEEK_CUR) < 0L) { CfOut(cf_error,"lseek","Copy failed (no space?) while doing %s to %s\n",source,new); free(buf); unlink(new); close(dd); close(sd); return false; } last_write_made_hole = 1; } else { /* Clear to indicate that a normal write is needed. */ intp = 0; } } if (intp == 0) { if (cf_full_write (dd, buf, n_read) < 0) { CfOut(cf_error,"","Copy failed (no space?) while doing %s to %s\n",source,new); close(sd); close(dd); free(buf); unlink(new); return false; } last_write_made_hole = 0; } } /* If the file ends with a `hole', something needs to be written at the end. Otherwise the kernel would truncate the file at the end of the last write operation. */ if (last_write_made_hole) { /* Write a null character and truncate it again. */ if (cf_full_write (dd, "", 1) < 0 || ftruncate (dd, n_read_total) < 0) { CfOut(cf_error,"write","cfengine: full_write or ftruncate error in CopyReg\n"); free(buf); unlink(new); close(sd); close(dd); return false; } } close(sd); close(dd); free(buf); return true; } /*********************************************************************/ int FSWrite(char *new,int dd,char *buf,int towrite,int *last_write_made_hole,int n_read,struct Attributes attr,struct Promise *pp) { int *intp; char *cp; intp = 0; if (pp && pp->makeholes) { buf[n_read] = 1; /* Sentinel to stop loop. */ /* Find first non-zero *word*, or the word with the sentinel. */ intp = (int *) buf; while (*intp++ == 0) { } /* Find the first non-zero *byte*, or the sentinel. */ cp = (char *) (intp - 1); while (*cp++ == 0) { } /* If we found the sentinel, the whole input block was zero, and we can make a hole. */ if (cp > buf + n_read) { /* Make a hole. */ if (lseek (dd,(off_t)n_read,SEEK_CUR) < 0L) { CfOut(cf_error,"lseek","lseek in EmbeddedWrite, dest=%s\n", new); return false; } *last_write_made_hole = 1; } else { /* Clear to indicate that a normal write is needed. */ intp = 0; } } if (intp == 0) { if (cf_full_write(dd,buf,towrite) < 0) { CfOut(cf_error,"write","Local disk write(%.256s) failed\n",new); pp->conn->error = true; return false; } *last_write_made_hole = 0; } return true; } ���������������������������������cfengine-3.2.4/src/transaction.c��������������������������������������������������������������������0000644�0001750�0001750�00000046432�11715232734�013515� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: transaction.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void WaitForCriticalSection(void); static void ReleaseCriticalSection(void); static time_t FindLock(char *last); static int WriteLock(char *lock); static int RemoveLock(char *name); static void LogLockCompletion(char *cflog,int pid,char *str,char *operator,char *operand); static time_t FindLockTime(char *name); static pid_t FindLockPid(char *name); static CF_DB *OpenLock(void); static void CloseLock(CF_DB *dbp); #if defined HAVE_PTHREAD_H && (defined HAVE_LIBPTHREAD || defined BUILDTIN_GCC_THREAD) static pthread_mutex_t *NameToThreadMutex(enum cf_thread_mutex name); #endif static void RemoveDates(char *s); /*****************************************************************************/ void SummarizeTransaction(struct Attributes attr,struct Promise *pp,char *logname) { FILE *fout; if (logname && attr.transaction.log_string) { if (strcmp(logname,"udp_syslog") == 0) { RemoteSyslog(attr,pp); } else if (strcmp(logname,"stdout") == 0) { CfOut(cf_reporting,"","L: %s\n",attr.transaction.log_string); } else { if ((fout = fopen(logname,"a")) == NULL) { CfOut(cf_error,"","Unable to open private log %s",logname); return; } CfOut(cf_verbose,""," -> Logging string \"%s\" to %s\n",attr.transaction.log_string,logname); fprintf(fout,"%s\n",attr.transaction.log_string); fclose(fout); } attr.transaction.log_string = NULL; /* To avoid repetition */ } else if (attr.transaction.log_failed) { if (strcmp(logname,attr.transaction.log_failed) == 0) { cfPS(cf_log,CF_NOP,"",pp,attr,"%s",attr.transaction.log_string); } } } /*****************************************************************************/ struct CfLock AcquireLock(char *operand,char *host,time_t now,struct Attributes attr,struct Promise *pp, int ignoreProcesses) { unsigned int pid; int i, err, sum=0; time_t lastcompleted = 0, elapsedtime; char *promise,cc_operator[CF_BUFSIZE],cc_operand[CF_BUFSIZE]; char cflock[CF_BUFSIZE],cflast[CF_BUFSIZE],cflog[CF_BUFSIZE]; char str_digest[CF_BUFSIZE]; struct CfLock this; unsigned char digest[EVP_MAX_MD_SIZE+1]; this.last = (char *) CF_UNDEFINED; this.lock = (char *) CF_UNDEFINED; this.log = (char *) CF_UNDEFINED; if (now == 0) { return this; } this.last = NULL; this.lock = NULL; this.log = NULL; /* Indicate as done if we tried ... as we have passed all class constraints now but we should only do this for level 0 promises. Sub routine bundles cannot be marked as done or it will disallow iteration over bundles */ if (pp->done) { return this; } if (CF_STCKFRAME == 1) { *(pp->donep) = true; /* Must not set pp->done = true for editfiles etc */ } HashPromise(operand,pp,digest,CF_DEFAULT_DIGEST); strcpy(str_digest,HashPrint(CF_DEFAULT_DIGEST,digest)); /* As a backup to "done" we need something immune to re-use */ if (THIS_AGENT_TYPE == cf_agent) { if (IsItemIn(DONELIST,str_digest)) { CfOut(cf_verbose,""," -> This promise has already been verified"); return this; } PrependItem(&DONELIST,str_digest,NULL); } /* Finally if we're supposed to ignore locks ... do the remaining stuff */ if (IGNORELOCK) { this.lock = strdup("dummy"); return this; } promise = BodyName(pp); snprintf(cc_operator,CF_MAXVARSIZE-1,"%s-%s",promise,host); strncpy(cc_operand, operand, CF_BUFSIZE-1); CanonifyNameInPlace(cc_operand); RemoveDates(cc_operand); free(promise); Debug("AcquireLock(%s,%s), ExpireAfter=%d, IfElapsed=%d\n",cc_operator,cc_operand,attr.transaction.expireafter,attr.transaction.ifelapsed); for (i = 0; cc_operator[i] != '\0'; i++) { sum = (CF_MACROALPHABET * sum + cc_operator[i]) % CF_HASHTABLESIZE; } for (i = 0; cc_operand[i] != '\0'; i++) { sum = (CF_MACROALPHABET * sum + cc_operand[i]) % CF_HASHTABLESIZE; } snprintf(cflog,CF_BUFSIZE,"%s/cf3.%.40s.runlog",CFWORKDIR,host); snprintf(cflock,CF_BUFSIZE,"lock.%.100s.%s.%.100s_%d_%s",pp->bundle,cc_operator,cc_operand,sum,str_digest); snprintf(cflast,CF_BUFSIZE,"last.%.100s.%s.%.100s_%d_%s",pp->bundle,cc_operator,cc_operand,sum,str_digest); Debug("LOCK(%s)[%s]\n",pp->bundle,cflock); // Now see if we can get exclusivity to edit the locks CFINITSTARTTIME = time(NULL); WaitForCriticalSection(); /* Look for non-existent (old) processes */ lastcompleted = FindLock(cflast); elapsedtime = (time_t)(now-lastcompleted) / 60; if (elapsedtime < 0) { CfOut(cf_verbose,""," XX Another cf-agent seems to have done this since I started (elapsed=%d)\n",elapsedtime); ReleaseCriticalSection(); return this; } if (elapsedtime < attr.transaction.ifelapsed) { CfOut(cf_verbose,""," XX Nothing promised here [%.40s] (%u/%u minutes elapsed)\n",cflock,elapsedtime,attr.transaction.ifelapsed); ReleaseCriticalSection(); return this; } /* Look for existing (current) processes */ if (!ignoreProcesses) { lastcompleted = FindLock(cflock); elapsedtime = (time_t)(now-lastcompleted) / 60; if (lastcompleted != 0) { if (elapsedtime >= attr.transaction.expireafter) { CfOut(cf_inform,"","Lock %s expired (after %u/%u minutes)\n",cflock,elapsedtime,attr.transaction.expireafter); pid = FindLockPid(cflock); if (pid == -1) { CfOut(cf_error,"","Illegal pid in corrupt lock %s - ignoring lock\n",cflock); } #ifdef MINGW // killing processes with e.g. task manager does not allow for termination handling else if (!NovaWin_IsProcessRunning(pid)) { CfOut(cf_verbose,"","Process with pid %d is not running - ignoring lock (Windows does not support graceful processes termination)\n",pid); LogLockCompletion(cflog,pid,"Lock expired, process not running",cc_operator,cc_operand); unlink(cflock); } #endif /* MINGW */ else { CfOut(cf_verbose,"","Trying to kill expired process, pid %d\n",pid); err = GracefulTerminate(pid); if (err || errno == ESRCH) { LogLockCompletion(cflog,pid,"Lock expired, process killed",cc_operator,cc_operand); unlink(cflock); } else { ReleaseCriticalSection(); CfOut(cf_error,"kill","Unable to kill expired cfagent process %d from lock %s, exiting this time..\n",pid,cflock); FatalError(""); } } } else { ReleaseCriticalSection(); CfOut(cf_verbose,"","Couldn't obtain lock for %s (already running!)\n",cflock); return this; } } WriteLock(cflock); } ReleaseCriticalSection(); this.lock = strdup(cflock); this.last = strdup(cflast); this.log = strdup(cflog); /* Keep this as a global for signal handling */ strcpy(CFLOCK,cflock); strcpy(CFLAST,cflast); strcpy(CFLOG,cflog); return this; } /************************************************************************/ void YieldCurrentLock(struct CfLock this) { if (IGNORELOCK) { return; } if (this.lock == (char *)CF_UNDEFINED) { return; } Debug("Yielding lock %s\n",this.lock); if (RemoveLock(this.lock) == -1) { CfOut(cf_verbose,"","Unable to remove lock %s\n",this.lock); free(this.last); free(this.lock); free(this.log); return; } if (WriteLock(this.last) == -1) { CfOut(cf_error,"creat","Unable to create %s\n",this.last); free(this.last); free(this.lock); free(this.log); return; } LogLockCompletion(this.log,getpid(),"Lock removed normally ",this.lock,""); free(this.last); free(this.lock); free(this.log); } /************************************************************************/ void GetLockName(char *lockname,char *locktype,char *base,struct Rlist *params) { struct Rlist *rp; int max_sample, count = 0; for (rp = params; rp != NULL; rp=rp->next) { count++; } if (count) { max_sample = CF_BUFSIZE / (2*count); } else { max_sample = 0; } strncpy(lockname,locktype,CF_BUFSIZE/10); strcat(lockname,"_"); strncat(lockname,base,CF_BUFSIZE/10); strcat(lockname,"_"); for (rp = params; rp != NULL; rp=rp->next) { strncat(lockname,(char *)rp->item,max_sample); } } /************************************************************************/ #if defined HAVE_PTHREAD_H && (defined HAVE_LIBPTHREAD || defined BUILDTIN_GCC_THREAD) static pthread_mutex_t *NameToThreadMutex(enum cf_thread_mutex name) { switch(name) { case cft_system: return &MUTEX_SYSCALL; break; case cft_count: return &MUTEX_COUNT; break; case cft_getaddr: return &MUTEX_GETADDR; break; case cft_lock: return &MUTEX_LOCK; break; case cft_output: return &MUTEX_OUTPUT; break; case cft_dbhandle: return &MUTEX_DBHANDLE; break; case cft_policy: return &MUTEX_POLICY; break; case cft_db_lastseen: return &MUTEX_DB_LASTSEEN; break; case cft_report: return &MUTEX_DB_REPORT; break; case cft_vscope: return &MUTEX_VSCOPE; break; case cft_server_keyseen: return &MUTEX_SERVER_KEYSEEN; break; case cft_server_children: return &MUTEX_SERVER_CHILDREN; break; default: CfOut(cf_error, "", "!! NameToThreadMutex supplied with unknown mutex name: %d", name); FatalError("Internal software error\n"); break; } return NULL; } #endif /************************************************************************/ int ThreadLock(enum cf_thread_mutex name) { #if defined HAVE_PTHREAD_H && (defined HAVE_LIBPTHREAD || defined BUILDTIN_GCC_THREAD) pthread_mutex_t *mutex; mutex = NameToThreadMutex(name); if (pthread_mutex_lock(mutex) != 0) { // Don't use CfOut here as it also requires locking printf("!! Could not lock: %d", name); return false; } return true; #else // NOT_HAVE_PTHREAD return true; #endif } /************************************************************************/ int ThreadUnlock(enum cf_thread_mutex name) { #if defined HAVE_PTHREAD_H && (defined HAVE_LIBPTHREAD || defined BUILDTIN_GCC_THREAD) pthread_mutex_t *mutex; mutex = NameToThreadMutex(name); if (pthread_mutex_unlock(mutex) != 0) { // Don't use CfOut here as it also requires locking printf("pthread_mutex_unlock: pthread_mutex_unlock failed"); return false; } return true; #else // NOT_HAVE_PTHREAD return true; #endif } /*****************************************************************************/ void AssertThreadLocked(enum cf_thread_mutex name, char *fname) /* Verifies that a given lock is taken (not neccessary by the current thread) */ { #if defined HAVE_PTHREAD_H && (defined HAVE_LIBPTHREAD || defined BUILDTIN_GCC_THREAD) pthread_mutex_t *mutex; int status; mutex = NameToThreadMutex(name); status = pthread_mutex_trylock(mutex); if (status != EBUSY && status != EDEADLK) { CfOut(cf_error, "", "!! The mutex %d was not locked in %s() -- status=%d", name, fname, status); FatalError("Software assertion failure\n"); } #endif } /*****************************************************************************/ /* Level */ /*****************************************************************************/ static time_t FindLock(char *last) { time_t mtime; if ((mtime = FindLockTime(last)) == -1) { /* Do this to prevent deadlock loops from surviving if IfElapsed > T_sched */ if (WriteLock(last) == -1) { CfOut(cf_error,"","Unable to lock %s\n",last); return 0; } return 0; } else { return mtime; } } /************************************************************************/ static int WriteLock(char *name) { CF_DB *dbp; struct LockData entry; Debug("WriteLock(%s)\n",name); ThreadLock(cft_lock); if ((dbp = OpenLock()) == NULL) { ThreadUnlock(cft_lock); return -1; } entry.pid = getpid(); entry.time = time((time_t *)NULL); WriteDB(dbp,name,&entry,sizeof(entry)); CloseLock(dbp); ThreadUnlock(cft_lock); return 0; } /*****************************************************************************/ static void LogLockCompletion(char *cflog,int pid,char *str,char *operator,char *operand) { FILE *fp; char buffer[CF_MAXVARSIZE]; struct stat statbuf; time_t tim; Debug("LockLogCompletion(%s)\n",str); if (cflog == NULL) { return; } if ((fp = fopen(cflog,"a")) == NULL) { CfOut(cf_error,"fopen","Can't open lock-log file %s\n",cflog); exit(1); } if ((tim = time((time_t *)NULL)) == -1) { Debug("Cfengine: couldn't read system clock\n"); } sprintf(buffer,"%s",cf_ctime(&tim)); Chop(buffer); fprintf(fp,"%s:%s:pid=%d:%s:%s\n",buffer,str,pid,operator,operand); fclose(fp); if (cfstat(cflog,&statbuf) != -1) { if (statbuf.st_size > CFLOGSIZE) { CfOut(cf_verbose,"","Rotating lock-runlog file\n"); RotateFiles(cflog,2); } } } /*****************************************************************************/ int RemoveLock(char *name) { CF_DB *dbp; if ((dbp = OpenLock()) == NULL) { return -1; } ThreadLock(cft_lock); DeleteDB(dbp,name); ThreadUnlock(cft_lock); CloseLock(dbp); return 0; } /************************************************************************/ static time_t FindLockTime(char *name) { CF_DB *dbp; struct LockData entry; Debug("FindLockTime(%s)\n",name); if ((dbp = OpenLock()) == NULL) { return -1; } if (ReadDB(dbp,name,&entry,sizeof(entry))) { CloseLock(dbp); return entry.time; } else { CloseLock(dbp); return -1; } } /************************************************************************/ static pid_t FindLockPid(char *name) { CF_DB *dbp; struct LockData entry; if ((dbp = OpenLock()) == NULL) { return -1; } if (ReadDB(dbp,name,&entry,sizeof(entry))) { CloseLock(dbp); return entry.pid; } else { CloseLock(dbp); return -1; } } /************************************************************************/ static CF_DB *OpenLock() { char name[CF_BUFSIZE]; CF_DB *dbp; snprintf(name,CF_BUFSIZE,"%s/state/%s",CFWORKDIR, CF_LOCKDB_FILE); MapName(name); if (!OpenDB(name,&dbp)) { return NULL; } Debug("OpenLock(%s)\n",name); return dbp; } /************************************************************************/ static void CloseLock(CF_DB *dbp) { if (dbp) { CloseDB(dbp); } } /*****************************************************************************/ static void RemoveDates(char *s) { int i,a = 0,b = 0,c = 0,d = 0; char *dayp = NULL, *monthp = NULL, *sp; char *days[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; char *months[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; // Canonifies or blanks our times/dates for locks where there would be an explosion of state if (strlen(s) < strlen("Fri Oct 1 15:15:23 EST 2010")) { // Probably not a full date return; } for (i = 0; i < 7; i++) { if ((dayp = strstr(s,days[i]))) { *dayp = 'D'; *(dayp+1) = 'A'; *(dayp+2) = 'Y'; break; } } for (i = 0; i < 12; i++) { if ((monthp = strstr(s,months[i]))) { *monthp = 'M'; *(monthp+1) = 'O'; *(monthp+2) = 'N'; break; } } if (dayp && monthp) // looks like a full date { sscanf(monthp+4,"%d %d:%d:%d",&a,&b,&c,&d); if (a*b*c*d == 0) { // Probably not a date return; } for (sp = monthp+4; *sp != '\0'; sp++) { if (sp > monthp+15) { break; } if (isdigit(*sp)) { *sp = 't'; } } } } /************************************************************************/ void PurgeLocks() { CF_DB *dbp = OpenLock(); CF_DBC *dbcp; char *key; int ksize,vsize; struct LockData entry; time_t now = time(NULL); memset(&entry, 0, sizeof(entry)); if (ReadDB(dbp,"lock_horizon",&entry,sizeof(entry))) { if (now - entry.time < CF_MONTH) { CfOut(cf_verbose,""," -> No lock purging scheduled"); CloseLock(dbp); return; } } CfOut(cf_verbose,""," -> Looking for stale locks to purge"); if (!NewDBCursor(dbp,&dbcp)) { CloseLock(dbp); return; } while(NextDB(dbp,dbcp,&key,&ksize,(void *)&entry,&vsize)) { if (strncmp(key,"last.internal_bundle.track_license.handle", strlen("last.internal_bundle.track_license.handle")) == 0) { continue; } if (now - entry.time > (time_t)CF_LOCKHORIZON) { CfOut(cf_verbose,""," --> Purging lock (%d) %s",now-entry.time,key); DeleteDB(dbp,key); } } entry.time = now; WriteDB(dbp,"lock_horizon",&entry,sizeof(entry)); DeleteDBCursor(dbp,dbcp); CloseLock(dbp); } /************************************************************************/ /* Release critical section */ /************************************************************************/ static void WaitForCriticalSection() { time_t now = time(NULL), then = FindLockTime("CF_CRITICAL_SECTION"); /* Another agent has been waiting more than a minute, it means there is likely crash detritus to clear up... After a minute we take our chances ... */ while ((then != -1) && (now - then < 60)) { sleep(1); then = FindLockTime("CF_CRITICAL_SECTION"); } WriteLock("CF_CRITICAL_SECTION"); } /************************************************************************/ static void ReleaseCriticalSection() { RemoveLock("CF_CRITICAL_SECTION"); } /************************************************************************/ int ShiftChange(void) { if (IsDefinedClass("(Hr00|Hr06|Hr12|Hr16|Hr18).Min00_05")) { return true; } else { return false; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/cf.defs.h������������������������������������������������������������������������0000644�0001750�0001750�00000103550�11715232734�012500� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*******************************************************************/ /* */ /* HEAER for cfengine */ /* */ /*******************************************************************/ #ifndef CFENGINE_CF_DEFS_H #define CFENGINE_CF_DEFS_H /* Hard link this file between cf2/cf3 for consistent update */ #include "conf.h" #ifdef NT # define MAX_FILENAME 227 # define WINVER 0x501 # define FD_SETSIZE 512 // increase select(2) FD limit from 64 #else # define MAX_FILENAME 254 #endif #ifdef MINGW # include <winsock2.h> # include <windows.h> # include <accctrl.h> # include <aclapi.h> # include <psapi.h> # include <wchar.h> # include <sddl.h> # include <tlhelp32.h> # include <iphlpapi.h> # include <ws2tcpip.h> # include <objbase.h> // for disphelper #endif #include <stdio.h> #include <math.h> #ifndef _GETOPT_H #include "../pub/getopt.h" #endif #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif #include <strings.h> #include <string.h> #include <ctype.h> #include <limits.h> #ifdef HAVE_UNAME #include <sys/utsname.h> #else #define _SYS_NMLN 257 struct utsname { char sysname[_SYS_NMLN]; char nodename[_SYS_NMLN]; char release[_SYS_NMLN]; char version[_SYS_NMLN]; char machine[_SYS_NMLN]; }; #endif #include <sys/types.h> #include <sys/stat.h> #ifdef HAVE_STDINT_H # include <stdint.h> #endif #ifdef HAVE_SYS_SYSTEMINFO_H # include <sys/systeminfo.h> #endif #ifdef HAVE_SYS_PARAM_H # include <sys/param.h> #endif #ifdef HAVE_SYS_MOUNT_H #include <sys/mount.h> #endif #ifdef HAVE_SYS_WAIT_H # include <sys/wait.h> #endif #ifndef WEXITSTATUS # define WEXITSTATUS(s) ((unsigned)(s) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(s) (((s) & 255) == 0) #endif #ifndef WIFSIGNALED # define WIFSIGNALED(s) ((s) & 0) /* Can't use for BSD */ #endif #ifndef WTERMSIG #define WTERMSIG(s) ((s) & 0) #endif #include "bool.h" #include "compiler.h" #include <openssl/err.h> #include <openssl/pem.h> #include <openssl/evp.h> #include <openssl/rsa.h> #include <openssl/rand.h> #include <openssl/bn.h> #include <errno.h> #ifdef HAVE_DIRENT_H # include <dirent.h> #else # define dirent direct # if HAVE_SYS_NDIR_H # include <sys/ndir.h> # endif # if HAVE_SYS_DIR_H # include <sys/dir.h> # endif # if HAVE_NDIR_H # include <ndir.h> # endif #endif #include <signal.h> #ifdef MINGW #define LOG_LOCAL0 (16<<3) #define LOG_LOCAL1 (17<<3) #define LOG_LOCAL2 (18<<3) #define LOG_LOCAL3 (19<<3) #define LOG_LOCAL4 (20<<3) #define LOG_LOCAL5 (21<<3) #define LOG_LOCAL6 (22<<3) #define LOG_LOCAL7 (23<<3) #define LOG_USER (1<<3) #define LOG_DAEMON (3<<3) #else /* NOT MINGW */ #include <syslog.h> extern int errno; #endif /* Do this for ease of configuration from the Makefile */ #ifdef HPuUX #define HPUX #endif #ifdef SunOS #define SUN4 #endif /* end of patch */ #ifdef AIX #ifndef ps2 #include <sys/statfs.h> #endif #include <sys/systemcfg.h> #endif #ifdef SOLARIS #include <sys/statvfs.h> #undef nfstype #endif #ifndef HAVE_BCOPY #define bcopy(fr,to,n) memcpy(to,fr,n) /* Eliminate ucblib */ #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) #define bzero(s, n) memset ((s), 0, (n)) #endif #if !HAVE_DECL_STRNDUP char *strndup(const char *s, size_t n); #endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif #if !HAVE_DECL_STRLCPY size_t strlcpy(char *destination, const char *source, size_t size); #endif #if !HAVE_DECL_STRLCAT size_t strlcat(char *destination, const char *source, size_t size); #endif #ifdef DARWIN #include <sys/malloc.h> #include <sys/paths.h> #endif #ifdef HAVE_SYS_MALLOC_H #ifdef DARWIN #include <sys/malloc.h> #include <sys/paths.h> #endif #else #ifdef HAVE_MALLOC_H #ifndef OPENBSD #ifdef __FreeBSD__ #include <stdlib.h> #else #include <malloc.h> #endif #endif #endif #endif #include <fcntl.h> #ifdef HAVE_VFS_H # include <sys/vfs.h> #endif #ifdef HPUX # include <sys/dirent.h> #endif #ifdef HAVE_UTIME_H # include <utime.h> /* use utime not utimes for portability */ #elif TIME_WITH_SYS_TIME # include <sys/time.h> # include <time.h> #elif HAVE_SYS_TIME_H # include <sys/time.h> #elif ! defined(AOS) # include <time.h> #endif #define _GNU_SOURCE #ifdef HAVE_TIME_H # include <time.h> #endif #ifdef HAVE_SYS_TIME_H # include <sys/time.h> #endif #ifndef MINGW #include <pwd.h> #include <grp.h> #endif #ifdef HAVE_SYS_SOCKIO_H # include <sys/sockio.h> #endif #ifndef MINGW # include <sys/socket.h> # include <sys/ioctl.h> # include <net/if.h> # include <netinet/in.h> # ifndef AOS # include <arpa/inet.h> # endif # include <netdb.h> # if !defined LINUX && !defined NT # include <sys/protosw.h> # undef sgi # include <net/route.h> # endif #endif #ifdef LINUX #ifdef __GLIBC__ # include <net/route.h> # include <netinet/in.h> #else # include <linux/route.h> # include <linux/in.h> #endif #endif #ifndef HAVE_SNPRINTF #include "../pub/snprintf.h" #endif #ifndef CLOCK_REALTIME #define CLOCK_REALTIME 1 #endif #ifndef HAVE_CLOCKID_T typedef int clockid_t; #endif #ifdef HAVE_PTHREAD_H # define __USE_GNU 1 # include <pthread.h> # ifndef _SC_THREAD_STACK_MIN # define _SC_THREAD_STACK_MIN PTHREAD_STACK_MIN # endif #endif #ifdef HAVE_SCHED_H # include <sched.h> #endif #ifdef WITH_SELINUX # include <selinux/selinux.h> #endif #ifndef MIN # define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif #ifndef MAX # define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif #ifndef INADDR_NONE #define INADDR_NONE ((unsigned long int) 0xffffffff) #endif #ifndef HAVE_SETEGID int setegid (gid_t gid); #endif #ifndef HAVE_DRAND48 double drand48(void); void srand48(long seed); #endif #if !HAVE_DECL_CLOCK_GETTIME int clock_gettime(clockid_t clock_id,struct timespec *tp); #endif #ifdef MINGW unsigned int alarm(unsigned int seconds); #endif #if !HAVE_DECL_REALPATH char *realpath(const char *path, char *resolved_path); #endif #ifndef HAVE_GETNETGRENT int setnetgrent (const char *netgroup); int getnetgrent (char **host, char **user, char **domain); void endnetgrent (void); #endif #ifndef HAVE_UNAME int uname (struct utsname *name); #endif #ifndef HAVE_STRSTR char *strstr (char *s1,char *s2); #endif #if !HAVE_DECL_STRDUP char *strdup (const char *str); #endif #ifndef HAVE_STRRCHR char *strrchr (char *str,char ch); #endif #ifndef HAVE_STRERROR char *strerror (int err); #endif #ifndef HAVE_STRSEP char *strsep(char **stringp, const char *delim); #endif #ifndef HAVE_PUTENV int putenv (char *s); #endif #if !HAVE_DECL_UNSETENV int unsetenv(const char *name); #endif #ifndef HAVE_SETEUID int seteuid (uid_t euid); #endif #ifndef HAVE_SETEUID int setegid (gid_t egid); #endif #if !HAVE_DECL_SETLINEBUF void setlinebuf(FILE *stream); #endif #ifdef MINGW const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt); int inet_pton(int af, const char *src, void *dst); #endif /*******************************************************************/ /* Preprocessor tricks */ /*******************************************************************/ /* Convert integer constant to string */ #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) /*******************************************************************/ /* Various defines */ /*******************************************************************/ #define CF_BUFSIZE 4096 /* max size of plaintext in one transaction, see net.c:SendTransaction(), leave space for encryption padding (assuming max 64*8 = 512-bit cipher block size)*/ #define CF_MAXTRANSSIZE (CF_BUFSIZE - CF_INBAND_OFFSET - 64) #define CF_BILLION 1000000000L #define CF_EXPANDSIZE (2*CF_BUFSIZE) #define CF_ALLCLASSSIZE (4*CF_BUFSIZE) #define CF_BUFFERMARGIN 32 #define CF_BLOWFISHSIZE 16 #define CF_SMALLBUF 128 #define CF_MAXVARSIZE 1024 #define CF_MAXSIDSIZE 2048 /* Windows only: Max size (bytes) of security identifiers */ #define CF_NONCELEN (CF_BUFSIZE/16) #define CF_MAXLINKSIZE 256 #define CF_MAXLINKLEVEL 4 #define CF_MAXFARGS 8 #define CF_MAX_IP_LEN 64 /* numerical ip length */ #define CF_PROCCOLS 16 //#define CF_HASHTABLESIZE 7919 /* prime number */ #define CF_HASHTABLESIZE 8192 #define CF_MACROALPHABET 61 /* a-z, A-Z plus a bit */ #define CF_ALPHABETSIZE 256 #define CF_MAXSHELLARGS 64 #define CF_MAX_SCLICODES 16 #define CF_SAMEMODE 7777 #define CF_SAME_OWNER ((uid_t)-1) #define CF_UNKNOWN_OWNER ((uid_t)-2) #define CF_SAME_GROUP ((gid_t)-1) #define CF_UNKNOWN_GROUP ((gid_t)-2) #define CF_NOSIZE -1 #define CF_EXTRASPC 8 /* pads items during AppendItem for eol handling in editfiles */ #define CF_INFINITY ((int)999999999) #define CF_NOT_CONNECTED -1 #define CF_COULD_NOT_CONNECT -2 #define CF_RECURSION_LIMIT 100 #define CF_MONDAY_MORNING 345600 #define CF_NOVAL -0.7259285297502359 #define CF_UNUSED_CHAR (char)127 #define SECONDS_PER_MINUTE 60 #define SECONDS_PER_HOUR (60 * SECONDS_PER_MINUTE) #define SECONDS_PER_DAY (24 * SECONDS_PER_HOUR) #define SECONDS_PER_WEEK (7 * SECONDS_PER_DAY) /* Long-term monitoring constants */ #define HOURS_PER_SHIFT 6 #define SECONDS_PER_SHIFT (HOURS_PER_SHIFT * SECONDS_PER_HOUR) #define SHIFTS_PER_DAY 4 #define SHIFTS_PER_WEEK (4*7) #define CF_INDEX_FIELD_LEN 7 #define CF_INDEX_OFFSET CF_INDEX_FIELD_LEN+1 #define CF_IFREQ 2048 /* Reportedly the largest size that does not segfault 32/64 bit*/ #define CF_ADDRSIZE 128 #define CF_METHODEXEC 0 #define CF_METHODREPLY 1 /* these should be >0 to prevent contention */ #define CF_EXEC_IFELAPSED 0 #define CF_EDIT_IFELAPSED 3 /* NOTE: If doing copy template then edit working copy, the edit ifelapsed must not be higher than the copy ifelapsed. This will make the working copy equal to the copied template file - not the copied + edited file. */ #define CF_EXEC_EXPIREAFTER 1 #define MAXIP4CHARLEN 16 #define PACK_UPIFELAPSED_SALT "packageuplist" /*******************************************************************/ /* DBM */ /*******************************************************************/ // maximum amount of simultanious open DBs #define MAX_OPENDB 30 #ifdef TCDB # include <tcutil.h> # include <tchdb.h> typedef struct { TCHDB *hdb; char *valmemp; // allocated on demand, freed on db close } CF_TCDB; typedef struct { char *curkey; char *curval; } CF_TCDBC; # define CF_DB CF_TCDB # define CF_DBC CF_TCDBC # define DB_FEXT "tcdb" #elif defined(QDB) # include <depot.h> typedef struct { DEPOT *depot; char *valmemp; // allocated on demand, freed on db close } CF_QDB; typedef struct { char *curkey; char *curval; } CF_QDBC; # define CF_DB CF_QDB # define CF_DBC CF_QDBC # define DB_FEXT "qdbm" #elif defined(SQLITE3) #include <sqlite3.h> typedef sqlite3 CF_DB; typedef sqlite3_stmt CF_DBC; #define DB_FEXT "sqlite3" #else /* Berkeley DB */ # ifdef SOLARIS # ifndef u_int32_t # define u_int32_t uint32_t # define u_int16_t uint16_t # define u_int8_t uint8_t # endif # endif # include <db.h> # define CF_DB DB # define CF_DBC DBC # define DB_FEXT "db" # define BDB 1 #endif /*******************************************************************/ /* Windows */ /*******************************************************************/ #ifdef MINGW # define MAXHOSTNAMELEN 256 // always adequate: http://msdn.microsoft.com/en-us/library/ms738527(VS.85).aspx # define NULLFILE "nul" # define EXEC_SUFFIX ".exe" typedef u_long in_addr_t; // as seen in in_addr struct in winsock.h #ifndef VER_SUITE_WH_SERVER // shold be in winnt.h, but is not in current mingw-version # define VER_SUITE_WH_SERVER 0x00008000 #endif /* Dummy signals, can be set to anything below 23 but * 2, 4, 8, 11, 15, 21, 22 which are taken. * Calling signal() with anything from below causes SIG_ERR * to be returned. */ # define SIGALRM 1 # define SIGHUP 3 # define SIGTRAP 5 # define SIGKILL 6 # define SIGPIPE 7 # define SIGCONT 9 # define SIGSTOP 10 # define SIGQUIT 12 # define SIGCHLD 13 # define SIGUSR1 14 # define SIGUSR2 16 # define SIGBUS 17 # if !defined( _TIMESPEC_DEFINED) && !defined(HAVE_STRUCT_TIMESPEC) # define HAVE_STRUCT_TIMESPEC 1 struct timespec { long tv_sec; long tv_nsec; }; # endif /* NOT _TIMESPEC_DEFINED */ #else /* NOT MINGW */ # define NULLFILE "/dev/null" # define EXEC_SUFFIX "" #endif /* NOT MINGW */ /*******************************************************************/ /* Class array limits */ /* This is the only place you ever need to edit anything */ /*******************************************************************/ #define CF_CLASSATTR 38 /* increase this for each new class added */ /* It defines the array size for class data */ #define CF_ATTRDIM 3 /* Only used in CLASSATTRUBUTES[][] defn */ /* end class array limits */ /*******************************************************************/ /* database file names */ #define CF_CLASSUSAGE "cf_classes" "." DB_FEXT #define CF_VARIABLES "cf_variables" "." DB_FEXT #define CF_PERFORMANCE "performance" "." DB_FEXT #define CF_CHKDB "checksum_digests" "." DB_FEXT #define CF_CHKPDB "stats" "." DB_FEXT #define CF_AVDB_FILE "cf_observations" "." DB_FEXT #define CF_STATEDB_FILE "cf_state" "." DB_FEXT #define CF_LASTDB_FILE "cf_lastseen" "." DB_FEXT #define CF_AUDITDB_FILE "cf_Audit" "." DB_FEXT #define CF_LOCKDB_FILE "cf_lock" "." DB_FEXT #define NOVA_HISTORYDB "history" "." DB_FEXT #define NOVA_MEASUREDB "nova_measures" "." DB_FEXT #define NOVA_STATICDB "nova_static" "." DB_FEXT #define NOVA_PSCALARDB "nova_pscalar" "." DB_FEXT #define NOVA_COMPLIANCE "promise_compliance" "." DB_FEXT #define NOVA_REGISTRY "mswin" "." DB_FEXT #define NOVA_CACHE "nova_cache" "." DB_FEXT #define NOVA_LICENSE "nova_track" "." DB_FEXT #define NOVA_VALUE "nova_value" "." DB_FEXT #define NOVA_NETWORK "nova_network" "." DB_FEXT #define NOVA_GLOBALCOUNTERS "nova_counters" "." DB_FEXT #define NOVA_BUNDLE_LOG "bundles" "." DB_FEXT /* end database file names */ /* database enums */ typedef enum { cfdb_classes, cfdb_variables, cfdb_performance, cfdb_cheksums_content, cfdb_cheksums_stats, cfdb_observations, cfdb_observations_year, cfdb_measurements, cfdb_state, cfdb_hostsseen, cfdb_audit, cfdb_locks, cfdb_static, cfdb_pscalar, cfdb_compliance, cfdb_winregistry, cfdb_cache, cfdb_license, cfdb_value, cfdb_network, cfdb_counters, cfdb_bundles }cfdb_t; /* end database enums */ #define CF_VALUE_LOG "cf_value.log" #define CF_FILECHANGE "file_change.log" #define CF_PROMISE_LOG "promise_summary.log" #define CF_STATELOG_FILE "state_log" #define CF_ENVNEW_FILE "env_data.new" #define CF_ENV_FILE "env_data" #define CF_TCPDUMP_COMM "/usr/sbin/tcpdump -t -n -v" #define CF_INPUTSVAR "CFINPUTS" /* default name for file path var */ #define CF_ALLCLASSESVAR "CFALLCLASSES" /* default name for CFALLCLASSES env */ #define CF_INF_RECURSE -99 /* code used to signify inf in recursion */ #define CF_TRUNCATE -1 #define CF_EMPTYFILE -2 #define CF_USELOGFILE true /* synonyms for tidy.c */ #define CF_NOLOGFILE false #define CF_SAVED ".cfsaved" #define CF_EDITED ".cfedited" #define CF_NEW ".cfnew" #define CFD_TERMINATOR "---cfXen/gine/cfXen/gine---" #define CFD_TRUE "CFD_TRUE" #define CFD_FALSE "CFD_FALSE" #define CF_ANYCLASS "any" #define CF_NOCLASS "XX_CF_opposite_any_XX" #define CF_NOUSER -99 #define CF_RSA_PROTO_OFFSET 24 #define CF_PROTO_OFFSET 16 #define CF_INBAND_OFFSET 8 #define CF_SMALL_OFFSET 2 /* digest sizes */ #define CF_MD5_LEN 16 #define CF_SHA_LEN 20 #define CF_SHA1_LEN 20 #define CF_BEST_LEN 0 #define CF_CRYPT_LEN 64 #define CF_SHA224_LEN 28 #define CF_SHA256_LEN 32 #define CF_SHA384_LEN 48 #define CF_SHA512_LEN 64 #define CF_DONE 't' #define CF_MORE 'm' #ifndef ERESTARTSYS # define ERESTARTSYS EINTR #endif #ifndef EOPNOTSUPP # define EOPNOTSUPP EINVAL #endif #ifndef ENOTSUPP # define ENOTSUPP EINVAL #endif #define CF_FAILEDSTR "BAD: Unspecified server refusal (see verbose server output)" #define CF_CHANGEDSTR1 "BAD: File changed " /* Split this so it cannot be recognized */ #define CF_CHANGEDSTR2 "while copying" #define CF_START_DOMAIN "undefined.domain" #define CFLOGSIZE 1048576 /* Size of lock-log before rotation */ /* Output control defines */ #define Verbose if (VERBOSE || DEBUG || D2) printf #define Debug4 if (D4) printf #define Debug3 if (D3 || DEBUG || D2) printf #define Debug2 if (DEBUG || D2) printf #define Debug1 if (DEBUG || D1) printf #define Debug if (DEBUG || D1 || D2) printf #define DebugVoid if (false) printf /* GNU REGEX */ #define BYTEWIDTH 8 /*****************************************************************************/ /* Auditing key */ #define CF_NOP 'n' #define CF_CHG 'c' #define CF_WARN 'w' /* something wrong but nothing done */ #define CF_FAIL 'f' #define CF_DENIED 'd' #define CF_TIMEX 't' #define CF_INTERPT 'i' #define CF_REGULAR 'r' #define CF_REPORT 'R' #define CF_UNKNOWN 'u' /*****************************************************************************/ #define CFGRACEPERIOD 4.0 /* training period in units of counters (weeks,iterations)*/ #define cf_noise_threshold 6 /* number that does not warrent large anomaly status */ #define MON_THRESHOLD_HIGH 1000000 // samples should stay below this threshold #define LDT_BUFSIZE 10 #define CF_GRAINS 64 #define ATTR 11 #define CF_NETATTR 7 /* icmp udp dns tcpsyn tcpfin tcpack */ #define PH_LIMIT 10 #define CF_MONTH (time_t)(3600*24*30) #define CF_WEEK (7.0*24.0*3600.0) #define CF_HOUR 3600 #define CF_DAY 3600*24 #define CF_RELIABLE_CLASSES 7*24 /* CF_WEEK/CF_HOUR */ #define CF_MEASURE_INTERVAL (5.0*60.0) #define CF_SHIFT_INTERVAL (6*3600.0) #define CF_OBSERVABLES 91 struct QPoint { double q; double expect; double var; }; struct Event { time_t t; struct QPoint Q; }; struct Averages { struct QPoint Q[CF_OBSERVABLES]; }; /******************************************************************/ struct LockData { pid_t pid; time_t time; }; /*****************************************************************************/ #define CF_AUDIT_COMMENT 128 #define CF_AUDIT_VERSION 64 #define CF_AUDIT_DATE 32 struct AuditLog /* key includes operation and date */ { char operator[CF_AUDIT_COMMENT]; char comment[CF_AUDIT_COMMENT]; char filename[CF_AUDIT_COMMENT]; char bundle[CF_AUDIT_VERSION]; /* not used in cf2 */ char version[CF_AUDIT_VERSION]; char date[CF_AUDIT_DATE]; short lineno; char status; }; /*******************************************************************/ /* Copy file defines */ /*******************************************************************/ /* Based heavily on cp.c in GNU-fileutils */ #ifndef DEV_BSIZE #ifdef BSIZE #define DEV_BSIZE BSIZE #else /* !BSIZE */ #define DEV_BSIZE 4096 #endif /* !BSIZE */ #endif /* !DEV_BSIZE */ /* Extract or fake data from a `struct stat'. ST_BLKSIZE: Optimal I/O blocksize for the file, in bytes. ST_NBLOCKS: Number of 512-byte blocks in the file (including indirect blocks). */ #define SMALL_BLOCK_BUF_SIZE 512 #ifndef HAVE_ST_BLOCKS # define ST_BLKSIZE(statbuf) DEV_BSIZE # if defined(_POSIX_SOURCE) || !defined(BSIZE) /* fileblocks.c uses BSIZE. */ # define ST_NBLOCKS(statbuf) (((statbuf).st_size + 512 - 1) / 512) # else /* !_POSIX_SOURCE && BSIZE */ # define ST_NBLOCKS(statbuf) (st_blocks ((statbuf).st_size)) # endif /* !_POSIX_SOURCE && BSIZE */ #else /* HAVE_ST_BLOCKS */ /* Some systems, like Sequents, return st_blksize of 0 on pipes. */ # define ST_BLKSIZE(statbuf) ((statbuf).st_blksize > 0 \ ? (statbuf).st_blksize : DEV_BSIZE) # if defined(hpux) || defined(__hpux__) || defined(__hpux) /* HP-UX counts st_blocks in 1024-byte units. This loses when mixing HP-UX and BSD filesystems with NFS. */ # define ST_NBLOCKS(statbuf) ((statbuf).st_blocks * 2) # else /* !hpux */ # if defined(_AIX) && defined(_I386) /* AIX PS/2 counts st_blocks in 4K units. */ # define ST_NBLOCKS(statbuf) ((statbuf).st_blocks * 8) # else /* not AIX PS/2 */ # define ST_NBLOCKS(statbuf) ((statbuf).st_blocks) # endif /* not AIX PS/2 */ # endif /* !hpux */ #endif /* HAVE_ST_BLOCKS */ #ifndef SEEK_CUR #define SEEK_CUR 1 #endif /*******************************************************************/ /* Client server defines */ /*******************************************************************/ #define CFENGINE_SERVICE "cfengine" enum PROTOS { cfd_exec, cfd_auth, cfd_get, cfd_opendir, cfd_synch, cfd_classes, cfd_md5, cfd_smd5, cfd_cauth, cfd_sauth, cfd_ssynch, cfd_sget, cfd_version, cfd_sopendir, cfd_var, cfd_svar, cfd_context, cfd_scontext, cfd_squery, cfd_bad }; #define CF_WORDSIZE 8 /* Number of bytes in a word */ /*******************************************************************/ enum cf_filetype { cf_reg, cf_link, cf_dir, cf_fifo, cf_block, cf_char, cf_sock }; /*******************************************************************/ enum roles { cf_connect, cf_accept }; /*******************************************************************/ struct cfstat { char *cf_filename; /* What file are we statting? */ char *cf_server; /* Which server did this come from? */ enum cf_filetype cf_type; /* enum filetype */ mode_t cf_lmode; /* Mode of link, if link */ mode_t cf_mode; /* Mode of remote file, not link */ uid_t cf_uid; /* User ID of the file's owner */ gid_t cf_gid; /* Group ID of the file's group */ off_t cf_size; /* File size in bytes */ time_t cf_atime; /* Time of last access */ time_t cf_mtime; /* Time of last data modification */ time_t cf_ctime; /* Time of last file status change */ char cf_makeholes; /* what we need to know from blksize and blks */ char *cf_readlink; /* link value or NULL */ int cf_failed; /* stat returned -1 */ int cf_nlink; /* Number of hard links */ int cf_ino; /* inode number on server */ dev_t cf_dev; /* device number */ struct cfstat *next; }; /*******************************************************************/ struct cfdir { /* Local directories */ void *dirh; /* DIR* or HANDLE */ struct dirent *entrybuf; /* Remote directories */ struct Item *list; struct Item *listpos; /* current pos */ }; typedef struct cfdir CFDIR; /*******************************************************************/ enum cfsizes { cfabs, cfpercent }; /*******************************************************************/ enum statepolicy { cfreset, /* Policy when trying to add already defined persistent states */ cfpreserve }; /*******************************************************************/ enum classes { empty, soft, sun4, ultrx, hp, aix, linuxx, solaris, osf, digital, sun3, irix4, irix, irix64, freebsd, solarisx86, bsd4_3, newsos, netbsd, aos, bsd_i, nextstep, crayos, GnU, cfnt, unix_sv, openbsd, cfsco, darwin, ux4800, qnx, dragonfly, mingw, vmware, unused1, unused2, unused3 }; /*******************************************************************/ enum fileactions { warnall, warnplain, warndirs, fixall, fixplain, fixdirs, touch, linkchildren, create, compress, alert }; /*******************************************************************/ enum SignalNames { cfnosignal, cfhup, cfint, cfquit, cfill, cftrap, cfiot, cfemt, cffpr, cfkill, cfbus, cfsegv, cfsys, cfpipe, cfalrm, cfterm }; #define highest_signal 64 /*******************************************************************/ enum modestate { wild, who, which }; enum modesort { unknown, numeric, symbolic }; /*******************************************************************/ enum cmpsense /* For package version comparison */ { cmpsense_eq, cmpsense_gt, cmpsense_lt, cmpsense_ge, cmpsense_le, cmpsense_ne, cmpsense_none }; /*******************************************************************/ enum pkgmgrs /* Available package managers to query in packages: */ { pkgmgr_rpm, pkgmgr_dpkg, pkgmgr_sun, pkgmgr_aix, pkgmgr_portage, pkgmgr_freebsd, pkgmgr_none }; /*******************************************************************/ enum pkgactions /* What to do with a package if it is found/not found */ { pkgaction_install, pkgaction_remove, pkgaction_upgrade, pkgaction_fix, pkgaction_none }; /*******************************************************************/ typedef char flag; enum socks { netbiosns, netbiosdgm, netbiosssn, irc, cfengine, nfsd, smtp, www, ftp, ssh, wwws }; enum iptypes { icmp, udp, dns, tcpsyn, tcpack, tcpfin, tcpmisc }; enum observables { ob_users, ob_rootprocs, ob_otherprocs, ob_diskfree, ob_loadavg, ob_netbiosns_in, ob_netbiosns_out, ob_netbiosdgm_in, ob_netbiosdgm_out, ob_netbiosssn_in, ob_netbiosssn_out, ob_irc_in, ob_irc_out, ob_cfengine_in, ob_cfengine_out, ob_nfsd_in, ob_nfsd_out, ob_smtp_in, ob_smtp_out, ob_www_in, ob_www_out, ob_ftp_in, ob_ftp_out, ob_ssh_in, ob_ssh_out, ob_wwws_in, ob_wwws_out, ob_icmp_in, ob_icmp_out, ob_udp_in, ob_udp_out, ob_dns_in, ob_dns_out, ob_tcpsyn_in, ob_tcpsyn_out, ob_tcpack_in, ob_tcpack_out, ob_tcpfin_in, ob_tcpfin_out, ob_tcpmisc_in, ob_tcpmisc_out, ob_webaccess, ob_weberrors, ob_syslog, ob_messages, ob_temp0, ob_temp1, ob_temp2, ob_temp3, ob_cpuall, ob_cpu0, ob_cpu1, ob_cpu2, ob_cpu3, ob_spare }; struct sock { char *portnr; char *name; enum observables in; enum observables out; }; /*******************************************************************/ struct cfagent_connection { int sd; int trust; /* true if key being accepted on trust */ int authenticated; int protoversion; int family; /* AF_INET or AF_INET6 */ char username[CF_SMALLBUF]; char localip[CF_MAX_IP_LEN]; char remoteip[CF_MAX_IP_LEN]; unsigned char digest[EVP_MAX_MD_SIZE+1]; unsigned char *session_key; char encryption_type; short error; }; /*******************************************************************/ struct CompressedArray { int key; char *value; struct CompressedArray *next; }; /*******************************************************************/ struct Audit { char *version; char *filename; char *date; unsigned char digest[EVP_MAX_MD_SIZE+1]; struct Audit *next; }; /*******************************************************************/ /* Action /promise types */ /*******************************************************************/ struct Item { char done; char *name; char *classes; int counter; time_t time; struct Item *next; }; /*******************************************************************/ struct AlphaList // Indexed itemlist { struct Item *list[256]; }; /*******************************************************************/ struct UidList { #ifdef MINGW // TODO: remove uid for NT ? char sid[CF_MAXSIDSIZE]; /* Invalid sid indicates unset */ #endif /* MINGW */ uid_t uid; char *uidname; /* when uid is -2 */ struct UidList *next; }; /*******************************************************************/ struct GidList { gid_t gid; char *gidname; /* when gid is -2 */ struct GidList *next; }; /*******************************************************************/ enum cffstype { posixfs, solarisfs, dfsfs, afsfs, hpuxfs, ntfs, badfs }; /*******************************************************************/ enum matchtypes { literalStart, literalComplete, literalSomewhere, regexComplete, NOTliteralStart, NOTliteralComplete, NOTliteralSomewhere, NOTregexComplete }; /*******************************************************************/ struct Auth { char *path; struct Item *accesslist; struct Item *maproot; /* which hosts should have root read access */ int encrypt; /* which files HAVE to be transmitted securely */ int literal; int classpattern; struct Auth *next; }; /*******************************************************************/ struct Strategy { char done; char *name; char *classes; char type; /* default r=random */ struct Item *strategies; struct Strategy *next; }; /*******************************************************************/ /* Checksum database structures */ /*******************************************************************/ struct Checksum_Value { unsigned char mess_digest[EVP_MAX_MD_SIZE+1]; /* Content digest */ unsigned char attr_digest[EVP_MAX_MD_SIZE+1]; /* Attribute digest */ }; /*******************************************************************/ /* Ultrix/BSD don't have all these from sys/stat.h */ /*******************************************************************/ # ifndef S_IFBLK # define S_IFBLK 0060000 # endif # ifndef S_IFCHR # define S_IFCHR 0020000 # endif # ifndef S_IFDIR # define S_IFDIR 0040000 # endif # ifndef S_IFIFO # define S_IFIFO 0010000 # endif # ifndef S_IFREG # define S_IFREG 0100000 # endif # ifndef S_IFLNK # define S_IFLNK 0120000 # endif # ifndef S_IFSOCK # define S_IFSOCK 0140000 # endif # ifndef S_IFMT # define S_IFMT 00170000 # endif #ifndef S_ISREG # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #endif #ifndef S_ISDIR # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #endif #ifndef S_ISLNK # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) #endif #ifndef S_ISFIFO # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) #endif #ifndef S_ISCHR # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) #endif #ifndef S_ISBLK # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) #endif #ifndef S_ISSOCK # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) #endif #ifndef S_IRUSR #define S_IRWXU 00700 #define S_IRUSR 00400 #define S_IWUSR 00200 #define S_IXUSR 00100 #define S_IRWXG 00070 #define S_IRGRP 00040 #define S_IWGRP 00020 #define S_IXGRP 00010 #define S_IRWXO 00007 #define S_IROTH 00004 #define S_IWOTH 00002 #define S_IXOTH 00001 #endif /********************************************************************/ /* *BSD chflags stuff - */ /********************************************************************/ # if !defined UF_NODUMP # define UF_NODUMP 0 # endif # if !defined UF_IMMUTABLE # define UF_IMMUTABLE 0 # endif # if !defined UF_APPEND # define UF_APPEND 0 # endif # if !defined UF_OPAQUE # define UF_OPAQUE 0 # endif # if !defined UF_NOUNLINK # define UF_NOUNLINK 0 # endif # if !defined SF_ARCHIVED # define SF_ARCHIVED 0 # endif # if !defined SF_IMMUTABLE # define SF_IMMUTABLE 0 # endif # if !defined SF_APPEND # define SF_APPEND 0 # endif # if !defined SF_NOUNLINK # define SF_NOUNLINK 0 # endif # define CHFLAGS_MASK ( UF_NODUMP | UF_IMMUTABLE | UF_APPEND | UF_OPAQUE | UF_NOUNLINK | SF_ARCHIVED | SF_IMMUTABLE | SF_APPEND | SF_NOUNLINK ) /* For cygwin32 */ #if !defined O_BINARY # define O_BINARY 0 #endif /*******************************************************************/ /* File path manipulation primitives */ /*******************************************************************/ /* Defined maximum length of a filename. */ /* File node separator (cygwin can use \ or / but prefer \ for communicating * with native windows commands). */ #ifdef NT # define IsFileSep(c) ((c) == '\\' || (c) == '/') #else # define IsFileSep(c) ((c) == '/') #endif /* Nobody already knows why it was needed in first place. Please test whether removing this variable is harmless on HP/UX nowadays. */ #ifdef HPuUX int Error; #endif #endif ��������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/files_operators.c����������������������������������������������������������������0000644�0001750�0001750�00000167766�11715232734�014406� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: files_operators.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" extern int CFA_MAXTHREADS; extern struct cfagent_connection *COMS; static void TruncateFile(char *name); static int VerifyFinderType(char *file,struct stat *statbuf,struct Attributes a,struct Promise *pp); static int TransformFile(char *file,struct Attributes attr,struct Promise *pp); static void VerifyName(char *path,struct stat *sb,struct Attributes attr,struct Promise *pp); static void VerifyDelete(char *path,struct stat *sb,struct Attributes attr,struct Promise *pp); static void DeleteDirectoryTree(char *path,struct Promise *pp); #ifndef MINGW static void VerifySetUidGid(char *file,struct stat *dstat,mode_t newperm,struct Promise *pp,struct Attributes attr); static int Unix_VerifyOwner(char *file,struct Promise *pp,struct Attributes attr,struct stat *sb); static void Unix_VerifyCopiedFileAttributes(char *file,struct stat *dstat,struct stat *sstat,struct Attributes attr,struct Promise *pp); static void Unix_VerifyFileAttributes(char *file,struct stat *dstat,struct Attributes attr,struct Promise *pp); #endif /*******************************************************************/ /* File API - OS function mapping */ /*******************************************************************/ void CreateEmptyFile(char *name) { #ifdef MINGW NovaWin_CreateEmptyFile(name); #else Unix_CreateEmptyFile(name); #endif } /*****************************************************************************/ int VerifyOwner(char *file,struct Promise *pp,struct Attributes attr,struct stat *sb) { #ifdef MINGW return NovaWin_VerifyOwner(file,pp,attr); #else return Unix_VerifyOwner(file,pp,attr,sb); #endif } /*****************************************************************************/ void VerifyFileAttributes(char *file,struct stat *dstat,struct Attributes attr,struct Promise *pp) { #ifdef MINGW NovaWin_VerifyFileAttributes(file,dstat,attr,pp); #else Unix_VerifyFileAttributes(file,dstat,attr,pp); #endif } /*****************************************************************************/ void VerifyCopiedFileAttributes(char *file,struct stat *dstat,struct stat *sstat,struct Attributes attr,struct Promise *pp) { #ifdef MINGW NovaWin_VerifyCopiedFileAttributes(file,dstat,attr,pp); #else Unix_VerifyCopiedFileAttributes(file,dstat,sstat,attr,pp); #endif } /*******************************************************************/ /* End file API */ /*******************************************************************/ int VerifyFileLeaf(char *path,struct stat *sb,struct Attributes attr,struct Promise *pp) { /* Here we can assume that we are in the parent directory of the leaf */ if (!SelectLeaf(path,sb,attr,pp)) { Debug("Skipping non-selected file %s\n",path); return false; } CfOut(cf_verbose,""," -> Handling file existence constraints on %s\n",path); /* We still need to augment the scope of context "this" for commands */ DeleteScalar("this","promiser"); NewScalar("this","promiser",path,cf_str); // Parameters may only be scalars if (attr.transformer != NULL) { if (!TransformFile(path,attr,pp)) { /* NOP? */ } } else { if (attr.haverename) { VerifyName(path,sb,attr,pp); } if (attr.havedelete) { VerifyDelete(path,sb,attr,pp); } if (attr.touch) { TouchFile(path,sb,attr,pp); // intrinsically non-convergent op } } if (attr.haveperms || attr.havechange || attr.acl.acl_entries) { if (S_ISDIR(sb->st_mode) && attr.recursion.depth && !attr.recursion.include_basedir && (strcmp(path,pp->promiser) == 0)) { CfOut(cf_verbose,""," -> Promise to skip base directory %s\n",path); } else { VerifyFileAttributes(path,sb,attr,pp); } } DeleteScalar("this","promiser"); return true; } /*****************************************************************************/ FILE *CreateEmptyStream() { FILE *fp; fp = fopen(NULLFILE, "r"); if(fp == NULL) { CfOut(cf_error, "", "!! Open of NULLFILE failed"); return NULL; } // get to EOF fgetc(fp); if(!feof(fp)) { CfOut(cf_error, "", "!! Could not create empty stream"); fclose(fp); return NULL; } return fp; } /*****************************************************************************/ int CfCreateFile(char *file,struct Promise *pp,struct Attributes attr) { int fd; /* If name ends in /. then this is a directory */ // attr.move_obstructions for MakeParentDirectory if (!IsAbsoluteFileName(file)) { cfPS(cf_inform,CF_FAIL,"creat",pp,attr," !! Cannot create a relative filename %s - has no invariant meaning\n",file); return false; } if (strcmp(".",ReadLastNode(file)) == 0) { Debug("File object \"%s \"seems to be a directory\n",file); if (!DONTDO && attr.transaction.action != cfa_warn) { if (!MakeParentDirectory(file,attr.move_obstructions)) { cfPS(cf_inform,CF_FAIL,"creat",pp,attr," !! Error creating directories for %s\n",file); return false; } cfPS(cf_inform,CF_CHG,"",pp,attr," -> Created directory %s\n",file); } else { CfOut(cf_error,""," !! Warning promised, need to create directory %s",file); return false; } } else { if (!DONTDO && attr.transaction.action != cfa_warn) { mode_t saveumask = umask(0); mode_t filemode = 0600; /* Decide the mode for filecreation */ if (GetConstraint("mode",pp,CF_SCALAR) == NULL) { /* Relying on umask is risky */ filemode = 0600; CfOut(cf_verbose,""," -> No mode was set, choose plain file default %o\n",filemode); } else { filemode = attr.perms.plus & ~(attr.perms.minus); } MakeParentDirectory(file,attr.move_obstructions); if ((fd = creat(file,filemode)) == -1) { cfPS(cf_inform,CF_FAIL,"creat",pp,attr," !! Error creating file %s, mode = %o\n",file,filemode); umask(saveumask); return false; } else { cfPS(cf_inform,CF_CHG,"",pp,attr," -> Created file %s, mode = %o\n",file,filemode); close(fd); umask(saveumask); } } else { CfOut(cf_error,""," !! Warning promised, need to create file %s\n",file); return false; } } return true; } /*****************************************************************************/ int ScheduleCopyOperation(char *destination,struct Attributes attr,struct Promise *pp) { struct cfagent_connection *conn; CfOut(cf_verbose,""," -> Copy file %s from %s check\n",destination,attr.copy.source); if (attr.copy.servers == NULL || strcmp(attr.copy.servers->item,"localhost") == 0) { conn = NULL; pp->this_server = strdup("localhost"); } else { conn = NewServerConnection(attr,pp); if (conn == NULL) { cfPS(cf_inform,CF_FAIL,"",pp,attr," -> No suitable server responded to hail\n"); PromiseRef(cf_inform,pp); return false; } } pp->conn = conn; /* for ease of access */ pp->cache = NULL; CopyFileSources(destination,attr,pp); return true; } /*****************************************************************************/ int ScheduleLinkChildrenOperation(char *destination,char *source,int recurse,struct Attributes attr,struct Promise *pp) { CFDIR *dirh; const struct dirent *dirp; char promiserpath[CF_BUFSIZE],sourcepath[CF_BUFSIZE]; struct stat lsb; int ret; if ((ret = lstat(destination,&lsb)) != -1) { if (attr.move_obstructions && S_ISLNK(lsb.st_mode)) { unlink(destination); } else if (!S_ISDIR(lsb.st_mode)) { CfOut(cf_error,"","Cannot promise to link multiple files to children of %s as it is not a directory!",destination); return false; } } snprintf(promiserpath,CF_BUFSIZE,"%s/.",destination); if ((ret == -1 || !S_ISDIR(lsb.st_mode)) && !CfCreateFile(promiserpath,pp,attr)) { CfOut(cf_error,"","Cannot promise to link multiple files to children of %s as it is not a directory!",destination); return false; } if ((dirh = OpenDirLocal(source)) == NULL) { cfPS(cf_error,CF_FAIL,"opendir",pp,attr,"Can't open source of children to link %s\n",attr.link.source); return false; } for (dirp = ReadDir(dirh); dirp != NULL; dirp = ReadDir(dirh)) { if (!ConsiderFile(dirp->d_name,source,attr,pp)) { continue; } /* Assemble pathnames */ strncpy(promiserpath,destination,CF_BUFSIZE-1); AddSlash(promiserpath); if (!JoinPath(promiserpath,dirp->d_name)) { cfPS(cf_error,CF_INTERPT,"",pp,attr,"Can't construct filename which verifying child links\n"); CloseDir(dirh); return false; } strncpy(sourcepath,source,CF_BUFSIZE-1); AddSlash(sourcepath); if (!JoinPath(sourcepath,dirp->d_name)) { cfPS(cf_error,CF_INTERPT,"",pp,attr,"Can't construct filename while verifying child links\n"); CloseDir(dirh); return false; } if ((lstat(promiserpath,&lsb) != -1) && !S_ISLNK(lsb.st_mode) && !S_ISDIR(lsb.st_mode)) { if (attr.link.when_linking_children == cfa_override) { attr.move_obstructions = true; } else { CfOut(cf_verbose,"","Have promised not to disturb %s\'s existing content",promiserpath); continue; } } if ((attr.recursion.depth > recurse) && (lstat(sourcepath,&lsb) != -1) && S_ISDIR(lsb.st_mode)) { ScheduleLinkChildrenOperation(promiserpath,sourcepath,recurse+1,attr,pp); } else { ScheduleLinkOperation(promiserpath,sourcepath,attr,pp); } } CloseDir(dirh); return true; } /*****************************************************************************/ int ScheduleLinkOperation(char *destination,char *source,struct Attributes attr,struct Promise *pp) { const char *lastnode; lastnode = ReadLastNode(destination); if (MatchRlistItem(attr.link.copy_patterns,lastnode)) { CfOut(cf_verbose,""," -> Link %s matches copy_patterns\n",destination); VerifyCopy(attr.link.source,destination,attr,pp); return true; } switch (attr.link.link_type) { case cfa_symlink: VerifyLink(destination,source,attr,pp); break; case cfa_hardlink: VerifyHardLink(destination,source,attr,pp); break; case cfa_relative: VerifyRelativeLink(destination,source,attr,pp); break; case cfa_absolute: VerifyAbsoluteLink(destination,source,attr,pp); break; default: CfOut(cf_error,"","Unknown link type - should not happen.\n"); break; } return true; } /*****************************************************************************/ int ScheduleEditOperation(char *filename,struct Attributes a,struct Promise *pp) { struct Bundle *bp; void *vp; struct FnCall *fp; char *edit_bundle_name = NULL,lockname[CF_BUFSIZE]; struct Rlist *params; int retval = false; struct CfLock thislock; snprintf(lockname,CF_BUFSIZE-1,"fileedit-%s",pp->promiser); thislock = AcquireLock(lockname,VUQNAME,CFSTARTTIME,a,pp,false); if (thislock.lock == NULL) { return false; } pp->edcontext = NewEditContext(filename,a,pp); if (pp->edcontext == NULL) { cfPS(cf_error,CF_FAIL,"",pp,a,"File %s was marked for editing but could not be opened\n",filename); FinishEditContext(pp->edcontext,a,pp); YieldCurrentLock(thislock); return false; } if (a.haveeditline) { if ((vp = GetConstraint("edit_line",pp,CF_FNCALL))) { fp = (struct FnCall *)vp; edit_bundle_name = fp->name; params = fp->args; } else if ((vp = GetConstraint("edit_line",pp,CF_SCALAR))) { edit_bundle_name = (char *)vp; params = NULL; } else { FinishEditContext(pp->edcontext,a,pp); YieldCurrentLock(thislock); return false; } CfOut(cf_verbose,""," -> Handling file edits in edit_line bundle %s\n",edit_bundle_name); // add current filename to context - already there? if ((bp = GetBundle(edit_bundle_name,"edit_line"))) { BannerSubBundle(bp,params); DeleteScope(bp->name); NewScope(bp->name); HashVariables(bp->name); AugmentScope(bp->name,bp->args,params); PushPrivateClassContext(); retval = ScheduleEditLineOperations(filename,bp,a,pp); PopPrivateClassContext(); DeleteScope(bp->name); } } FinishEditContext(pp->edcontext,a,pp); YieldCurrentLock(thislock); return retval; } /*****************************************************************************/ /* Level */ /*****************************************************************************/ /*****************************************************************************/ /* Level */ /*****************************************************************************/ int MoveObstruction(char *from,struct Attributes attr,struct Promise *pp) { struct stat sb; char stamp[CF_BUFSIZE],saved[CF_BUFSIZE]; time_t now_stamp = time((time_t *)NULL); if (lstat(from,&sb) == 0) { if (!attr.move_obstructions) { cfPS(cf_verbose,CF_FAIL,"",pp,attr," !! Object %s exists and is obstructing our promise\n",from); return false; } if (!S_ISDIR(sb.st_mode)) { if (DONTDO) { return false; } saved[0] = '\0'; strcpy(saved,from); if (attr.copy.backup == cfa_timestamp || attr.edits.backup == cfa_timestamp) { sprintf(stamp, "_%d_%s",CFSTARTTIME,CanonifyName(cf_ctime(&now_stamp))); strcat(saved,stamp); } strcat(saved,CF_SAVED); cfPS(cf_verbose,CF_CHG,"",pp,attr," -> Moving file object %s to %s\n",from,saved); if (cf_rename(from,saved) == -1) { cfPS(cf_error,CF_FAIL,"cf_rename",pp,attr," !! Can't rename %s to %s\n",from,saved); return false; } if (ArchiveToRepository(saved,attr,pp)) { unlink(saved); } return true; } if (S_ISDIR(sb.st_mode)) { cfPS(cf_verbose,CF_CHG,"",pp,attr," -> Moving directory %s to %s%s\n",from,from,CF_SAVED); if (DONTDO) { return false; } saved[0] = '\0'; strcpy(saved,from); sprintf(stamp, "_%d_%s", CFSTARTTIME, CanonifyName(cf_ctime(&now_stamp))); strcat(saved,stamp); strcat(saved,CF_SAVED); strcat(saved,".dir"); if (cfstat(saved,&sb) != -1) { cfPS(cf_error,CF_FAIL,"",pp,attr," !! Couldn't save directory %s, since %s exists already\n",from,saved); CfOut(cf_error,"","Unable to force link to existing directory %s\n",from); return false; } if (cf_rename(from,saved) == -1) { cfPS(cf_error,CF_FAIL,"cf_rename",pp,attr,"Can't rename %s to %s\n",from,saved); return false; } } } return true; } /*********************************************************************/ #ifdef DARWIN static int VerifyFinderType(char *file,struct stat *statbuf,struct Attributes a,struct Promise *pp) { /* Code modeled after hfstar's extract.c */ typedef struct t_fndrinfo { long fdType; long fdCreator; short fdFlags; short fdLocationV; short fdLocationH; short fdFldr; short fdIconID; short fdUnused[3]; char fdScript; char fdXFlags; short fdComment; long fdPutAway; } FInfo; struct attrlist attrs; struct { long ssize; struct timespec created; struct timespec modified; struct timespec changed; struct timespec backup; FInfo fi; } fndrInfo; int retval; if (a.perms.findertype == NULL) { return 0; } Debug("VerifyFinderType of %s for %s\n", file,a.perms.findertype); if (strncmp(a.perms.findertype,"*",CF_BUFSIZE) == 0 || strncmp(a.perms.findertype,"",CF_BUFSIZE) == 0) { return 0; } attrs.bitmapcount = ATTR_BIT_MAP_COUNT; attrs.reserved = 0; attrs.commonattr = ATTR_CMN_CRTIME | ATTR_CMN_MODTIME | ATTR_CMN_CHGTIME | ATTR_CMN_BKUPTIME | ATTR_CMN_FNDRINFO; attrs.volattr = 0; attrs.dirattr = 0; attrs.fileattr = 0; attrs.forkattr = 0; memset(&fndrInfo, 0, sizeof(fndrInfo)); getattrlist(file, &attrs, &fndrInfo, sizeof(fndrInfo),0); if (fndrInfo.fi.fdType != *(long *)a.perms.findertype) { fndrInfo.fi.fdType = *(long *)a.perms.findertype; switch (a.transaction.action) { case cfa_fix: if (DONTDO) { CfOut(cf_inform,"","Promised to set Finder Type code of %s to %s\n",file,a.perms.findertype); return 0; } /* setattrlist does not take back in the long ssize */ retval = setattrlist(file, &attrs, &fndrInfo.created, 4*sizeof(struct timespec) + sizeof(FInfo), 0); Debug("CheckFinderType setattrlist returned %d\n", retval); if (retval >= 0) { cfPS(cf_inform,CF_CHG,"",pp,a,"Setting Finder Type code of %s to %s\n",file,a.perms.findertype); } else { cfPS(cf_error,CF_FAIL,"",pp,a,"Setting Finder Type code of %s to %s failed!!\n",file,a.perms.findertype); } return retval; case cfa_warn: CfOut(cf_error,"","Darwin FinderType does not match -- not fixing.\n"); return 0; default: return 0; } } else { cfPS(cf_verbose,CF_NOP,"",pp,a,"Finder Type code of %s to %s is as promised\n",file,a.perms.findertype); return 0; } } #endif /*********************************************************************/ /* Level */ /*********************************************************************/ static void VerifyName(char *path,struct stat *sb,struct Attributes attr,struct Promise *pp) { mode_t newperm; struct stat dsb; if (lstat(path,&dsb) == -1) { cfPS(cf_inform,CF_NOP,"",pp,attr,"File object named %s is not there (promise kept)",path); return; } else { if (attr.rename.rotate == CF_NOINT) { CfOut(cf_inform,""," !! Warning - file object %s exists, contrary to promise\n",path); } } if (attr.rename.newname) { if (DONTDO) { CfOut(cf_inform,""," -> File %s should be renamed to %s to keep promise\n",path,attr.rename.newname); return; } else { if (!IsItemIn(VREPOSLIST,attr.rename.newname)) { if (cf_rename(path,attr.rename.newname) == -1) { cfPS(cf_error,CF_FAIL,"cf_rename",pp,attr," !! Error occurred while renaming %s\n",path); return; } else { cfPS(cf_inform,CF_CHG,"",pp,attr," -> Renaming file %s to %s\n",path,attr.rename.newname); } } else { cfPS(cf_error,CF_WARN,"",pp,attr," !! Rename to same destination twice? Would overwrite saved copy - aborting",path); } } return; } if (S_ISLNK(dsb.st_mode)) { if (attr.rename.disable) { if (!DONTDO) { if (unlink(path) == -1) { cfPS(cf_error,CF_FAIL,"unlink",pp,attr," !! Unable to unlink %s\n",path); } else { cfPS(cf_inform,CF_CHG,"",pp,attr," -> Disabling symbolic link %s by deleting it\n",path); } } else { CfOut(cf_inform,""," * Need to disable link %s to keep promise\n",path); } return; } } /* Normal disable - has priority */ if (attr.rename.disable) { char newname[CF_BUFSIZE]; if (attr.rename.newname && strlen(attr.rename.newname) > 0) { if (IsAbsPath(attr.rename.newname)) { strncpy(path,attr.rename.newname,CF_BUFSIZE-1); } else { strcpy(newname,path); ChopLastNode(newname); if (!JoinPath(newname,attr.rename.newname)) { return; } } } else { strcpy(newname,path); if (attr.rename.disable_suffix) { if (!JoinSuffix(newname,attr.rename.disable_suffix)) { return; } } else { if (!JoinSuffix(newname,".cfdisabled")) { return; } } } if ((attr.rename.plus != CF_SAMEMODE) && (attr.rename.minus != CF_SAMEMODE)) { newperm = (sb->st_mode & 07777); newperm |= attr.rename.plus; newperm &= ~(attr.rename.minus); } else { newperm = (mode_t)0600; } if (DONTDO) { CfOut(cf_inform,""," -> File %s should be renamed to %s to keep promise\n",path,newname); return; } else { cf_chmod(path,newperm); if (!IsItemIn(VREPOSLIST,newname)) { if (cf_rename(path,newname) == -1) { cfPS(cf_error,CF_FAIL,"cf_rename",pp,attr,"Error occurred while renaming %s\n",path); return; } else { cfPS(cf_inform,CF_CHG,"",pp,attr," -> Disabling/renaming file %s to %s with mode %o\n",path,newname,newperm); } if (ArchiveToRepository(newname,attr,pp)) { unlink(newname); } } else { cfPS(cf_error,CF_WARN,"",pp,attr," !! Disable required twice? Would overwrite saved copy - changing permissions only",path); } } return; } if (attr.rename.rotate == 0) { if (! DONTDO) { TruncateFile(path); cfPS(cf_inform,CF_CHG,"",pp,attr," -> Truncating (emptying) %s\n",path); } else { CfOut(cf_error,""," * File %s needs emptying",path); } return; } if (attr.rename.rotate > 0) { if (!DONTDO) { RotateFiles(path,attr.rename.rotate); cfPS(cf_inform,CF_CHG,"",pp,attr," -> Rotating files %s in %d fifo\n",path,attr.rename.rotate); } else { CfOut(cf_error,""," * File %s needs rotating",path); } return; } } /*********************************************************************/ static void VerifyDelete(char *path,struct stat *sb,struct Attributes attr,struct Promise *pp) { const char *lastnode = ReadLastNode(path); char buf[CF_MAXVARSIZE]; CfOut(cf_verbose,""," -> Verifying file deletions for %s\n",path); if (DONTDO) { CfOut(cf_inform,"","Promise requires deletion of file object %s\n",path); } else { switch (attr.transaction.action) { case cfa_warn: cfPS(cf_error,CF_WARN,"",pp,attr," !! %s '%s' should be deleted", S_ISDIR(sb->st_mode) ? "Directory" : "File", path); break; case cfa_fix: if (!S_ISDIR(sb->st_mode)) { if (unlink(lastnode) == -1) { cfPS(cf_verbose,CF_FAIL,"unlink",pp,attr,"Couldn't unlink %s tidying\n",path); } else { cfPS(cf_inform,CF_CHG,"",pp,attr," -> Deleted file %s\n",path); } } else // directory { if (!attr.delete.rmdirs) { CfOut(cf_inform,"unlink","Keeping directory %s\n",path); return; } if (attr.havedepthsearch && strcmp(path,pp->promiser) == 0) { /* This is the parent and we cannot delete it from here - must delete separately*/ return; } // use the full path if we are to delete the current dir if((strcmp(lastnode, ".") == 0) && strlen(path) > 2) { snprintf(buf, sizeof(buf), "%s", path); buf[strlen(path) - 1] = '\0'; buf[strlen(path) - 2] = '\0'; } else { snprintf(buf, sizeof(buf), "%s", lastnode); } if (rmdir(buf) == -1) { cfPS(cf_verbose,CF_FAIL,"rmdir",pp,attr," !! Delete directory %s failed (cannot delete node called \"%s\")\n",path,buf); } else { cfPS(cf_inform,CF_CHG,"",pp,attr," -> Deleted directory %s\n",path); } } break; default: FatalError("Cfengine: internal error: illegal file action\n"); } } } /*********************************************************************/ void TouchFile(char *path,struct stat *sb,struct Attributes attr,struct Promise *pp) { if (! DONTDO) { if (utime(path,NULL) != -1) { cfPS(cf_inform,CF_CHG,"",pp,attr," -> Touched (updated time stamps) %s\n",path); } else { cfPS(cf_inform,CF_FAIL,"utime",pp,attr,"Touch %s failed to update timestamps\n",path); } } else { CfOut(cf_error,"","Need to touch (update timestamps) %s\n",path); } } /*********************************************************************/ void VerifyFileIntegrity(char *file,struct Attributes attr,struct Promise *pp) { unsigned char digest1[EVP_MAX_MD_SIZE+1]; unsigned char digest2[EVP_MAX_MD_SIZE+1]; int changed = false, one,two; if ((attr.change.report_changes != cfa_contentchange) && (attr.change.report_changes != cfa_allchanges)) { return; } memset(digest1,0,EVP_MAX_MD_SIZE+1); memset(digest2,0,EVP_MAX_MD_SIZE+1); if (attr.change.hash == cf_besthash) { if (!DONTDO) { HashFile(file,digest1,cf_md5); HashFile(file,digest2,cf_sha1); one = FileHashChanged(file,digest1,cf_error,cf_md5,attr,pp); two = FileHashChanged(file,digest2,cf_error,cf_sha1,attr,pp); if (one || two) { changed = true; } } } else { if (!DONTDO) { HashFile(file,digest1,attr.change.hash); if (FileHashChanged(file,digest1,cf_error,attr.change.hash,attr,pp)) { changed = true; } } } if (changed) { NewPersistentContext("checksum_alerts",CF_PERSISTENCE,cfpreserve); LogHashChange(file); } if (attr.change.report_diffs) { LogFileChange(file,changed,attr,pp); } } /*********************************************************************/ void VerifyFileChanges(char *file,struct stat *sb,struct Attributes attr,struct Promise *pp) { struct stat cmpsb; CF_DB *dbp; char message[CF_BUFSIZE]; char statdb[CF_BUFSIZE]; int ok = true; if ((attr.change.report_changes != cfa_statschange) && (attr.change.report_changes != cfa_allchanges)) { return; } snprintf(statdb,CF_BUFSIZE,"%s/%s",CFWORKDIR,CF_CHKPDB); MapName(statdb); if (!OpenDB(statdb,&dbp)) { return; } if (!ReadDB(dbp,file,&cmpsb,sizeof(struct stat))) { if (!DONTDO) { WriteDB(dbp,file,sb,sizeof(struct stat)); CloseDB(dbp); return; } } if (cmpsb.st_mode != sb->st_mode) { ok = false; } if (cmpsb.st_uid != sb->st_uid) { ok = false; } if (cmpsb.st_gid != sb->st_gid) { ok = false; } if (cmpsb.st_dev != sb->st_dev) { ok = false; } if (cmpsb.st_ino != sb->st_ino) { ok = false; } if (cmpsb.st_mtime != sb->st_mtime) { ok = false; } if (ok) { CloseDB(dbp); return; } if (EXCLAIM) { CfOut(cf_error,"","!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } if (cmpsb.st_mode != sb->st_mode) { snprintf(message,CF_BUFSIZE-1,"ALERT: Permissions for %s changed %o -> %o",file,cmpsb.st_mode,sb->st_mode); CfOut(cf_error,"","%s",message); LogHashChange(message+strlen("ALERT: ")); } if (cmpsb.st_uid != sb->st_uid) { snprintf(message,CF_BUFSIZE-1,"ALERT: owner for %s changed %d -> %d",file,cmpsb.st_uid,sb->st_uid); CfOut(cf_error,"","%s",message); LogHashChange(message+strlen("ALERT: ")); } if (cmpsb.st_gid != sb->st_gid) { snprintf(message,CF_BUFSIZE-1,"ALERT: group for %s changed %d -> %d",file,cmpsb.st_gid,sb->st_gid); CfOut(cf_error,"","%s",message); LogHashChange(message+strlen("ALERT: ")); } if (cmpsb.st_dev != sb->st_dev) { CfOut(cf_error,"","ALERT: device for %s changed %d -> %d",file,cmpsb.st_dev,sb->st_dev); } if (cmpsb.st_ino != sb->st_ino) { CfOut(cf_error,"","ALERT: inode for %s changed %lu -> %lu",file,cmpsb.st_ino,sb->st_ino); } if (cmpsb.st_mtime != sb->st_mtime) { char from[CF_MAXVARSIZE]; char to[CF_MAXVARSIZE]; strcpy(from,cf_ctime(&(cmpsb.st_mtime))); strcpy(to,cf_ctime(&(sb->st_mtime))); Chop(from); Chop(to); CfOut(cf_error,"","ALERT: Last modified time for %s changed %s -> %s",file,from,to); } if (pp->ref) { CfOut(cf_error,"","Preceding promise: %s",pp->ref); } if (EXCLAIM) { CfOut(cf_error,"","!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } if (attr.change.update && !DONTDO) { DeleteDB(dbp,file); WriteDB(dbp,file,sb,sizeof(struct stat)); } CloseDB(dbp); } /*********************************************************************/ /* Level */ /*********************************************************************/ static int TransformFile(char *file,struct Attributes attr,struct Promise *pp) { char comm[CF_EXPANDSIZE],line[CF_BUFSIZE]; FILE *pop = NULL; int print = false; int transRetcode = 0; if (attr.transformer == NULL || file == NULL) { return false; } ExpandScalar(attr.transformer,comm); CfOut(cf_inform,"","Transforming: %s ",comm); if (!IsExecutable(GetArg0(comm))) { cfPS(cf_inform,CF_FAIL,"",pp,attr,"Transformer %s %s failed",attr.transformer,file); return false; } if (strncmp(comm,"/bin/echo",strlen("/bin/echo")) == 0) { print = true; } if (!DONTDO) { struct CfLock thislock = AcquireLock(comm,VUQNAME,CFSTARTTIME,attr,pp,false); if (thislock.lock == NULL) { return false; } if ((pop = cf_popen(comm,"r")) == NULL) { cfPS(cf_inform,CF_FAIL,"",pp,attr,"Transformer %s %s failed",attr.transformer,file); YieldCurrentLock(thislock); return false; } while (!feof(pop)) { CfReadLine(line,CF_BUFSIZE,pop); if (print) { CfOut(cf_reporting,"",line); } else { CfOut(cf_inform,"",line); } } transRetcode = cf_pclose(pop); if(VerifyCommandRetcode(transRetcode,true,attr,pp)) { CfOut(cf_inform,"","-> Transformer %s => %s seemed to work ok",file,comm); } else { CfOut(cf_error,"","-> Transformer %s => %s returned error",file,comm); } YieldCurrentLock(thislock); } else { CfOut(cf_error,""," -> Need to transform file \"%s\" with \"%s\"",file,comm); } return true; } /*******************************************************************/ int MakeParentDirectory(char *parentandchild,int force) { char *spc, *sp; char currentpath[CF_BUFSIZE]; char pathbuf[CF_BUFSIZE]; struct stat statbuf; mode_t mask; int rootlen; char Path_File_Separator; #ifdef DARWIN /* Keeps track of if dealing w. resource fork */ int rsrcfork; rsrcfork = 0; char * tmpstr; #endif Debug("Trying to create a parent directory for %s%s", parentandchild, force ? " (force applied)": ""); if (!IsAbsoluteFileName(parentandchild)) { CfOut(cf_error,"","Will not create directories for a relative filename (%s). Has no invariant meaning\n",parentandchild); return false; } strncpy(pathbuf,parentandchild,CF_BUFSIZE-1); /* local copy */ #ifdef DARWIN if (strstr(pathbuf, _PATH_RSRCFORKSPEC) != NULL) { rsrcfork = 1; } #endif /* skip link name */ /* This cast is necessary, as you can't have (char* -> char*) and (const char* -> const char*) functions in C */ sp = (char *)LastFileSeparator(pathbuf); if (sp == NULL) { sp = pathbuf; } *sp = '\0'; DeleteSlash(pathbuf); if (lstat(pathbuf,&statbuf) != -1) { if (S_ISLNK(statbuf.st_mode)) { CfOut(cf_verbose,"","INFO: %s is a symbolic link, not a true directory!\n",pathbuf); } if (force) /* force in-the-way directories aside */ { struct stat dir; stat(pathbuf,&dir); if (!S_ISDIR(dir.st_mode)) /* if the dir exists - no problem */ { struct stat sbuf; if (DONTDO) { return true; } strcpy(currentpath,pathbuf); DeleteSlash(currentpath); strcat(currentpath,".cf-moved"); CfOut(cf_inform,"","Moving obstructing file/link %s to %s to make directory",pathbuf,currentpath); /* If cfagent, remove an obstructing backup object */ if (lstat(currentpath,&sbuf) != -1) { if (S_ISDIR(sbuf.st_mode)) { DeleteDirectoryTree(currentpath,NULL); } else { if (unlink(currentpath) == -1) { CfOut(cf_inform,"unlink","Couldn't remove file/link %s while trying to remove a backup\n",currentpath); } } } /* And then move the current object out of the way...*/ if (cf_rename(pathbuf,currentpath) == -1) { CfOut(cf_inform,"cf_rename","Warning. The object %s is not a directory.\n",pathbuf); return(false); } } } else { if (! S_ISLNK(statbuf.st_mode) && ! S_ISDIR(statbuf.st_mode)) { CfOut(cf_inform,"","The object %s is not a directory. Cannot make a new directory without deleting it.",pathbuf); return(false); } } } /* Now we can make a new directory .. */ currentpath[0] = '\0'; rootlen = RootDirLength(parentandchild); strncpy(currentpath, parentandchild, rootlen); for (sp = parentandchild+rootlen, spc = currentpath+rootlen; *sp != '\0'; sp++) { if (!IsFileSep(*sp) && *sp != '\0') { *spc = *sp; spc++; } else { Path_File_Separator = *sp; *spc = '\0'; if (strlen(currentpath) == 0) { } else if (cfstat(currentpath,&statbuf) == -1) { Debug2("cfengine: Making directory %s, mode %o\n",currentpath,DEFAULTMODE); if (! DONTDO) { mask = umask(0); if (cf_mkdir(currentpath,DEFAULTMODE) == -1) { CfOut(cf_error,"cf_mkdir","Unable to make directories to %s\n",parentandchild); umask(mask); return(false); } umask(mask); } } else { if (! S_ISDIR(statbuf.st_mode)) { #ifdef DARWIN /* Ck if rsrc fork */ if (rsrcfork) { tmpstr = malloc(CF_BUFSIZE); strncpy(tmpstr, currentpath, CF_BUFSIZE); strncat(tmpstr, _PATH_FORKSPECIFIER, CF_BUFSIZE); /* Cfengine removed terminating slashes */ DeleteSlash(tmpstr); if (strncmp(tmpstr, pathbuf, CF_BUFSIZE) == 0) { free(tmpstr); return(true); } free(tmpstr); } #endif CfOut(cf_error,"","Cannot make %s - %s is not a directory! (use forcedirs=true)\n",pathbuf,currentpath); return(false); } } /* *spc = FILE_SEPARATOR; */ *spc = Path_File_Separator; spc++; } } Debug("Directory for %s exists. Okay\n",parentandchild); return(true); } /**********************************************************************/ static void TruncateFile(char *name) { struct stat statbuf; int fd; if (cfstat(name,&statbuf) == -1) { Debug("cfengine: didn't find %s to truncate\n",name); } else { if ((fd = creat(name,000)) == -1) /* dummy mode ignored */ { CfOut(cf_error,"creat","Failed to create or truncate file %s\n",name); } else { close(fd); } } } /*********************************************************************/ void LogHashChange(char *file) { FILE *fp; char fname[CF_BUFSIZE]; time_t now = time(NULL); struct stat sb; mode_t perm = 0600; static char prevFile[CF_MAXVARSIZE] = {0}; // we might get called twice.. if (strcmp(file,prevFile) == 0) { return; } snprintf(prevFile,sizeof(prevFile),file); /* This is inefficient but we don't want to lose any data */ snprintf(fname,CF_BUFSIZE,"%s/state/%s",CFWORKDIR,CF_FILECHANGE); MapName(fname); #ifndef MINGW if (cfstat(fname,&sb) != -1) { if (sb.st_mode & (S_IWGRP | S_IWOTH)) { CfOut(cf_error,"","File %s (owner %d) is writable by others (security exception)",fname,sb.st_uid); } } #endif /* NOT MINGW */ if ((fp = fopen(fname,"a")) == NULL) { CfOut(cf_error,"fopen","Could not write to the hash change log"); return; } fprintf(fp,"%ld,%s\n",(long)now,file); fclose(fp); cf_chmod(fname,perm); } /*******************************************************************/ void RotateFiles(char *name,int number) { int i, fd; struct stat statbuf; char from[CF_BUFSIZE],to[CF_BUFSIZE]; struct Attributes attr = {{0}}; struct Promise dummyp = {0}; if (IsItemIn(ROTATED,name)) { return; } PrependItem(&ROTATED,name,NULL); if (cfstat(name,&statbuf) == -1) { CfOut(cf_verbose,"","No access to file %s\n",name); return; } for (i = number-1; i > 0; i--) { snprintf(from,CF_BUFSIZE,"%s.%d",name,i); snprintf(to,CF_BUFSIZE,"%s.%d",name, i+1); if (cf_rename(from,to) == -1) { Debug("Rename failed in RotateFiles %s -> %s\n",name,from); } snprintf(from,CF_BUFSIZE,"%s.%d.gz",name,i); snprintf(to,CF_BUFSIZE,"%s.%d.gz",name, i+1); if (cf_rename(from,to) == -1) { Debug("Rename failed in RotateFiles %s -> %s\n",name,from); } snprintf(from,CF_BUFSIZE,"%s.%d.Z",name,i); snprintf(to,CF_BUFSIZE,"%s.%d.Z",name, i+1); if (cf_rename(from,to) == -1) { Debug("Rename failed in RotateFiles %s -> %s\n",name,from); } snprintf(from,CF_BUFSIZE,"%s.%d.bz",name,i); snprintf(to,CF_BUFSIZE,"%s.%d.bz",name, i+1); if (cf_rename(from,to) == -1) { Debug("Rename failed in RotateFiles %s -> %s\n",name,from); } snprintf(from,CF_BUFSIZE,"%s.%d.bz2",name,i); snprintf(to,CF_BUFSIZE,"%s.%d.bz2",name, i+1); if (cf_rename(from,to) == -1) { Debug("Rename failed in RotateFiles %s -> %s\n",name,from); } } snprintf(to,CF_BUFSIZE,"%s.1",name); memset(&dummyp,0,sizeof(dummyp)); memset(&attr,0,sizeof(attr)); dummyp.this_server = "localdisk"; if (CopyRegularFileDisk(name,to,attr,&dummyp) == -1) { Debug2("cfengine: copy failed in RotateFiles %s -> %s\n",name,to); return; } cf_chmod(to,statbuf.st_mode); chown(to,statbuf.st_uid,statbuf.st_gid); cf_chmod(name,0600); /* File must be writable to empty ..*/ if ((fd = creat(name,statbuf.st_mode)) == -1) { CfOut(cf_error,"creat","Failed to create new %s in disable(rotate)\n",name); } else { chown(name,statbuf.st_uid,statbuf.st_gid); /* NT doesn't have fchown */ fchmod(fd,statbuf.st_mode); close(fd); } } /*******************************************************************/ /* Level */ /*******************************************************************/ static void DeleteDirectoryTree(char *path,struct Promise *pp) { struct Promise promise = {0}; char s[CF_MAXVARSIZE]; time_t now = time(NULL); // Check that tree is a directory promise.promiser = path; promise.promisee = NULL; promise.petype = CF_NOPROMISEE; promise.classes = "any"; if (pp != NULL) { promise.bundletype = pp->bundletype; promise.lineno = pp->lineno; promise.bundle = strdup(pp->bundle); promise.ref = pp->ref; } else { promise.bundletype = "agent"; promise.lineno = 0; promise.bundle = "embedded"; promise.ref = "Embedded deletion of direction"; } promise.audit = AUDITPTR; promise.agentsubtype = "files"; promise.done = false; promise.next = NULL; promise.donep = false; promise.conlist = NULL; snprintf(s,CF_MAXVARSIZE,"0,%ld",(long)now); AppendConstraint(&(promise.conlist),"action","true",CF_SCALAR,"any",false); AppendConstraint(&(promise.conlist),"ifelapsed","0",CF_SCALAR,"any",false); AppendConstraint(&(promise.conlist),"delete","true",CF_SCALAR,"any",false); AppendConstraint(&(promise.conlist),"dirlinks","delete",CF_SCALAR,"any",false); AppendConstraint(&(promise.conlist),"rmdirs","true",CF_SCALAR,"any",false); AppendConstraint(&(promise.conlist),"depth_search","true",CF_SCALAR,"any",false); AppendConstraint(&(promise.conlist),"depth","inf",CF_SCALAR,"any",false); AppendConstraint(&(promise.conlist),"file_select","true",CF_SCALAR,"any",false); AppendConstraint(&(promise.conlist),"mtime",s,CF_SCALAR,"any",false); AppendConstraint(&(promise.conlist),"file_result","mtime",CF_SCALAR,"any",false); VerifyFilePromise(promise.promiser,&promise); rmdir(path); } #ifndef MINGW /*******************************************************************/ /* Unix-specific implementations of file functions */ /*******************************************************************/ static void VerifySetUidGid(char *file,struct stat *dstat,mode_t newperm,struct Promise *pp,struct Attributes attr) { int amroot = true; if (!IsPrivileged()) { amroot = false; } if ((dstat->st_uid == 0) && (dstat->st_mode & S_ISUID)) { if (newperm & S_ISUID) { if (!IsItemIn(VSETUIDLIST,file)) { if (amroot) { cfPS(cf_error,CF_WARN,"",pp,attr,"NEW SETUID root PROGRAM %s\n",file); } PrependItem(&VSETUIDLIST,file,NULL); } } else { switch (attr.transaction.action) { case cfa_fix: cfPS(cf_inform,CF_CHG,"",pp,attr," -> Removing setuid (root) flag from %s...\n\n",file); break; case cfa_warn: if (amroot) { cfPS(cf_error,CF_WARN,"",pp,attr," !! WARNING setuid (root) flag on %s...\n\n",file); } break; } } } if (dstat->st_uid == 0 && (dstat->st_mode & S_ISGID)) { if (newperm & S_ISGID) { if (!IsItemIn(VSETUIDLIST,file)) { if (S_ISDIR(dstat->st_mode)) { /* setgid directory */ } else { if (amroot) { cfPS(cf_error,CF_WARN,"",pp,attr," !! NEW SETGID root PROGRAM %s\n",file); } PrependItem(&VSETUIDLIST,file,NULL); } } } else { switch (attr.transaction.action) { case cfa_fix: cfPS(cf_inform,CF_CHG,"",pp,attr," -> Removing setgid (root) flag from %s...\n\n",file); break; case cfa_warn: cfPS(cf_inform,CF_WARN,"",pp,attr," !! WARNING setgid (root) flag on %s...\n\n",file); break; default: break; } } } } /*****************************************************************************/ static int Unix_VerifyOwner(char *file,struct Promise *pp,struct Attributes attr,struct stat *sb) { struct passwd *pw; struct group *gp; struct UidList *ulp; struct GidList *glp; short uidmatch = false, gidmatch = false; uid_t uid = CF_SAME_OWNER; gid_t gid = CF_SAME_GROUP; Debug("Unix_VerifyOwner: %d\n",sb->st_uid); for (ulp = attr.perms.owners; ulp != NULL; ulp=ulp->next) { if (ulp->uid == CF_SAME_OWNER || sb->st_uid == ulp->uid) /* "same" matches anything */ { uid = ulp->uid; uidmatch = true; break; } } if (attr.perms.groups->next == NULL && attr.perms.groups->gid == CF_UNKNOWN_GROUP) // Only one non.existent item { cfPS(cf_inform,CF_FAIL,"",pp,attr," !! Unable to make file belong to an unknown group"); } if (attr.perms.owners->next == NULL && attr.perms.owners->uid == CF_UNKNOWN_OWNER) // Only one non.existent item { cfPS(cf_inform,CF_FAIL,"",pp,attr," !! Unable to make file belong to an unknown user"); } for (glp = attr.perms.groups; glp != NULL; glp=glp->next) { if (glp->gid == CF_SAME_GROUP || sb->st_gid == glp->gid) /* "same" matches anything */ { gid = glp->gid; gidmatch = true; break; } } if (uidmatch && gidmatch) { return false; } else { if (! uidmatch) { for (ulp = attr.perms.owners; ulp != NULL; ulp=ulp->next) { if (attr.perms.owners->uid != CF_UNKNOWN_OWNER) { uid = attr.perms.owners->uid; /* default is first (not unknown) item in list */ break; } } } if (! gidmatch) { for (glp = attr.perms.groups; glp != NULL; glp=glp->next) { if (attr.perms.groups->gid != CF_UNKNOWN_GROUP) { gid = attr.perms.groups->gid; /* default is first (not unknown) item in list */ break; } } } switch (attr.transaction.action) { case cfa_fix: if (uid == CF_SAME_OWNER && gid == CF_SAME_GROUP) { CfOut(cf_verbose,""," -> Touching %s\n",file); } else { if (uid != CF_SAME_OWNER) { Debug("(Change owner to uid %d if possible)\n",uid); } if (gid != CF_SAME_GROUP) { Debug("Change group to gid %d if possible)\n",gid); } } if (!DONTDO && S_ISLNK(sb->st_mode)) { #ifdef HAVE_LCHOWN Debug("Using LCHOWN function\n"); if (lchown(file,uid,gid) == -1) { CfOut(cf_inform,"lchown"," !! Cannot set ownership on link %s!\n",file); } else { return true; } #endif } else if (!DONTDO) { if (!uidmatch) { cfPS(cf_inform,CF_CHG,"",pp,attr," -> Owner of %s was %d, setting to %d",file,sb->st_uid,uid); } if (!gidmatch) { cfPS(cf_inform,CF_CHG,"",pp,attr," -> Group of %s was %d, setting to %d",file,sb->st_gid,gid); } if (!S_ISLNK(sb->st_mode)) { if (chown(file,uid,gid) == -1) { cfPS(cf_inform,CF_DENIED,"chown",pp,attr," !! Cannot set ownership on file %s!\n",file); } else { return true; } } } break; case cfa_warn: if ((pw = getpwuid(sb->st_uid)) == NULL) { CfOut(cf_error,"","File %s is not owned by anybody in the passwd database\n",file); CfOut(cf_error,"","(uid = %d,gid = %d)\n",sb->st_uid,sb->st_gid); break; } if ((gp = getgrgid(sb->st_gid)) == NULL) { cfPS(cf_error,CF_WARN,"",pp,attr," !! File %s is not owned by any group in group database\n",file); break; } cfPS(cf_error,CF_WARN,"",pp,attr," !! File %s is owned by [%s], group [%s]\n",file,pw->pw_name,gp->gr_name); break; } } return false; } /*********************************************************************/ struct UidList *MakeUidList(char *uidnames) { struct UidList *uidlist; struct Item *ip, *tmplist; char uidbuff[CF_BUFSIZE]; char *sp; int offset; struct passwd *pw; char *machine, *user, *domain, *usercopy=NULL; int uid; int tmp = -1; uidlist = NULL; for (sp = uidnames; *sp != '\0'; sp+=strlen(uidbuff)) { if (*sp == ',') { sp++; } if (sscanf(sp,"%[^,]",uidbuff)) { if (uidbuff[0] == '+') /* NIS group - have to do this in a roundabout */ { /* way because calling getpwnam spoils getnetgrent */ offset = 1; if (uidbuff[1] == '@') { offset++; } setnetgrent(uidbuff+offset); tmplist = NULL; while (getnetgrent(&machine,&user,&domain)) { if (user != NULL) { AppendItem(&tmplist,user,NULL); } } endnetgrent(); for (ip = tmplist; ip != NULL; ip=ip->next) { if ((pw = getpwnam(ip->name)) == NULL) { CfOut(cf_inform,""," !! Unknown user \'%s\'\n",ip->name); uid = CF_UNKNOWN_OWNER; /* signal user not found */ usercopy = ip->name; } else { uid = pw->pw_uid; } AddSimpleUidItem(&uidlist,uid,usercopy); } DeleteItemList(tmplist); continue; } if (isdigit((int)uidbuff[0])) { sscanf(uidbuff,"%d",&tmp); uid = (uid_t)tmp; } else { if (strcmp(uidbuff,"*") == 0) { uid = CF_SAME_OWNER; /* signals wildcard */ } else if ((pw = getpwnam(uidbuff)) == NULL) { CfOut(cf_inform,"","Unknown user \'%s\'\n",uidbuff); uid = CF_UNKNOWN_OWNER; /* signal user not found */ usercopy = uidbuff; } else { uid = pw->pw_uid; } } AddSimpleUidItem(&uidlist,uid,usercopy); } } if (uidlist == NULL) { AddSimpleUidItem(&uidlist,CF_SAME_OWNER,(char *) NULL); } return (uidlist); } /*********************************************************************/ struct GidList *MakeGidList(char *gidnames) { struct GidList *gidlist; char gidbuff[CF_BUFSIZE]; char *sp, *groupcopy=NULL; struct group *gr; int gid; int tmp = -1; gidlist = NULL; for (sp = gidnames; *sp != '\0'; sp+=strlen(gidbuff)) { if (*sp == ',') { sp++; } if (sscanf(sp,"%[^,]",gidbuff)) { if (isdigit((int)gidbuff[0])) { sscanf(gidbuff,"%d",&tmp); gid = (gid_t)tmp; } else { if (strcmp(gidbuff,"*") == 0) { gid = CF_SAME_GROUP; /* signals wildcard */ } else if ((gr = getgrnam(gidbuff)) == NULL) { CfOut(cf_inform,""," !! Unknown group %s\n",gidbuff); gid = CF_UNKNOWN_GROUP; groupcopy = gidbuff; } else { gid = gr->gr_gid; } } AddSimpleGidItem(&gidlist,gid,groupcopy); } } if (gidlist == NULL) { AddSimpleGidItem(&gidlist,CF_SAME_GROUP,NULL); } return(gidlist); } /*****************************************************************************/ static void Unix_VerifyFileAttributes(char *file,struct stat *dstat,struct Attributes attr,struct Promise *pp) { mode_t newperm = dstat->st_mode, maskvalue; #if defined HAVE_CHFLAGS u_long newflags; #endif maskvalue = umask(0); /* This makes the DEFAULT modes absolute */ newperm = (dstat->st_mode & 07777); if ((attr.perms.plus != CF_SAMEMODE) && (attr.perms.minus != CF_SAMEMODE)) { newperm |= attr.perms.plus; newperm &= ~(attr.perms.minus); Debug("Unix_VerifyFileAttributes(%s -> %o)\n",file,newperm); /* directories must have x set if r set, regardless */ if (S_ISDIR(dstat->st_mode)) { if (attr.perms.rxdirs) { Debug("Directory...fixing x bits\n"); if (newperm & S_IRUSR) { newperm |= S_IXUSR; } if (newperm & S_IRGRP) { newperm |= S_IXGRP; } if (newperm & S_IROTH) { newperm |= S_IXOTH; } } else { CfOut(cf_verbose,"","NB: rxdirs is set to false - x for r bits not checked\n"); } } } VerifySetUidGid(file,dstat,newperm,pp,attr); #ifdef DARWIN if (VerifyFinderType(file,dstat,attr,pp)) { /* nop */ } #endif if (VerifyOwner(file,pp,attr,dstat)) { /* nop */ } if (attr.havechange && S_ISREG(dstat->st_mode)) { VerifyFileIntegrity(file,attr,pp); } if (attr.havechange) { VerifyFileChanges(file,dstat,attr,pp); } if (S_ISLNK(dstat->st_mode)) /* No point in checking permission on a link */ { KillGhostLink(file,attr,pp); umask(maskvalue); return; } if (attr.acl.acl_entries) { VerifyACL(file,attr,pp); } VerifySetUidGid(file,dstat,dstat->st_mode,pp,attr); if ((newperm & 07777) == (dstat->st_mode & 07777)) /* file okay */ { Debug("File okay, newperm = %o, stat = %o\n",(newperm & 07777),(dstat->st_mode & 07777)); cfPS(cf_verbose,CF_NOP,"",pp,attr," -> File permissions on %s as promised\n",file); } else { Debug("Trying to fix mode...newperm = %o, stat = %o\n",(newperm & 07777),(dstat->st_mode & 07777)); switch (attr.transaction.action) { case cfa_warn: cfPS(cf_error,CF_WARN,"",pp,attr," !! %s has permission %o - [should be %o]\n",file,dstat->st_mode & 07777,newperm & 07777); break; case cfa_fix: if (!DONTDO) { if (cf_chmod(file,newperm & 07777) == -1) { CfOut(cf_error,"cf_chmod","cf_chmod failed on %s\n",file); break; } } cfPS(cf_inform,CF_CHG,"",pp,attr," -> Object %s had permission %o, changed it to %o\n",file,dstat->st_mode & 07777,newperm & 07777); break; default: FatalError("cfengine: internal error Unix_VerifyFileAttributes(): illegal file action\n"); } } #if defined HAVE_CHFLAGS /* BSD special flags */ newflags = (dstat->st_flags & CHFLAGS_MASK); newflags |= attr.perms.plus_flags; newflags &= ~(attr.perms.minus_flags); if ((newflags & CHFLAGS_MASK) == (dstat->st_flags & CHFLAGS_MASK)) /* file okay */ { Debug("BSD File okay, flags = %lx, current = %lx\n",(newflags & CHFLAGS_MASK),(dstat->st_flags & CHFLAGS_MASK)); } else { Debug("BSD Fixing %s, newflags = %lx, flags = %lx\n",file,(newflags & CHFLAGS_MASK),(dstat->st_flags & CHFLAGS_MASK)); switch (attr.transaction.action) { case cfa_warn: cfPS(cf_error,CF_WARN,"",pp,attr," !! %s has flags %o - [should be %o]\n",file,dstat->st_mode & CHFLAGS_MASK,newflags & CHFLAGS_MASK); break; case cfa_fix: if (! DONTDO) { if (chflags(file,newflags & CHFLAGS_MASK) == -1) { cfPS(cf_error,CF_DENIED,"chflags",pp,attr," !! Failed setting BSD flags %x on %s\n",newflags,file); break; } else { cfPS(cf_inform,CF_CHG,"",pp,attr," -> %s had flags %o, changed it to %o\n",file,dstat->st_flags & CHFLAGS_MASK,newflags & CHFLAGS_MASK); } } break; default: FatalError("cfengine: internal error Unix_VerifyFileAttributes() illegal file action\n"); } } #endif if (attr.touch) { if (utime(file,NULL) == -1) { cfPS(cf_inform,CF_DENIED,"utime",pp,attr," !! Touching file %s failed",file); } else { cfPS(cf_inform,CF_CHG,"",pp,attr," -> Touching file %s",file); } } umask(maskvalue); Debug("Unix_VerifyFileAttributes(Done)\n"); } /*****************************************************************************/ static void Unix_VerifyCopiedFileAttributes(char *file,struct stat *dstat,struct stat *sstat,struct Attributes attr,struct Promise *pp) { mode_t newplus,newminus; uid_t save_uid; gid_t save_gid; // If we get here, there is both a src and dest file Debug("VerifyCopiedFile(%s,+%o,-%o)\n",file,attr.perms.plus,attr.perms.minus); save_uid = (attr.perms.owners)->uid; save_gid = (attr.perms.groups)->gid; if (attr.copy.preserve) { CfOut(cf_verbose,""," -> Attempting to preserve file permissions from the source: %o",(sstat->st_mode & 07777)); if ((attr.perms.owners)->uid == CF_SAME_OWNER) /* Preserve uid and gid */ { (attr.perms.owners)->uid = sstat->st_uid; } if ((attr.perms.groups)->gid == CF_SAME_GROUP) { (attr.perms.groups)->gid = sstat->st_gid; } // Will this preserve if no mode set? newplus = (sstat->st_mode & 07777); newminus = ~newplus & 07777; attr.perms.plus = newplus; attr.perms.minus = newminus; VerifyFileAttributes(file,dstat,attr,pp); } else { if ((attr.perms.owners)->uid == CF_SAME_OWNER) /* Preserve uid and gid */ { (attr.perms.owners)->uid = dstat->st_uid; } if ((attr.perms.groups)->gid == CF_SAME_GROUP) { (attr.perms.groups)->gid = dstat->st_gid; } if (attr.haveperms) { newplus = (dstat->st_mode & 07777) | attr.perms.plus; newminus = ~(newplus & ~(attr.perms.minus)) & 07777; attr.perms.plus = newplus; attr.perms.minus = newminus; VerifyFileAttributes(file,dstat,attr,pp); } } (attr.perms.owners)->uid = save_uid; (attr.perms.groups)->gid = save_gid; } /*******************************************************************/ void AddSimpleUidItem(struct UidList **uidlist,uid_t uid,char *uidname) { struct UidList *ulp, *u; char *copyuser; if ((ulp = (struct UidList *)malloc(sizeof(struct UidList))) == NULL) { FatalError("cfengine: malloc() failed #1 in AddSimpleUidItem()"); } ulp->uid = uid; if (uid == CF_UNKNOWN_OWNER) /* unknown user */ { if ((copyuser = strdup(uidname)) == NULL) { FatalError("cfengine: malloc() failed #2 in AddSimpleUidItem()"); } ulp->uidname = copyuser; } else { ulp->uidname = NULL; } ulp->next = NULL; if (*uidlist == NULL) { *uidlist = ulp; } else { for (u = *uidlist; u->next != NULL; u = u->next) { } u->next = ulp; } } /*******************************************************************/ void AddSimpleGidItem(struct GidList **gidlist,gid_t gid,char *gidname) { struct GidList *glp,*g; char *copygroup; if ((glp = (struct GidList *)malloc(sizeof(struct GidList))) == NULL) { FatalError("cfengine: malloc() failed #1 in AddSimpleGidItem()"); } glp->gid = gid; if (gid == CF_UNKNOWN_GROUP) /* unknown group */ { if ((copygroup = strdup(gidname)) == NULL) { FatalError("cfengine: malloc() failed #2 in AddSimpleGidItem()"); } glp->gidname = copygroup; } else { glp->gidname = NULL; } glp->next = NULL; if (*gidlist == NULL) { *gidlist = glp; } else { for (g = *gidlist; g->next != NULL; g = g->next) { } g->next = glp; } } #endif /* NOT MINGW */ ����������cfengine-3.2.4/src/patches.c������������������������������������������������������������������������0000644�0001750�0001750�00000040477�11715232734�012622� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*********************************************************/ /* patches.c */ /* */ /* Contains any fixes which need to be made because of */ /* lack of OS support on a given platform */ /* These are conditionally compiled, pending extensions */ /* or developments in the OS concerned. */ /*********************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int IntMin (int a,int b); static int UseUnixStandard(char *s); static char *cf_format_strtimestamp(struct tm *tm, char *buf); /*********************************************************/ static int IntMin (int a,int b) { if (a > b) { return b; } else { return a; } } /*********************************************************/ /* We assume that s is at least MAX_FILENAME large. * MapName() is thread-safe, but the argument is modified. */ #ifdef NT char *MapName(char *s) { char buffer[CF_BUFSIZE]; char *spto; char *spf; memset(buffer,0,CF_BUFSIZE); if (UseUnixStandard(s)) { spto = buffer; for (spf = s; *spf != '\0'; spf++) { if (IsFileSep(*spf) && IsFileSep(*(spf+1))) /* compress // or \\ */ { continue; } if (IsFileSep(*spf) && *(spf+1) != '\0' && *(spf+2) == ':') /* compress \c:\abc */ { continue; } if (*(spf+1) != '\0' && (strncmp(spf+1,":\\",2) == 0 || strncmp(spf+1,":/",2) == 0 )) { /* For cygwin translation */ strcat(spto,"/cygdrive/"); /* Drive letter */ strncat(spto,spf,1); strcat(spto,"/"); spto += strlen("/cygdrive/c/"); spf += strlen("c:/") - 1; continue; } switch (*spf) { case '\\': *spto = '/'; break; default: *spto = *spf; break; } spto++; } } else { spto = buffer; for (spf = s; *spf != '\0'; spf++) { switch (*spf) { case '/': *spto++ = '\\'; break; default: *spto++ = *spf; break; } } } memset(s,0,MAX_FILENAME); strncpy(s,buffer,MAX_FILENAME-1); return s; } #else char *MapName(char *s) { return s; } #endif /* NT */ /*********************************************************/ char *MapNameForward(char *s) /* Like MapName(), but maps all slashes to forward */ { char *sp; for (sp = s; *sp != '\0'; sp++) { switch(*sp) { case '\\': *sp = '/'; } } return s; } /*********************************************************/ static int UseUnixStandard(char *s) { #ifdef MINGW return false; #else return true; #endif } /*********************************************************/ char *StrStr(char *a,char *b) /* Case insensitive match */ { char buf1[CF_BUFSIZE],buf2[CF_BUFSIZE]; strncpy(buf1,ToLowerStr(a),CF_BUFSIZE-1); strncpy(buf2,ToLowerStr(b),CF_BUFSIZE-1); return strstr(buf1,buf2); } /*********************************************************/ int StrnCmp(char *a,char *b,size_t n) /* Case insensitive match */ { char buf1[CF_BUFSIZE],buf2[CF_BUFSIZE]; strncpy(buf1,ToLowerStr(a),CF_BUFSIZE-1); strncpy(buf2,ToLowerStr(b),CF_BUFSIZE-1); return strncmp(buf1,buf2,n); } /*********************************************************************/ int cf_strcmp(const char *s1, const char *s2) { /* Windows native eventually? */ return strcmp(s1,s2); } /*********************************************************************/ int cf_strncmp(const char *s1, const char *s2, size_t n) { /* Windows native eventually? */ return strncmp(s1,s2,n); } /*********************************************************************/ char *cf_strcpy(char *s1, const char *s2) { /* Windows native eventually? */ return strcpy(s1,s2); } /*********************************************************************/ char *cf_strncpy(char *s1, const char *s2, size_t n) { /* Windows native eventually? */ return strncpy(s1,s2,n); } /*********************************************************************/ char *cf_strdup(const char *s) { return strdup(s); } /*********************************************************************/ int cf_strlen(const char *s) { return strlen(s); } /*********************************************************************/ char *cf_strchr(const char *s, int c) { return strchr(s,c); } /*********************************************************/ #ifndef HAVE_GETNETGRENT #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ # ifndef const # define const # endif #endif /*********************************************************/ int setnetgrent(netgroup) const char *netgroup; { return 0; } /**********************************************************/ int getnetgrent(a,b,c) char **a, **b, **c; { *a=NULL; *b=NULL; *c=NULL; return 0; } /***********************************************************/ void endnetgrent() { } #endif #ifndef HAVE_UNAME #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ # ifndef const # define const # endif #endif /***********************************************************/ /* UNAME is missing on some weird OSes */ /***********************************************************/ int uname (struct utsname *sys) #ifdef MINGW { return NovaWin_uname(sys); } #else /* NOT MINGW */ { char buffer[CF_BUFSIZE], *sp; if (gethostname(buffer,CF_BUFSIZE) == -1) { perror("gethostname"); exit(1); } strcpy(sys->nodename,buffer); if (strcmp(buffer,AUTOCONF_HOSTNAME) != 0) { CfOut(cf_verbose,"","This binary was complied on a different host (%s).\n",AUTOCONF_HOSTNAME); CfOut(cf_verbose,"","This host does not have uname, so I can't tell if it is the exact same OS\n"); } strcpy(sys->sysname,AUTOCONF_SYSNAME); strcpy(sys->release,"cfengine-had-to-guess"); strcpy(sys->machine,"missing-uname(2)"); strcpy(sys->version,"unknown"); /* Extract a version number if possible */ for (sp = sys->sysname; *sp != '\0'; sp++) { if (isdigit(*sp)) { strcpy(sys->release,sp); strcpy(sys->version,sp); *sp = '\0'; break; } } return (0); } #endif /* NOT MINGW */ #endif /* NOT HAVE_UNAME */ /***********************************************************/ /* strstr() missing on old BSD systems */ /***********************************************************/ #ifndef HAVE_STRSTR #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ # ifndef const # define const # endif #endif char *strstr(char *s1,char *s2) { char *sp; for (sp = s1; *sp != '\0'; sp++) { if (*sp != *s2) { continue; } if (strncmp(sp,s2,strlen(s2))== 0) { return sp; } } return NULL; } #endif #ifndef HAVE_STRSEP char *strsep(char **stringp, const char *delim) { return strtok(*stringp,delim); } #endif /***********************************************************/ /* strrchr() missing on old BSD systems */ /***********************************************************/ #ifndef HAVE_STRRCHR char *strrchr(char *str,char ch) { char *sp; if (str == NULL) { return NULL; } if (strlen(str) == 0) { return NULL; } for (sp = str+strlen(str)-1; sp > str; sp--) { if (*sp == ch) { return *sp; } } return NULL; } #endif /***********************************************************/ /* strerror() missing on systems */ /***********************************************************/ #ifndef HAVE_STRERROR char *strerror(int err) { static char buffer[20]; sprintf(buffer,"Error number %d\n",err); return buffer; } #endif /***********************************************************/ /* putenv() missing on old BSD systems */ /***********************************************************/ #ifndef HAVE_PUTENV #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ # ifndef const # define const # endif #endif int putenv(char *s) { CfOut(cf_verbose,"","(This system does not have putenv: cannot update CFALLCLASSES\n"); return 0; } #endif /***********************************************************/ /* seteuid/gid() missing on some on posix systems */ /***********************************************************/ #ifndef HAVE_SETEUID #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ # ifndef const # define const # endif #endif int seteuid (uid_t uid) { #ifdef HAVE_SETREUID return setreuid(-1,uid); #else CfOut(cf_verbose,"","(This system does not have setreuid (patches.c)\n"); return -1; #endif } #endif /***********************************************************/ #ifndef HAVE_SETEGID #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ # ifndef const # define const # endif #endif int setegid (gid_t gid) { #ifdef HAVE_SETREGID return setregid(-1,gid); #else CfOut(cf_verbose,"","(This system does not have setregid (patches.c)\n"); return -1; #endif } #endif /*******************************************************************/ #ifndef HAVE_DRAND48 double drand48(void) { return (double)random(); } #endif #ifndef HAVE_DRAND48 void srand48(long seed) { srandom((unsigned int)seed); } #endif /*******************************************************************/ int IsPrivileged() { #ifdef NT return true; #else return (getuid() == 0); #endif } /*******************************************************************/ char *cf_ctime(const time_t *timep) { static char buf[26]; return cf_strtimestamp_local(*timep, buf); } /* * This function converts passed time_t value to string timestamp used * throughout the system. By sheer coincidence this timestamp has the same * format as ctime(3) output on most systems (but NT differs in definition of * ctime format, so those are not identical there). * * Buffer passed should be at least 26 bytes long (including the trailing zero). * * Please use this function instead of (non-portable and deprecated) ctime_r or * (non-threadsafe) cf_ctime or ctime. */ /*******************************************************************/ char *cf_strtimestamp_local(const time_t time, char *buf) { struct tm tm; if (localtime_r(&time, &tm) == NULL) { CfOut(cf_verbose, "localtime_r", "Unable to parse passed timestamp"); return NULL; } return cf_format_strtimestamp(&tm, buf); } /*******************************************************************/ char *cf_strtimestamp_utc(const time_t time, char *buf) { struct tm tm; if (gmtime_r(&time, &tm) == NULL) { CfOut(cf_verbose, "gmtime_r", "Unable to parse passed timestamp"); return NULL; } return cf_format_strtimestamp(&tm, buf); } /*******************************************************************/ static char *cf_format_strtimestamp(struct tm *tm, char *buf) { /* Security checks */ if (tm->tm_year < -2899 || tm->tm_year > 8099) { CfOut(cf_error, "", "Unable to format timestamp: passed year is out of range: %d", tm->tm_year + 1900); return NULL; } /* There is no easy way to replicate ctime output by using strftime */ if (snprintf(buf, 26, "%3.3s %3.3s %2d %02d:%02d:%02d %04d", DAY_TEXT[tm->tm_wday ? (tm->tm_wday - 1) : 6], MONTH_TEXT[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_year + 1900) >= 26) { CfOut(cf_error, "", "Unable to format timestamp: passed values are out of range"); return NULL; } return buf; } /*******************************************************************/ int cf_closesocket(int sd) { int res; #ifdef MINGW res = closesocket(sd); #else res = close(sd); #endif if (res != 0) { CfOut(cf_error,"cf_closesocket","!! Could not close socket"); } return res; } /*******************************************************************/ int cf_mkdir(const char *path, mode_t mode) { #ifdef MINGW return NovaWin_mkdir(path, mode); #else return mkdir(path,mode); #endif } /*******************************************************************/ int cf_chmod(const char *path, mode_t mode) { #ifdef MINGW return NovaWin_chmod(path, mode); #else return chmod(path,mode); #endif } /*******************************************************************/ int cf_rename(const char *oldpath, const char *newpath) { #ifdef MINGW return NovaWin_rename(oldpath, newpath); #else return rename(oldpath,newpath); #endif } /*******************************************************************/ void OpenNetwork() { #ifdef MINGW NovaWin_OpenNetwork(); #else /* no network init on Unix */ #endif } /*******************************************************************/ void CloseNetwork() { #ifdef MINGW NovaWin_CloseNetwork(); #else /* no network close on Unix */ #endif } /*******************************************************************/ void CloseWmi() { #ifdef MINGW NovaWin_WmiDeInitialize(); #else /* no WMI on Unix */ #endif } /*******************************************************************/ #ifdef MINGW // FIXME: Timeouts ignored on windows for now... unsigned int alarm(unsigned int seconds) { return 0; } #endif /* MINGW */ /*******************************************************************/ #ifdef MINGW const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) { if (af == AF_INET) { struct sockaddr_in in; memset(&in, 0, sizeof(in)); in.sin_family = AF_INET; memcpy(&in.sin_addr, src, sizeof(struct in_addr)); getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in), dst, cnt, NULL, 0, NI_NUMERICHOST); return dst; } else if (af == AF_INET6) { struct sockaddr_in6 in; memset(&in, 0, sizeof(in)); in.sin6_family = AF_INET6; memcpy(&in.sin6_addr, src, sizeof(struct in_addr6)); getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in6), dst, cnt, NULL, 0, NI_NUMERICHOST); return dst; } return NULL; } int inet_pton(int af, const char *src, void *dst) { struct addrinfo hints, *res, *ressave; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = af; if (getaddrinfo(src, NULL, &hints, &res) != 0) { CfOut(cf_error,"getaddrinfo", "!! Could not resolve host \"%s\"", src); return -1; } ressave = res; while (res) { memcpy(dst, res->ai_addr, res->ai_addrlen); res = res->ai_next; } freeaddrinfo(ressave); return 0; } #endif /* MINGW */ /*******************************************************************/ int LinkOrCopy(const char *from, const char *to, int sym) /** * Creates symlink to file on platforms supporting it, copies on * others. **/ { #ifdef MINGW // only copy on Windows for now if (!CopyFile(from,to,TRUE)) { return false; } #else /* NOT MINGW */ if(sym) { if (symlink(from,to) == -1) { return false; } } else // hardlink { if(link(from,to) == -1) { return false; } } #endif /* NOT MINGW */ return true; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/pipes.c��������������������������������������������������������������������������0000644�0001750�0001750�00000054437�11715232734�012314� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: pipes.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #ifndef MINGW static FILE *Unix_cf_popen(char *command,char *type); static FILE *Unix_cf_popensetuid(char *command,char *type,uid_t uid,gid_t gid,char *chdirv,char *chrootv); static FILE *Unix_cf_popen_sh(char *command,char *type); static FILE *Unix_cf_popen_shsetuid(char *command,char *type,uid_t uid,gid_t gid,char *chdirv,char *chrootv); static int Unix_cf_pclose(FILE *pp); static int Unix_cf_pclose_def(FILE *pfp,struct Attributes a,struct Promise *pp); static int CfSetuid(uid_t uid,gid_t gid); #endif /*******************************************************************/ /* Pipe API - OS function mapping */ /*******************************************************************/ FILE *cf_popen(char *command,char *type) { #ifdef MINGW return NovaWin_cf_popen(command, type); #else return Unix_cf_popen(command, type); #endif } /*****************************************************************************/ FILE *cf_popensetuid(char *command,char *type,uid_t uid,gid_t gid,char *chdirv,char *chrootv,int background) { #ifdef MINGW return NovaWin_cf_popensetuid(command, type, uid, gid, chdirv, chrootv,background); #else return Unix_cf_popensetuid(command, type, uid, gid, chdirv, chrootv); #endif } /*****************************************************************************/ FILE *cf_popen_sh(char *command,char *type) { #ifdef MINGW return NovaWin_cf_popen_sh(command, type); #else return Unix_cf_popen_sh(command, type); #endif } /*****************************************************************************/ FILE *cf_popen_shsetuid(char *command,char *type,uid_t uid,gid_t gid,char *chdirv,char *chrootv,int background) { #ifdef MINGW return NovaWin_cf_popen_shsetuid(command, type, uid, gid, chdirv, chrootv, background); #else return Unix_cf_popen_shsetuid(command, type, uid, gid, chdirv, chrootv); #endif } /*****************************************************************************/ int cf_pclose(FILE *pp) { #ifdef MINGW return NovaWin_cf_pclose(pp); #else return Unix_cf_pclose(pp); #endif } /*****************************************************************************/ int cf_pclose_def(FILE *pfp,struct Attributes a,struct Promise *pp) { #ifdef MINGW return NovaWin_cf_pclose_def(pfp, a, pp); #else return Unix_cf_pclose_def(pfp, a, pp); #endif } /*******************************************************************/ /* End pipe API */ /*******************************************************************/ int VerifyCommandRetcode(int retcode, int fallback, struct Attributes a, struct Promise *pp) { char retcodeStr[128] = {0}; int result = true; int matched = false; if(a.classes.retcode_kept || a.classes.retcode_repaired || a.classes.retcode_failed) { snprintf(retcodeStr,sizeof(retcodeStr),"%d",retcode); if(KeyInRlist(a.classes.retcode_kept, retcodeStr)) { cfPS(cf_inform,CF_NOP,"",pp,a,"-> Command related to promiser \"%s\" returned code defined as promise kept (%d)", pp->promiser, retcode); result = true; matched = true; } if(KeyInRlist(a.classes.retcode_repaired, retcodeStr)) { cfPS(cf_inform,CF_CHG,"",pp,a,"-> Command related to promiser \"%s\" returned code defined as promise repaired (%d)", pp->promiser, retcode); result = true; matched = true; } if(KeyInRlist(a.classes.retcode_failed, retcodeStr)) { cfPS(cf_inform,CF_FAIL,"",pp,a,"!! Command related to promiser \"%s\" returned code defined as promise failed (%d)", pp->promiser, retcode); result = false; matched = true; } if(!matched) { CfOut(cf_verbose, "", "Command related to promiser \"%s\" returned code %d -- did not match any failed, repaired or kept lists", pp->promiser, retcode); } } else if(fallback) // default: 0 is success, != 0 is failure { if (retcode == 0) { cfPS(cf_verbose,CF_CHG,"",pp,a," -> Finished command related to promiser \"%s\" -- succeeded",pp->promiser); result = true; } else { cfPS(cf_inform,CF_FAIL,"",pp,a," !! Finished command related to promiser \"%s\" -- an error occurred (returned %d)",pp->promiser, retcode); result = false; } } return result; } #ifndef MINGW /*******************************************************************/ /* Unix implementations */ /*******************************************************************/ /*****************************************************************************/ pid_t *CHILDREN; int MAX_FD = 128; /* Max number of simultaneous pipes */ /*****************************************************************************/ static FILE *Unix_cf_popen(char *command,char *type) { static char arg[CF_MAXSHELLARGS][CF_BUFSIZE]; int i, argc, pd[2]; char **argv; pid_t pid; FILE *pp = NULL; Debug("Unix_cf_popen(%s)\n",command); if ((*type != 'r' && *type != 'w') || (type[1] != '\0')) { errno = EINVAL; return NULL; } if (!ThreadLock(cft_count)) { return NULL; } if (CHILDREN == NULL) /* first time */ { if ((CHILDREN = calloc(MAX_FD,sizeof(pid_t))) == NULL) { ThreadUnlock(cft_count); return NULL; } } ThreadUnlock(cft_count); if (pipe(pd) < 0) /* Create a pair of descriptors to this process */ { return NULL; } if ((pid = fork()) == -1) { close(pd[0]); close(pd[1]); return NULL; } signal(SIGCHLD,SIG_DFL); ALARM_PID = (pid != 0 ? pid : -1); if (pid == 0) { switch (*type) { case 'r': close(pd[0]); /* Don't need output from parent */ if (pd[1] != 1) { dup2(pd[1],1); /* Attach pp=pd[1] to our stdout */ dup2(pd[1],2); /* Merge stdout/stderr */ close(pd[1]); } break; case 'w': close(pd[1]); if (pd[0] != 0) { dup2(pd[0],0); close(pd[0]); } } for (i = 0; i < MAX_FD; i++) { if (CHILDREN[i] > 0) { close(i); } } argc = ArgSplitCommand(command,arg); argv = (char **) malloc((argc+1)*sizeof(char *)); if (argv == NULL) { FatalError("Out of memory"); } for (i = 0; i < argc; i++) { argv[i] = arg[i]; } argv[i] = (char *) NULL; if (execv(arg[0],argv) == -1) { CfOut(cf_error,"execv","Couldn't run %s",arg[0]); } free((char *)argv); _exit(1); } else { switch (*type) { case 'r': close(pd[1]); if ((pp = fdopen(pd[0],type)) == NULL) { cf_pwait(pid); return NULL; } break; case 'w': close(pd[0]); if ((pp = fdopen(pd[1],type)) == NULL) { cf_pwait(pid); return NULL; } } if (fileno(pp) >= MAX_FD) { CfOut(cf_error,"","File descriptor %d of child %d higher than MAX_FD in Unix_cf_popen, check for defunct children", fileno(pp), pid); } else { ThreadLock(cft_count); CHILDREN[fileno(pp)] = pid; ThreadUnlock(cft_count); } return pp; } return NULL; /* Cannot reach here */ } /*****************************************************************************/ static FILE *Unix_cf_popensetuid(char *command,char *type,uid_t uid,gid_t gid,char *chdirv,char *chrootv) { static char arg[CF_MAXSHELLARGS][CF_BUFSIZE]; int i, argc, pd[2]; char **argv; pid_t pid; FILE *pp = NULL; Debug("Unix_cf_popensetuid(%s,%s,%d,%d)\n",command,type,uid,gid); if ((*type != 'r' && *type != 'w') || (type[1] != '\0')) { errno = EINVAL; return NULL; } if (!ThreadLock(cft_count)) { return NULL; } if (CHILDREN == NULL) /* first time */ { if ((CHILDREN = calloc(MAX_FD,sizeof(pid_t))) == NULL) { ThreadUnlock(cft_count); return NULL; } } ThreadUnlock(cft_count); if (pipe(pd) < 0) /* Create a pair of descriptors to this process */ { return NULL; } if ((pid = fork()) == -1) { close(pd[0]); close(pd[1]); return NULL; } signal(SIGCHLD,SIG_DFL); ALARM_PID = (pid != 0 ? pid : -1); if (pid == 0) { switch (*type) { case 'r': close(pd[0]); /* Don't need output from parent */ if (pd[1] != 1) { dup2(pd[1],1); /* Attach pp=pd[1] to our stdout */ dup2(pd[1],2); /* Merge stdout/stderr */ close(pd[1]); } break; case 'w': close(pd[1]); if (pd[0] != 0) { dup2(pd[0],0); close(pd[0]); } } for (i = 0; i < MAX_FD; i++) { if (CHILDREN[i] > 0) { close(i); } } argc = ArgSplitCommand(command,arg); argv = (char **) malloc((argc+1)*sizeof(char *)); if (argv == NULL) { FatalError("Out of memory"); } for (i = 0; i < argc; i++) { argv[i] = arg[i]; } argv[i] = (char *) NULL; if (chrootv && strlen(chrootv) != 0) { if (chroot(chrootv) == -1) { CfOut(cf_error,"chroot","Couldn't chroot to %s\n",chrootv); free((char *)argv); return NULL; } } if (chdirv && strlen(chdirv) != 0) { if (chdir(chdirv) == -1) { CfOut(cf_error,"chdir","Couldn't chdir to %s\n",chdirv); free((char *)argv); return NULL; } } if (!CfSetuid(uid,gid)) { free((char *)argv); _exit(1); } if (execv(arg[0],argv) == -1) { CfOut(cf_error,"execv","Couldn't run %s",arg[0]); } free((char *)argv); _exit(1); } else { switch (*type) { case 'r': close(pd[1]); if ((pp = fdopen(pd[0],type)) == NULL) { cf_pwait(pid); return NULL; } break; case 'w': close(pd[0]); if ((pp = fdopen(pd[1],type)) == NULL) { cf_pwait(pid); return NULL; } } if (fileno(pp) >= MAX_FD) { CfOut(cf_error,"","File descriptor %d of child %d higher than MAX_FD in Unix_cf_popensetuid, check for defunct children", fileno(pp), pid); } else { ThreadLock(cft_count); CHILDREN[fileno(pp)] = pid; ThreadUnlock(cft_count); } return pp; } return NULL; /* cannot reach here */ } /*****************************************************************************/ /* Shell versions of commands - not recommended for security reasons */ /*****************************************************************************/ static FILE *Unix_cf_popen_sh(char *command,char *type) { int i,pd[2]; pid_t pid; FILE *pp = NULL; char esc_command[CF_BUFSIZE]; Debug("Unix_cf_popen_sh(%s)\n",command); if ((*type != 'r' && *type != 'w') || (type[1] != '\0')) { errno = EINVAL; return NULL; } if (!ThreadLock(cft_count)) { return NULL; } if (CHILDREN == NULL) /* first time */ { if ((CHILDREN = calloc(MAX_FD,sizeof(pid_t))) == NULL) { ThreadUnlock(cft_count); return NULL; } } ThreadUnlock(cft_count); if (pipe(pd) < 0) /* Create a pair of descriptors to this process */ { return NULL; } if ((pid = fork()) == -1) { close(pd[0]); close(pd[1]); return NULL; } signal(SIGCHLD,SIG_DFL); ALARM_PID = (pid != 0 ? pid : -1); if (pid == 0) { switch (*type) { case 'r': close(pd[0]); /* Don't need output from parent */ if (pd[1] != 1) { dup2(pd[1],1); /* Attach pp=pd[1] to our stdout */ dup2(pd[1],2); /* Merge stdout/stderr */ close(pd[1]); } break; case 'w': close(pd[1]); if (pd[0] != 0) { dup2(pd[0],0); close(pd[0]); } } for (i = 0; i < MAX_FD; i++) { if (CHILDREN[i] > 0) { close(i); } } strncpy(esc_command,ShEscapeCommand(command),CF_BUFSIZE-1); execl("/bin/sh","sh","-c",esc_command,NULL); _exit(1); } else { switch (*type) { case 'r': close(pd[1]); if ((pp = fdopen(pd[0],type)) == NULL) { cf_pwait(pid); return NULL; } break; case 'w': close(pd[0]); if ((pp = fdopen(pd[1],type)) == NULL) { cf_pwait(pid); return NULL; } } if (fileno(pp) >= MAX_FD) { CfOut(cf_error,"","File descriptor %d of child %d higher than MAX_FD in Unix_cf_popen_sh, check for defunct children", fileno(pp), pid); } else { ThreadLock(cft_count); CHILDREN[fileno(pp)] = pid; ThreadUnlock(cft_count); } return pp; } return NULL; } /******************************************************************************/ static FILE *Unix_cf_popen_shsetuid(char *command,char *type,uid_t uid,gid_t gid,char *chdirv,char *chrootv) { int i,pd[2]; pid_t pid; FILE *pp = NULL; char esc_command[CF_BUFSIZE]; Debug("Unix_cf_popen_shsetuid(%s,%s,%d,%d)\n",command,type,uid,gid); if ((*type != 'r' && *type != 'w') || (type[1] != '\0')) { errno = EINVAL; return NULL; } if (!ThreadLock(cft_count)) { return NULL; } if (CHILDREN == NULL) /* first time */ { if ((CHILDREN = calloc(MAX_FD,sizeof(pid_t))) == NULL) { ThreadUnlock(cft_count); return NULL; } } ThreadUnlock(cft_count); if (pipe(pd) < 0) /* Create a pair of descriptors to this process */ { return NULL; } if ((pid = fork()) == -1) { close(pd[0]); close(pd[1]); return NULL; } signal(SIGCHLD,SIG_DFL); ALARM_PID = (pid != 0 ? pid : -1); if (pid == 0) { switch (*type) { case 'r': close(pd[0]); /* Don't need output from parent */ if (pd[1] != 1) { dup2(pd[1],1); /* Attach pp=pd[1] to our stdout */ dup2(pd[1],2); /* Merge stdout/stderr */ close(pd[1]); } break; case 'w': close(pd[1]); if (pd[0] != 0) { dup2(pd[0],0); close(pd[0]); } } for (i = 0; i < MAX_FD; i++) { if (CHILDREN[i] > 0) { close(i); } } if (chrootv && strlen(chrootv) != 0) { if (chroot(chrootv) == -1) { CfOut(cf_error,"chroot","Couldn't chroot to %s\n",chrootv); return NULL; } } if (chdirv && strlen(chdirv) != 0) { if (chdir(chdirv) == -1) { CfOut(cf_error,"chdir","Couldn't chdir to %s\n",chdirv); return NULL; } } if (!CfSetuid(uid,gid)) { _exit(1); } strncpy(esc_command,ShEscapeCommand(command),CF_BUFSIZE-1); execl("/bin/sh","sh","-c",esc_command,NULL); _exit(1); } else { switch (*type) { case 'r': close(pd[1]); if ((pp = fdopen(pd[0],type)) == NULL) { cf_pwait(pid); return NULL; } break; case 'w': close(pd[0]); if ((pp = fdopen(pd[1],type)) == NULL) { cf_pwait(pid); return NULL; } } if (fileno(pp) >= MAX_FD) { CfOut(cf_error,"","File descriptor %d of child %d higher than MAX_FD in Unix_cf_popen_shsetuid, check for defunct children", fileno(pp), pid); cf_pwait(pid); return NULL; } else { ThreadLock(cft_count); CHILDREN[fileno(pp)] = pid; ThreadUnlock(cft_count); } return pp; } return NULL; } /******************************************************************************/ /* Close commands */ /******************************************************************************/ int cf_pwait(pid_t pid) { int status; Debug("cf_pwait - Waiting for process %d\n",pid); #ifdef HAVE_WAITPID while(waitpid(pid,&status,0) < 0) { if (errno != EINTR) { return -1; } } if (!WIFEXITED(status)) { return -1; } return WEXITSTATUS(status); #else while ((wait_result = wait(&status)) != pid) { if (wait_result <= 0) { CfOut(cf_inform,"wait"," !! Wait for child failed\n"); return -1; } } if (WIFSIGNALED(status)) { return -1; } if (!WIFEXITED(status)) { return -1; } return (WEXITSTATUS(status)); #endif } /*******************************************************************/ static int Unix_cf_pclose(FILE *pp) { int fd; pid_t pid; Debug("Unix_cf_pclose(pp)\n"); if (!ThreadLock(cft_count)) { return -1; } if (CHILDREN == NULL) /* popen hasn't been called */ { ThreadUnlock(cft_count); return -1; } ThreadUnlock(cft_count); ALARM_PID = -1; fd = fileno(pp); if (fd >= MAX_FD) { CfOut(cf_error,"","File descriptor %d of child higher than MAX_FD in Unix_cf_pclose, check for defunct children", fd); pid = -1; } else { if ((pid = CHILDREN[fd]) == 0) { return -1; } ThreadLock(cft_count); CHILDREN[fd] = 0; ThreadUnlock(cft_count); } if (fclose(pp) == EOF) { return -1; } return cf_pwait(pid); } /*******************************************************************/ static int Unix_cf_pclose_def(FILE *pfp,struct Attributes a,struct Promise *pp) /** * Defines command failure/success with cfPS based on exit code. */ { int fd, status; pid_t pid; Debug("Unix_cf_pclose_def(pfp)\n"); if (!ThreadLock(cft_count)) { return -1; } if (CHILDREN == NULL) /* popen hasn't been called */ { ThreadUnlock(cft_count); return -1; } ThreadUnlock(cft_count); ALARM_PID = -1; fd = fileno(pfp); if (fd >= MAX_FD) { CfOut(cf_error,"","File descriptor %d of child higher than MAX_FD in Unix_cf_pclose_def, check for defunct children", fd); fclose(pfp); return -1; } if ((pid = CHILDREN[fd]) == 0) { return -1; } ThreadLock(cft_count); CHILDREN[fd] = 0; ThreadUnlock(cft_count); if (fclose(pfp) == EOF) { return -1; } Debug("Unix_cf_pclose_def - Waiting for process %d\n",pid); #ifdef HAVE_WAITPID while(waitpid(pid,&status,0) < 0) { if (errno != EINTR) { return -1; } } if (!WIFEXITED(status)) { cfPS(cf_inform,CF_FAIL,"",pp,a," !! Finished script \"%s\" - failed (abnormal termination)",pp->promiser); return -1; } VerifyCommandRetcode(WEXITSTATUS(status),true,a,pp); return status; #else while ((wait_result = wait(&status)) != pid) { if (wait_result <= 0) { CfOut(cf_inform,"wait","Wait for child failed\n"); return -1; } } if (WIFSIGNALED(status)) { cfPS(cf_inform,CF_INTERPT,"",pp,a," -> Finished script - interrupted %s\n",pp->promiser); return -1; } if (!WIFEXITED(status)) { cfPS(cf_inform,CF_FAIL,"",pp,a," !! Finished script \"%s\" - failed (abnormal termination)",pp->promiser); return -1; } VerifyCommandRetcode(WEXITSTATUS(status),true,a,pp); return (WEXITSTATUS(status)); #endif } /*******************************************************************/ static int CfSetuid(uid_t uid,gid_t gid) { struct passwd *pw; if (gid != (gid_t) -1) { CfOut(cf_verbose,"","Changing gid to %d\n",gid); if (setgid(gid) == -1) { CfOut(cf_error,"setgid","Couldn't set gid to %d\n",gid); return false; } /* Now eliminate any residual privileged groups */ if ((pw = getpwuid(uid)) == NULL) { CfOut(cf_error,"getpwuid","Unable to get login groups when dropping privilege to %d",uid); return false; } if (initgroups(pw->pw_name, pw->pw_gid) == -1) { CfOut(cf_error,"initgroups","Unable to set login groups when dropping privilege to %s=%d",pw->pw_name,uid); return false; } } if (uid != (uid_t) -1) { CfOut(cf_verbose,"","Changing uid to %d\n",uid); if (setuid(uid) == -1) { CfOut(cf_error,"setuid","Couldn't set uid to %d\n",uid); return false; } } return true; } #endif /* NOT MINGW */ ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/files_select.c�������������������������������������������������������������������0000644�0001750�0001750�00000034521�11715232734�013625� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: files_select.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int SelectTypeMatch(struct stat *lstatptr,struct Rlist *crit); static int SelectOwnerMatch(char *path,struct stat *lstatptr,struct Rlist *crit); static int SelectModeMatch(struct stat *lstatptr,struct Rlist *ls); static int SelectTimeMatch(time_t stattime,time_t fromtime,time_t totime); static int SelectNameRegexMatch(const char *filename,char *crit); static int SelectPathRegexMatch(char *filename,char *crit); static int SelectExecRegexMatch(char *filename,char *crit,char *prog); static int SelectIsSymLinkTo(char *filename,struct Rlist *crit); static int SelectExecProgram(char *filename,char *command); static int SelectSizeMatch(size_t size,size_t min,size_t max); static int SelectBSDMatch(struct stat *lstatptr,struct Rlist *bsdflags,struct Promise *pp); #ifndef MINGW static int Unix_GetOwnerName(struct stat *lstatptr, char *owner, int ownerSz); static int SelectGroupMatch(struct stat *lstatptr,struct Rlist *crit); #endif int SelectLeaf(char *path,struct stat *sb,struct Attributes attr,struct Promise *pp) { struct AlphaList leaf_attr; int result = true; struct Rlist *rp; InitAlphaList(&leaf_attr); #ifdef MINGW if(attr.select.issymlinkto != NULL) { CfOut(cf_verbose, "", "files_select.issymlinkto is ignored on Windows (symbolic links are not supported by Windows)"); } if(attr.select.groups != NULL) { CfOut(cf_verbose, "", "files_select.search_groups is ignored on Windows (file groups are not supported by Windows)"); } if(attr.select.bsdflags != NULL) { CfOut(cf_verbose, "", "files_select.search_bsdflags is ignored on Windows"); } #endif /* MINGW */ if (!attr.haveselect) { return true; } if (attr.select.name == NULL) { PrependAlphaList(&leaf_attr,"leaf_name"); } for (rp = attr.select.name; rp != NULL; rp = rp->next) { if (SelectNameRegexMatch(path,rp->item)) { PrependAlphaList(&leaf_attr,"leaf_name"); break; } } if (attr.select.path == NULL) { PrependAlphaList(&leaf_attr,"leaf_path"); } for (rp = attr.select.path; rp != NULL; rp = rp->next) { if (SelectPathRegexMatch(path,rp->item)) { PrependAlphaList(&leaf_attr,"path_name"); break; } } if (SelectTypeMatch(sb,attr.select.filetypes)) { PrependAlphaList(&leaf_attr,"file_types"); } if (attr.select.owners && SelectOwnerMatch(path,sb,attr.select.owners)) { PrependAlphaList(&leaf_attr,"owner"); } if (attr.select.owners == NULL) { PrependAlphaList(&leaf_attr,"owner"); } #ifdef MINGW PrependAlphaList(&leaf_attr,"group"); #else /* NOT MINGW */ if (attr.select.groups && SelectGroupMatch(sb,attr.select.groups)) { PrependAlphaList(&leaf_attr,"group"); } if (attr.select.groups == NULL) { PrependAlphaList(&leaf_attr,"group"); } #endif /* NOT MINGW */ if (SelectModeMatch(sb,attr.select.perms)) { PrependAlphaList(&leaf_attr,"mode"); } #if defined HAVE_CHFLAGS if (SelectBSDMatch(sb,attr.select.bsdflags,pp)) { PrependAlphaList(&leaf_attr,"bsdflags"); } #endif if (SelectTimeMatch(sb->st_atime,attr.select.min_atime,attr.select.max_atime)) { PrependAlphaList(&leaf_attr,"atime"); } if (SelectTimeMatch(sb->st_ctime,attr.select.min_ctime,attr.select.max_ctime)) { PrependAlphaList(&leaf_attr,"ctime"); } if (SelectSizeMatch(sb->st_size,attr.select.min_size,attr.select.max_size)) { PrependAlphaList(&leaf_attr,"size"); } if (SelectTimeMatch(sb->st_mtime,attr.select.min_mtime,attr.select.max_mtime)) { PrependAlphaList(&leaf_attr,"mtime"); } if (attr.select.issymlinkto && SelectIsSymLinkTo(path,attr.select.issymlinkto)) { PrependAlphaList(&leaf_attr,"issymlinkto"); } if (attr.select.exec_regex && SelectExecRegexMatch(path,attr.select.exec_regex,attr.select.exec_program)) { PrependAlphaList(&leaf_attr,"exec_regex"); } if (attr.select.exec_program && SelectExecProgram(path,attr.select.exec_program)) { PrependAlphaList(&leaf_attr,"exec_program"); } if ((result = EvalFileResult(attr.select.result,&leaf_attr))) { //NewClassesFromString(fp->defines); } Debug("Select result \"%s\"on %s was %d\n",attr.select.result,path,result); DeleteAlphaList(&leaf_attr); return result; } /*******************************************************************/ /* Level */ /*******************************************************************/ static int SelectSizeMatch(size_t size,size_t min,size_t max) { if (size <= max && size >= min) { return true; } return false; } /*******************************************************************/ static int SelectTypeMatch(struct stat *lstatptr,struct Rlist *crit) { struct AlphaList leafattrib; struct Rlist *rp; InitAlphaList(&leafattrib); if (S_ISREG(lstatptr->st_mode)) { PrependAlphaList(&leafattrib,"reg"); PrependAlphaList(&leafattrib,"plain"); } if (S_ISDIR(lstatptr->st_mode)) { PrependAlphaList(&leafattrib,"dir"); } #ifndef MINGW if (S_ISLNK(lstatptr->st_mode)) { PrependAlphaList(&leafattrib,"symlink"); } if (S_ISFIFO(lstatptr->st_mode)) { PrependAlphaList(&leafattrib,"fifo"); } if (S_ISSOCK(lstatptr->st_mode)) { PrependAlphaList(&leafattrib,"socket"); } if (S_ISCHR(lstatptr->st_mode)) { PrependAlphaList(&leafattrib,"char"); } if (S_ISBLK(lstatptr->st_mode)) { PrependAlphaList(&leafattrib,"block"); } #endif /* NOT MINGW */ #ifdef HAVE_DOOR_CREATE if (S_ISDOOR(lstatptr->st_mode)) { PrependAlphaList(&leafattrib,"door"); } #endif for (rp = crit; rp != NULL; rp=rp->next) { if (EvalFileResult((char *)rp->item,&leafattrib)) { DeleteAlphaList(&leafattrib); return true; } } DeleteAlphaList(&leafattrib); return false; } /*******************************************************************/ /* Writes the owner of file 'path', with stat 'lstatptr' into buffer 'owner' of * size 'ownerSz'. Returns true on success, false otherwise */ int GetOwnerName(char *path, struct stat *lstatptr, char *owner, int ownerSz) { #ifdef MINGW return NovaWin_GetOwnerName(path, owner, ownerSz); #else /* NOT MINGW */ return Unix_GetOwnerName(lstatptr, owner, ownerSz); #endif /* NOT MINGW */ } /*******************************************************************/ static int SelectOwnerMatch(char *path,struct stat *lstatptr,struct Rlist *crit) { struct AlphaList leafattrib; struct Rlist *rp; char ownerName[CF_BUFSIZE]; int gotOwner; InitAlphaList(&leafattrib); #ifndef MINGW // no uids on Windows char buffer[CF_SMALLBUF]; sprintf(buffer,"%d",lstatptr->st_uid); PrependAlphaList(&leafattrib,buffer); #endif /* MINGW */ gotOwner = GetOwnerName(path, lstatptr, ownerName, sizeof(ownerName)); if (gotOwner) { PrependAlphaList(&leafattrib,ownerName); } else { PrependAlphaList(&leafattrib,"none"); } for (rp = crit; rp != NULL; rp = rp->next) { if (EvalFileResult((char *)rp->item,&leafattrib)) { Debug(" - ? Select owner match\n"); DeleteAlphaList(&leafattrib); return true; } if (gotOwner && FullTextMatch((char *)rp->item,ownerName)) { Debug(" - ? Select owner match\n"); DeleteAlphaList(&leafattrib); return true; } #ifndef MINGW if (FullTextMatch((char *)rp->item,buffer)) { Debug(" - ? Select owner match\n"); DeleteAlphaList(&leafattrib); return true; } #endif /* NOT MINGW */ } DeleteAlphaList(&leafattrib); return false; } /*******************************************************************/ static int SelectModeMatch(struct stat *lstatptr,struct Rlist *list) { mode_t newperm,plus,minus; struct Rlist *rp; for (rp = list; rp != NULL; rp=rp->next) { plus = 0; minus = 0; if (!ParseModeString(rp->item,&plus,&minus)) { CfOut(cf_error,""," !! Problem validating a mode string \"%s\" in search filter",rp->item); continue; } newperm = (lstatptr->st_mode & 07777); newperm |= plus; newperm &= ~minus; if ((newperm & 07777) == (lstatptr->st_mode & 07777)) { return true; } } return false; } /*******************************************************************/ static int SelectBSDMatch(struct stat *lstatptr,struct Rlist *bsdflags,struct Promise *pp) { #if defined HAVE_CHFLAGS u_long newflags,plus,minus; struct Rlist *rp; if (!ParseFlagString(bsdflags,&plus,&minus)) { CfOut(cf_error,""," !! Problem validating a BSD flag string"); PromiseRef(cf_error,pp); } newflags = (lstatptr->st_flags & CHFLAGS_MASK) ; newflags |= plus; newflags &= ~minus; if ((newflags & CHFLAGS_MASK) == (lstatptr->st_flags & CHFLAGS_MASK)) /* file okay */ { return true; } #endif return false; } /*******************************************************************/ static int SelectTimeMatch(time_t stattime,time_t fromtime,time_t totime) { return ((fromtime < stattime) && (stattime < totime)); } /*******************************************************************/ static int SelectNameRegexMatch(const char *filename,char *crit) { if (FullTextMatch(crit,ReadLastNode(filename))) { return true; } return false; } /*******************************************************************/ static int SelectPathRegexMatch(char *filename,char *crit) { if (FullTextMatch(crit,filename)) { return true; } return false; } /*******************************************************************/ static int SelectExecRegexMatch(char *filename,char *crit,char *prog) { char line[CF_BUFSIZE]; FILE *pp; char buf[CF_MAXVARSIZE]; // insert real value of $(this.promiser) in command ReplaceStr(prog,buf,sizeof(buf),"$(this.promiser)",filename); ReplaceStr(prog,buf,sizeof(buf),"${this.promiser}",filename); if ((pp = cf_popen(buf,"r")) == NULL) { CfOut(cf_error,"cf_popen","Couldn't open pipe to command %s\n",buf); return false; } while (!feof(pp)) { line[0] = '\0'; CfReadLine(line,CF_BUFSIZE,pp); /* One buffer only */ if (FullTextMatch(crit,line)) { cf_pclose(pp); return true; } } cf_pclose(pp); return false; } /*******************************************************************/ static int SelectIsSymLinkTo(char *filename,struct Rlist *crit) { #ifndef MINGW char buffer[CF_BUFSIZE]; struct Rlist *rp; for (rp = crit; rp != NULL; rp = rp->next) { memset(buffer,0,CF_BUFSIZE); if (readlink(filename,buffer,CF_BUFSIZE-1) == -1) { CfOut(cf_error,"readlink","Unable to read link %s in filter",filename); return false; } if (FullTextMatch(rp->item,buffer)) { return true; } } #endif /* NOT MINGW */ return false; } /*******************************************************************/ static int SelectExecProgram(char *filename,char *command) /* command can include $(this.promiser) for the name of the file */ { char buf[CF_MAXVARSIZE]; // insert real value of $(this.promiser) in command ReplaceStr(command,buf,sizeof(buf),"$(this.promiser)",filename); ReplaceStr(command,buf,sizeof(buf),"${this.promiser}",filename); if (ShellCommandReturnsZero(buf,false)) { Debug(" - ? Select ExecProgram match for %s\n",buf); return true; } else { return false; } } #ifndef MINGW /*******************************************************************/ /* Unix implementations */ /*******************************************************************/ static int Unix_GetOwnerName(struct stat *lstatptr, char *owner, int ownerSz) { struct passwd *pw; memset(owner, 0, ownerSz); pw = getpwuid(lstatptr->st_uid); if(pw == NULL) { CfOut(cf_error, "getpwuid", "!! Could not get owner name of user with uid=%d", lstatptr->st_uid); return false; } strncpy(owner, pw->pw_name, ownerSz - 1); return true; } /*******************************************************************/ static int SelectGroupMatch(struct stat *lstatptr,struct Rlist *crit) { struct AlphaList leafattrib; char buffer[CF_SMALLBUF]; struct group *gr; struct Rlist *rp; InitAlphaList(&leafattrib); sprintf(buffer,"%d",lstatptr->st_gid); PrependAlphaList(&leafattrib,buffer); if ((gr = getgrgid(lstatptr->st_gid)) != NULL) { PrependAlphaList(&leafattrib,gr->gr_name); } else { PrependAlphaList(&leafattrib,"none"); } for (rp = crit; rp != NULL; rp = rp->next) { if (EvalFileResult((char *)rp->item,&leafattrib)) { Debug(" - ? Select group match\n"); DeleteAlphaList(&leafattrib); return true; } if (gr && FullTextMatch((char *)rp->item,gr->gr_name)) { Debug(" - ? Select owner match\n"); DeleteAlphaList(&leafattrib); return true; } if (FullTextMatch((char *)rp->item,buffer)) { Debug(" - ? Select owner match\n"); DeleteAlphaList(&leafattrib); return true; } } DeleteAlphaList(&leafattrib); return false; } #endif /* NOT MINGW */ �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/dir.c����������������������������������������������������������������������������0000644�0001750�0001750�00000013356�11715232734�011745� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#include "cf3.defs.h" #include "cf3.extern.h" static size_t GetNameMax(DIR *dirp); static size_t GetDirentBufferSize(size_t path_len); static void CloseDirRemote(CFDIR *dir); void CloseDirLocal(CFDIR *dir); const struct dirent *ReadDirLocal(CFDIR *dir); /*********************************************************************/ CFDIR *OpenDirForPromise(const char *dirname, struct Attributes attr, struct Promise *pp) { if (attr.copy.servers == NULL || strcmp(attr.copy.servers->item,"localhost") == 0) { return OpenDirLocal(dirname); } else { /* -> client_code.c to talk to server */ return OpenDirRemote(dirname, attr, pp); } } /*********************************************************************/ #ifndef MINGW CFDIR *OpenDirLocal(const char *dirname) { CFDIR *ret; if ((ret = calloc(1, sizeof(CFDIR))) == NULL) { FatalError("Unable to allocate memory for CFDIR"); } DIR *dirh; ret->dirh = dirh = opendir(dirname); if (dirh == NULL) { free(ret); return NULL; } size_t dirent_buf_size = GetDirentBufferSize(GetNameMax(dirh)); if (dirent_buf_size == (size_t)-1) { FatalError("Unable to determine directory entry buffer size for directory %s", dirname); } if ((ret->entrybuf = calloc(1, dirent_buf_size)) == NULL) { FatalError("Unable to allocate memory for directory entry buffer for directory %s", dirname); } return ret; } #endif /*********************************************************************/ static const struct dirent *ReadDirRemote(CFDIR *dir) { const char *ret = NULL; if (dir->listpos != NULL) { ret = dir->listpos->name; dir->listpos = dir->listpos->next; } return (struct dirent*)ret; } /*********************************************************************/ #ifndef MINGW /* * Returns NULL on EOF or error. * * Sets errno to 0 for EOF and non-0 for error. */ const struct dirent *ReadDirLocal(CFDIR *dir) { int err; struct dirent *ret; errno = 0; err = readdir_r((DIR *)dir->dirh, dir->entrybuf, &ret); if (err != 0) { errno = err; return NULL; } if (ret == NULL) { return NULL; } return ret; } #endif /*********************************************************************/ const struct dirent *ReadDir(CFDIR *dir) { if (dir->list) { return ReadDirRemote(dir); } else if (dir->dirh) { return ReadDirLocal(dir); } else { FatalError("CFDIR passed has no list nor directory handle open"); } } /*********************************************************************/ void CloseDir(CFDIR *dir) { if (dir->dirh) { CloseDirLocal(dir); } else { CloseDirRemote(dir); } } /*********************************************************************/ static void CloseDirRemote(CFDIR *dir) { if (dir->list) { DeleteItemList(dir->list); } free(dir); } /*********************************************************************/ #ifndef MINGW void CloseDirLocal(CFDIR *dir) { closedir((DIR *)dir->dirh); free(dir->entrybuf); free(dir); } #endif /*********************************************************************/ #ifndef MINGW /* * Taken from http://womble.decadent.org.uk/readdir_r-advisory.html * * Issued by Ben Hutchings <ben@decadent.org.uk>, 2005-11-02. * * Licence * * 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 condition: * * 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. */ /* * Calculate the required buffer size (in bytes) for directory entries read from * the given directory handle. Return -1 if this this cannot be done. * * This code does not trust values of NAME_MAX that are less than 255, since * some systems (including at least HP-UX) incorrectly define it to be a smaller * value. * * If you use autoconf, include fpathconf and dirfd in your AC_CHECK_FUNCS list. * Otherwise use some other method to detect and use them where available. */ #if defined(HAVE_FPATHCONF) && defined(_PC_NAME_MAX) static size_t GetNameMax(DIR *dirp) { long name_max = fpathconf(dirfd(dirp), _PC_NAME_MAX); if (name_max != -1) { return name_max; } #if defined(NAME_MAX) return (NAME_MAX > 255) ? NAME_MAX : 255; #else return (size_t)(-1); #endif } #else /* FPATHCONF && _PC_NAME_MAX */ # if defined(NAME_MAX) static size_t GetNameMax(DIR *dirp) { return (NAME_MAX > 255) ? NAME_MAX : 255; } # else # error "buffer size for readdir_r cannot be determined" # endif #endif /* FPATHCONF && _PC_NAME_MAX */ /*********************************************************************/ /* * Returns size of memory enough to hold path name_len bytes long. */ static size_t GetDirentBufferSize(size_t name_len) { size_t name_end = (size_t)offsetof(struct dirent, d_name) + name_len + 1; return (name_end > sizeof(struct dirent) ? name_end : sizeof(struct dirent)); } /*********************************************************************/ struct dirent *AllocateDirentForFilename(const char *filename) { struct dirent *entry = calloc(1, GetDirentBufferSize(strlen(filename))); strcpy(entry->d_name, filename); return entry; } #endif ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/sort.c���������������������������������������������������������������������������0000644�0001750�0001750�00000040561�11715232734�012154� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*****************************************************************************/ /* */ /* File: sort.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*******************************************************************/ /* The following sort functions are trivial rewrites of merge-sort * implementation by Simon Tatham * copyright 2001 Simon Tatham. * * 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 SIMON TATHAM 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. */ struct Item *SortItemListNames(struct Item *list) /* Alphabetical */ { struct Item *p, *q, *e, *tail, *oldhead; int insize, nmerges, psize, qsize, i; if (list == NULL) { return NULL; } insize = 1; while (true) { p = list; oldhead = list; /* only used for circular linkage */ list = NULL; tail = NULL; nmerges = 0; /* count number of merges we do in this pass */ while (p) { nmerges++; /* there exists a merge to be done */ /* step `insize' places along from p */ q = p; psize = 0; for (i = 0; i < insize; i++) { psize++; q = q->next; if (!q) { break; } } /* if q hasn't fallen off end, we have two lists to merge */ qsize = insize; /* now we have two lists; merge them */ while (psize > 0 || (qsize > 0 && q)) { /* decide whether next element of merge comes from p or q */ if (psize == 0) { /* p is empty; e must come from q. */ e = q; q = q->next; qsize--; } else if (qsize == 0 || !q) { /* q is empty; e must come from p. */ e = p; p = p->next; psize--; } else if (strcmp(p->name, q->name) <= 0) { /* First element of p is lower (or same); * e must come from p. */ e = p; p = p->next; psize--; } else { /* First element of q is lower; e must come from q. */ e = q; q = q->next; qsize--; } /* add the next element to the merged list */ if (tail) { tail->next = e; } else { list = e; } tail = e; } /* now p has stepped `insize' places along, and q has too */ p = q; } tail->next = NULL; /* If we have done only one merge, we're finished. */ if (nmerges <= 1) /* allow for nmerges==0, the empty list case */ { return list; } /* Otherwise repeat, merging lists twice the size */ insize *= 2; } } /*******************************************************************/ struct Item *SortItemListClasses(struct Item *list) /* Alphabetical */ { struct Item *p, *q, *e, *tail, *oldhead; int insize, nmerges, psize, qsize, i; if (list == NULL) { return NULL; } insize = 1; while (true) { p = list; oldhead = list; /* only used for circular linkage */ list = NULL; tail = NULL; nmerges = 0; /* count number of merges we do in this pass */ while (p) { nmerges++; /* there exists a merge to be done */ /* step `insize' places along from p */ q = p; psize = 0; for (i = 0; i < insize; i++) { psize++; q = q->next; if (!q) { break; } } /* if q hasn't fallen off end, we have two lists to merge */ qsize = insize; /* now we have two lists; merge them */ while (psize > 0 || (qsize > 0 && q)) { /* decide whether next element of merge comes from p or q */ if (psize == 0) { /* p is empty; e must come from q. */ e = q; q = q->next; qsize--; } else if (qsize == 0 || !q) { /* q is empty; e must come from p. */ e = p; p = p->next; psize--; } else if (strcmp(p->classes, q->classes) <= 0) { /* First element of p is lower (or same); * e must come from p. */ e = p; p = p->next; psize--; } else { /* First element of q is lower; e must come from q. */ e = q; q = q->next; qsize--; } /* add the next element to the merged list */ if (tail) { tail->next = e; } else { list = e; } tail = e; } /* now p has stepped `insize' places along, and q has too */ p = q; } tail->next = NULL; /* If we have done only one merge, we're finished. */ if (nmerges <= 1) /* allow for nmerges==0, the empty list case */ { return list; } /* Otherwise repeat, merging lists twice the size */ insize *= 2; } } /*******************************************************************/ struct Item *SortItemListCounters(struct Item *list) /* Biggest first */ { struct Item *p, *q, *e, *tail, *oldhead; int insize, nmerges, psize, qsize, i; if (list == NULL) { return NULL; } insize = 1; while (true) { p = list; oldhead = list; /* only used for circular linkage */ list = NULL; tail = NULL; nmerges = 0; /* count number of merges we do in this pass */ while (p) { nmerges++; /* there exists a merge to be done */ /* step `insize' places along from p */ q = p; psize = 0; for (i = 0; i < insize; i++) { psize++; q = q->next; if (!q) { break; } } /* if q hasn't fallen off end, we have two lists to merge */ qsize = insize; /* now we have two lists; merge them */ while (psize > 0 || (qsize > 0 && q)) { /* decide whether next element of merge comes from p or q */ if (psize == 0) { /* p is empty; e must come from q. */ e = q; q = q->next; qsize--; } else if (qsize == 0 || !q) { /* q is empty; e must come from p. */ e = p; p = p->next; psize--; } else if (p->counter - q->counter >= 0) { /* First element of p is higher (or same); * e must come from p. */ e = p; p = p->next; psize--; } else { /* First element of q is lower; e must come from q. */ e = q; q = q->next; qsize--; } /* add the next element to the merged list */ if (tail) { tail->next = e; } else { list = e; } tail = e; } /* now p has stepped `insize' places along, and q has too */ p = q; } tail->next = NULL; /* If we have done only one merge, we're finished. */ if (nmerges <= 1) /* allow for nmerges==0, the empty list case */ { return list; } /* Otherwise repeat, merging lists twice the size */ insize *= 2; } } /*******************************************************************/ struct Item *SortItemListTimes(struct Item *list) /* Biggest first */ { struct Item *p, *q, *e, *tail, *oldhead; int insize, nmerges, psize, qsize, i; if (list == NULL) { return NULL; } insize = 1; while (true) { p = list; oldhead = list; /* only used for circular linkage */ list = NULL; tail = NULL; nmerges = 0; /* count number of merges we do in this pass */ while (p) { nmerges++; /* there exists a merge to be done */ /* step `insize' places along from p */ q = p; psize = 0; for (i = 0; i < insize; i++) { psize++; q = q->next; if (!q) { break; } } /* if q hasn't fallen off end, we have two lists to merge */ qsize = insize; /* now we have two lists; merge them */ while (psize > 0 || (qsize > 0 && q)) { /* decide whether next element of merge comes from p or q */ if (psize == 0) { /* p is empty; e must come from q. */ e = q; q = q->next; qsize--; } else if (qsize == 0 || !q) { /* q is empty; e must come from p. */ e = p; p = p->next; psize--; } else if (p->time - q->time >= 0) { /* First element of p is higher (or same); * e must come from p. */ e = p; p = p->next; psize--; } else { /* First element of q is lower; e must come from q. */ e = q; q = q->next; qsize--; } /* add the next element to the merged list */ if (tail) { tail->next = e; } else { list = e; } tail = e; } /* now p has stepped `insize' places along, and q has too */ p = q; } tail->next = NULL; /* If we have done only one merge, we're finished. */ if (nmerges <= 1) /* allow for nmerges==0, the empty list case */ { return list; } /* Otherwise repeat, merging lists twice the size */ insize *= 2; } } /*******************************************************************/ struct Rlist *SortRlist(struct Rlist *list, int (*CompareItems)()) /** * Sorts an Rlist on list->item. A function CompareItems(i1,i2) * must be written for this particular item, which returns * true if i1 <= i2, false otherwise. **/ { struct Rlist *p = NULL, *q = NULL, *e = NULL, *tail = NULL, *oldhead = NULL; int insize = 0, nmerges = 0, psize = 0, qsize = 0, i = 0; if (list == NULL) { return NULL; } insize = 1; while (true) { p = list; oldhead = list; /* only used for circular linkage */ list = NULL; tail = NULL; nmerges = 0; /* count number of merges we do in this pass */ while (p) { nmerges++; /* there exists a merge to be done */ /* step `insize' places along from p */ q = p; psize = 0; for (i = 0; i < insize; i++) { psize++; q = q->next; if (!q) { break; } } /* if q hasn't fallen off end, we have two lists to merge */ qsize = insize; /* now we have two lists; merge them */ while (psize > 0 || (qsize > 0 && q)) { /* decide whether next element of merge comes from p or q */ if (psize == 0) { /* p is empty; e must come from q. */ e = q; q = q->next; qsize--; } else if (qsize == 0 || !q) { /* q is empty; e must come from p. */ e = p; p = p->next; psize--; } else if (CompareItems(p->item,q->item)) { /* First element of p is lower (or same); * e must come from p. */ e = p; p = p->next; psize--; } else { /* First element of q is lower; e must come from q. */ e = q; q = q->next; qsize--; } /* add the next element to the merged list */ if (tail) { tail->next = e; } else { list = e; } tail = e; } /* now p has stepped `insize' places along, and q has too */ p = q; } tail->next = NULL; /* If we have done only one merge, we're finished. */ if (nmerges <= 1) /* allow for nmerges==0, the empty list case */ { return list; } /* Otherwise repeat, merging lists twice the size */ insize *= 2; } } /*******************************************************************/ struct Rlist *AlphaSortRListNames(struct Rlist *list) /* Borrowed this algorithm from merge-sort implementation */ { struct Rlist *p, *q, *e, *tail, *oldhead; int insize, nmerges, psize, qsize, i; if (list == NULL) { return NULL; } insize = 1; while (true) { p = list; oldhead = list; /* only used for circular linkage */ list = NULL; tail = NULL; nmerges = 0; /* count number of merges we do in this pass */ while (p) { nmerges++; /* there exists a merge to be done */ /* step `insize' places along from p */ q = p; psize = 0; for (i = 0; i < insize; i++) { psize++; q = q->next; if (!q) { break; } } /* if q hasn't fallen off end, we have two lists to merge */ qsize = insize; /* now we have two lists; merge them */ while (psize > 0 || (qsize > 0 && q)) { /* decide whether next element of merge comes from p or q */ if (psize == 0) { /* p is empty; e must come from q. */ e = q; q = q->next; qsize--; } else if (qsize == 0 || !q) { /* q is empty; e must come from p. */ e = p; p = p->next; psize--; } else if (strcmp(p->item, q->item) <= 0) { /* First element of p is lower (or same); * e must come from p. */ e = p; p = p->next; psize--; } else { /* First element of q is lower; e must come from q. */ e = q; q = q->next; qsize--; } /* add the next element to the merged list */ if (tail) { tail->next = e; } else { list = e; } tail = e; } /* now p has stepped `insize' places along, and q has too */ p = q; } tail->next = NULL; /* If we have done only one merge, we're finished. */ if (nmerges <= 1) /* allow for nmerges==0, the empty list case */ { return list; } /* Otherwise repeat, merging lists twice the size */ insize *= 2; } } �����������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/syntax.c�������������������������������������������������������������������������0000644�0001750�0001750�00000070607�11715232734�012517� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: syntax.c */ /* */ /* Created: Wed Aug 8 14:01:42 2007 */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int CheckParseString(char *lv,char *s,char *range); static void CheckParseInt(char *lv,char *s,char *range); static void CheckParseReal(char *lv,char *s,char *range); static void CheckParseRealRange(char *lval,char *s,char *range); static void CheckParseIntRange(char *lval,char *s,char *range); static void CheckParseOpts(char *lv,char *s,char *range); static void CheckFnCallType(char *lval,const char *s,enum cfdatatype dtype,char *range); /*********************************************************/ void CheckBundle(char *name,char *type) { struct Bundle *bp; char output[CF_BUFSIZE]; const char *reserved[] = { "sys", "const", "mon", "edit", "match", "mon", "this", NULL }; Debug("Checking for bundle (%s,%s)\n",name,type); if (IsStrIn(name,reserved)) { snprintf(output,CF_BUFSIZE,"Use of a reserved context as a bundle name \"%s\" ",name); ReportError(output); } for (bp = BUNDLES; bp != NULL; bp=bp->next) { if ((strcmp(name,bp->name) == 0) && (strcmp(type,bp->type) == 0)) { snprintf(output,CF_BUFSIZE,"Redefinition of bundle %s for %s is a broken promise",name,type); ReportError(output); ERRORCOUNT++; } } } /*********************************************************/ void CheckBody(char *name,char *type) { struct Body *bp; char output[CF_BUFSIZE]; for (bp = BODIES; bp != NULL; bp=bp->next) { if ((strcmp(name,bp->name) == 0) && (strcmp(type,bp->type) == 0)) { snprintf(output,CF_BUFSIZE,"Redefinition of body \"%s\" for \"%s\" is a broken promise",name,type); ReportError(output); ERRORCOUNT++; } } } /*********************************************************/ struct SubTypeSyntax CheckSubType(char *bundletype,char *subtype) { int i,j; struct SubTypeSyntax *ss; char output[CF_BUFSIZE]; if (subtype == NULL) { snprintf(output,CF_BUFSIZE,"Missing promise type category for %s bundle",bundletype); ReportError(output); return CF_NOSTYPE; } for (i = 0; i < CF3_MODULES; i++) { if ((ss = CF_ALL_SUBTYPES[i]) == NULL) { continue; } for (j = 0; ss[j].btype != NULL; j++) { if (subtype && strcmp(subtype,ss[j].subtype) == 0) { if ((strcmp(bundletype,ss[j].btype) == 0) || (strcmp("*",ss[j].btype) == 0)) { /* Return a pointer to bodies for this subtype */ Debug("Subtype %s syntax ok for %s\n",subtype,bundletype); return ss[j]; } } } } snprintf(output,CF_BUFSIZE,"%s is not a valid type category for %s bundle",subtype,bundletype); ReportError(output); snprintf(output,CF_BUFSIZE,"Possibly the bundle type \"%s\" itself is undefined",bundletype); ReportError(output); return CF_NOSTYPE; } /*********************************************************/ enum cfdatatype ExpectedDataType(char *lvalname) { int i,j,k; struct BodySyntax *bs; struct SubTypeSyntax *ss; for (i = 0; i < CF3_MODULES; i++) { if ((ss = CF_ALL_SUBTYPES[i]) == NULL) { continue; } for (j = 0; ss[j].subtype != NULL; j++) { if ((bs = ss[j].bs) == NULL) { continue; } for (k = 0; bs[k].range != NULL; k++) { if (strcmp(lvalname,bs[k].lval) == 0) { return bs[k].dtype; } } } } return cf_notype; } /*********************************************************/ void CheckConstraint(char *type,char *name,char *lval,void *rval,char rvaltype,struct SubTypeSyntax ss) { int lmatch = false; int i,l, allowed = false; struct BodySyntax *bs; char output[CF_BUFSIZE]; Debug("CheckConstraint(%s,%s,",type,lval); if (DEBUG) { ShowRval(stdout,rval,rvaltype); } Debug(")\n"); if (ss.subtype != NULL) /* In a bundle */ { if (strcmp(ss.subtype,type) == 0) { Debug("Found type %s's body syntax\n",type); bs = ss.bs; for (l = 0; bs[l].lval != NULL; l++) { Debug1("CMP-bundle # (%s,%s)\n",lval,bs[l].lval); if (strcmp(lval,bs[l].lval) == 0) { /* If we get here we have found the lval and it is valid for this subtype */ lmatch = true; Debug("Matched syntatically correct bundle (lval,rval) item = (%s) to its rval\n",lval); if (bs[l].dtype == cf_body) { Debug("Constraint syntax ok, but definition of body is elsewhere %s=%c\n",lval,rvaltype); PrependRlist(&BODYPARTS,rval,rvaltype); return; } else if (bs[l].dtype == cf_bundle) { Debug("Constraint syntax ok, but definition of relevant bundle is elsewhere %s=%c\n",lval,rvaltype); PrependRlist(&SUBBUNDLES,rval,rvaltype); return; } else { CheckConstraintTypeMatch(lval,rval,rvaltype,bs[l].dtype,(char *)(bs[l].range),0); return; } } } } } /* Now check the functional modules - extra level of indirection Note that we only check body attributes relative to promise type. We can enter any promise types in any bundle, but only recognized types will be dealt with. */ for (i = 0; CF_COMMON_BODIES[i].lval != NULL; i++) { Debug1("CMP-common # %s,%s\n",lval,CF_COMMON_BODIES[i].lval); if (strcmp(lval,CF_COMMON_BODIES[i].lval) == 0) { Debug("Found a match for lval %s in the common constraint attributes\n",lval); return; } } for (i = 0; CF_COMMON_EDITBODIES[i].lval != NULL; i++) { Debug1("CMP-common # %s,%s\n",lval,CF_COMMON_EDITBODIES[i].lval); if (strcmp(lval,CF_COMMON_EDITBODIES[i].lval) == 0) { Debug("Found a match for lval %s in the common edit constraint attributes\n",lval); return; } } // Now check if it is in the common list... if (!lmatch || !allowed) { snprintf(output,CF_BUFSIZE,"Constraint lvalue \'%s\' is not allowed in bundle category \'%s\'",lval,type); ReportError(output); } } /******************************************************************************************/ int LvalWantsBody(char *stype,char *lval) { int i,j,l; struct SubTypeSyntax *ss; struct BodySyntax *bs; for (i = 0; i < CF3_MODULES; i++) { if ((ss = CF_ALL_SUBTYPES[i]) == NULL) { continue; } for (j = 0; ss[j].subtype != NULL; j++) { if ((bs = ss[j].bs) == NULL) { continue; } if (strcmp(ss[j].subtype,stype) != 0) { continue; } for (l = 0; bs[l].range != NULL; l++) { if (strcmp(bs[l].lval,lval) == 0) { if (bs[l].dtype == cf_body) { return true; } else { return false; } } } } } return false; } /******************************************************************************************/ void CheckSelection(char *type,char *name,char *lval,void *rval,char rvaltype) { int lmatch = false; int i,j,k,l; struct SubTypeSyntax *ss; struct BodySyntax *bs,*bs2; char output[CF_BUFSIZE]; Debug("CheckSelection(%s,%s,",type,lval); if (DEBUG) { ShowRval(stdout,rval,rvaltype); } Debug(")\n"); /* Check internal control bodies etc */ for (i = 0; CF_ALL_BODIES[i].subtype != NULL; i++) { if (strcmp(CF_ALL_BODIES[i].subtype,name) == 0 && strcmp(type,CF_ALL_BODIES[i].btype) == 0) { Debug("Found matching a body matching (%s,%s)\n",type,name); bs = CF_ALL_BODIES[i].bs; for (l = 0; bs[l].lval != NULL; l++) { if (strcmp(lval,bs[l].lval) == 0) { Debug("Matched syntatically correct body (lval) item = (%s)\n",lval); if (bs[l].dtype == cf_body) { Debug("Constraint syntax ok, but definition of body is elsewhere\n"); return; } else if (bs[l].dtype == cf_bundle) { Debug("Constraint syntax ok, but definition of bundle is elsewhere\n"); return; } else { CheckConstraintTypeMatch(lval,rval,rvaltype,bs[l].dtype,(char *)(bs[l].range),0); return; } } } } } /* Now check the functional modules - extra level of indirection */ for (i = 0; i < CF3_MODULES; i++) { Debug("Trying function module %d for matching lval %s\n",i,lval); if ((ss = CF_ALL_SUBTYPES[i]) == NULL) { continue; } for (j = 0; ss[j].subtype != NULL; j++) { if ((bs = ss[j].bs) == NULL) { continue; } Debug("\nExamining subtype %s\n",ss[j].subtype); for (l = 0; bs[l].range != NULL; l++) { if (bs[l].dtype == cf_body) { bs2 = (struct BodySyntax *)(bs[l].range); if (bs2 == NULL || bs2 == (void *)CF_BUNDLE) { continue; } for (k = 0; bs2[k].dtype != cf_notype; k++) { /* Either module defined or common */ if (strcmp(ss[j].subtype,type) == 0 && strcmp(ss[j].subtype,"*") != 0) { snprintf(output,CF_BUFSIZE,"lval %s belongs to promise type \'%s:\' but this is '\%s\'\n",lval,ss[j].subtype,type); ReportError(output); return; } if (strcmp(lval,bs2[k].lval) == 0) { Debug("Matched\n"); CheckConstraintTypeMatch(lval,rval,rvaltype,bs2[k].dtype,(char *)(bs2[k].range),0); return; } } } } } } if (!lmatch) { snprintf(output,CF_BUFSIZE,"Constraint lvalue \"%s\" is not allowed in \'%s\' constraint body",lval,type); ReportError(output); } } /****************************************************************************/ /* Level 1 */ /****************************************************************************/ void CheckConstraintTypeMatch(char *lval,void *rval,char rvaltype,enum cfdatatype dt,char *range,int level) { struct Rlist *rp; struct Item *checklist; char output[CF_BUFSIZE]; if (rval == NULL) { return; } Debug(" ------------------------------------------------\n"); if (dt == cf_bundle || dt == cf_body) { Debug(" - Checking inline constraint/arg %s[%s] => mappedval (bundle/body)\n",lval,CF_DATATYPES[dt]); } else { Debug(" - Checking inline constraint/arg %s[%s] => mappedval (%c) %s\n",lval,CF_DATATYPES[dt],rvaltype,range); } Debug(" ------------------------------------------------\n"); /* Get type of lval */ switch(rvaltype) { case CF_SCALAR: switch(dt) { case cf_slist: case cf_ilist: case cf_rlist: case cf_clist: case cf_olist: if (level == 0) { snprintf(output,CF_BUFSIZE," !! Type mismatch -- rhs is a scalar, but lhs (%s) is not a scalar type",CF_DATATYPES[dt]); ReportError(output); } break; } break; case CF_LIST: switch(dt) { case cf_slist: case cf_ilist: case cf_rlist: case cf_clist: case cf_olist: break; default: snprintf(output,CF_BUFSIZE,"!! Type mistach -- rhs is a list, but lhs (%s) is not a list type",CF_DATATYPES[dt]); ReportError(output); break; } for (rp = (struct Rlist *)rval; rp != NULL; rp = rp->next) { CheckConstraintTypeMatch(lval,rp->item,rp->type,dt,range,1); } return; case CF_FNCALL: /* Fn-like objects are assumed to be parameterized bundles in these... */ checklist = SplitString("bundlesequence,edit_line,edit_xml,usebundle",','); if (!IsItemIn(checklist,lval)) { CheckFnCallType(lval,((struct FnCall *)rval)->name,dt,range); } DeleteItemList(checklist); return; } /* If we get here, we have a literal scalar type */ switch (dt) { case cf_str: case cf_slist: CheckParseString(lval,(char *)rval,range); break; case cf_int: case cf_ilist: CheckParseInt(lval,(char *)rval,range); break; case cf_real: case cf_rlist: CheckParseReal(lval,(char *)rval,range); break; case cf_body: case cf_bundle: Debug("Nothing to check for body reference\n"); break; case cf_opts: case cf_olist: CheckParseOpts(lval,(char *)rval,range); break; case cf_class: case cf_clist: CheckParseClass(lval,(char *)rval,range); break; case cf_irange: CheckParseIntRange(lval,(char *)rval,range); break; case cf_rrange: CheckParseRealRange(lval,(char *)rval,range); break; default: snprintf(output,CF_BUFSIZE,"Unknown (unhandled) datatype for lval = %s (CheckConstraintTypeMatch)\n",lval); FatalError(output); } Debug("end CheckConstraintTypeMatch---------\n"); } /****************************************************************************/ enum cfdatatype StringDataType(char *scopeid,char *string) { enum cfdatatype dtype; char rtype; void *rval; int islist = false; char var[CF_BUFSIZE],exp[CF_EXPANDSIZE]; Debug("StringDataType(%s)\n",string); /*------------------------------------------------------- What happens if we embed vars in a literal string "$(list)withending" - a list? "$(list1)$(list2)" - not a simple list Disallow these manual concatenations as ambiguous. Demand this syntax to work around vars: "listvar" slist => EmbellishList("prefix$(list)suffix"); ---------------------------------------------------------*/ var[0] = '\0'; exp[0] = '\0'; if (*string == '$') { if (ExtractInnerCf3VarString(string,var)) { if ((dtype = GetVariable(scopeid,var,&rval,&rtype)) != cf_notype) { if (rtype == CF_LIST) { if (!islist) { islist = true; } else { islist = false; } } } if (strlen(var) == strlen(string)) { /* Can trust variables own datatype */ return dtype; } else { /* Must force non-pure substitution to be generic type CF_SCALAR.cf_str */ return cf_str; } } } return cf_str; } /****************************************************************************/ /* Level 1 */ /****************************************************************************/ static int CheckParseString(char *lval,char *s,char *range) { char output[CF_BUFSIZE]; Debug("\nCheckParseString(%s => %s/%s)\n",lval,s,range); if (s == NULL) { return true; } if (strlen(range) == 0) { return true; } if (IsNakedVar(s,'@')||IsNakedVar(s,'$')) { Debug("Validation: Unable to verify variable expansion of %s at this stage\n",s); return false; } /* Deal with complex strings as special cases */ if (strcmp(lval,"mode") == 0 || strcmp(lval,"search_mode") == 0) { mode_t plus,minus; if (!ParseModeString(s,&plus,&minus)) { snprintf(output,CF_BUFSIZE,"Error parsing Unix permission string %s)",s); ReportError(output); return false; } } if (FullTextMatch(range,s)) { return true; } if (IsCf3VarString(s)) { Debug("Validation: Unable to verify syntax of %s due to variable expansion at this stage\n",s); } else { snprintf(output,CF_BUFSIZE,"Scalar item in %s => { %s } in rvalue is out of bounds (value should match pattern %s)",lval,s,range); ReportError(output); return false; } return true; } /****************************************************************************/ int CheckParseClass(char *lval,char *s,char *range) { char output[CF_BUFSIZE]; if (s == NULL) { return false; } Debug("\nCheckParseClass(%s => %s/%s)\n",lval,s,range); if (strlen(range) == 0) { return true; } if (FullTextMatch(range,s)) { return true; } snprintf(output,CF_BUFSIZE,"Class item on rhs of lval \'%s\' given as { %s } is out of bounds (should match %s)",lval,s,range); ReportError(output); return false; } /****************************************************************************/ static void CheckParseInt(char *lval,char *s,char *range) { struct Item *split; int n; long max = CF_LOWINIT, min = CF_HIGHINIT, val; char output[CF_BUFSIZE]; /* Numeric types are registered by range separated by comma str "min,max" */ Debug("\nCheckParseInt(%s => %s/%s)\n",lval,s,range); if (s == NULL) { return; } split = SplitString(range,','); if ((n = ListLen(split)) != 2) { snprintf(output,CF_BUFSIZE,"INTERN: format specifier for int rvalues is not ok for lval %s - got %d items",lval,n); FatalError(output); } sscanf(split->name,"%ld",&min); if (strcmp(split->next->name,"inf") == 0) { max = CF_INFINITY; } else { sscanf(split->next->name,"%ld",&max); } DeleteItemList(split); if (min == CF_HIGHINIT || max == CF_LOWINIT) { snprintf(output,CF_BUFSIZE,"INTERN: could not parse format specifier for int rvalues for lval %s",lval); FatalError(output); } if (IsCf3VarString(s)) { Debug("Validation: Unable to verify syntax of int \'%s\' due to variable expansion at this stage\n",s); return; } val = Str2Int(s); if (val > max || val < min) { snprintf(output,CF_BUFSIZE,"Int item on rhs of lval \'%s\' given as {%s => %ld} is out of bounds (should be in [%s])",lval,s,val,range); ReportError(output); return; } Debug("CheckParseInt - syntax verified\n\n"); } /****************************************************************************/ static void CheckParseIntRange(char *lval,char *s,char *range) { struct Item *split,*ip,*rangep; int n; long max = CF_LOWINIT, min = CF_HIGHINIT, val; char output[CF_BUFSIZE]; if (s == NULL) { return; } /* Numeric types are registered by range separated by comma str "min,max" */ Debug("\nCheckParseIntRange(%s => %s/%s)\n",lval,s,range); if (*s == '[' || *s == '(') { ReportError("Range specification should not be enclosed in brackets - just \"a,b\""); return; } split = SplitString(range,','); if ((n = ListLen(split)) != 2) { snprintf(output,CF_BUFSIZE,"INTERN:format specifier %s for irange rvalues is not ok for lval %s - got %d items",range,lval,n); FatalError(output); } sscanf(split->name,"%ld",&min); if (strcmp(split->next->name,"inf") == 0) { max = CF_INFINITY; } else { sscanf(split->next->name,"%ld",&max); } DeleteItemList(split); if (min == CF_HIGHINIT || max == CF_LOWINIT) { snprintf(output,CF_BUFSIZE,"INTERN: could not parse irange format specifier for int rvalues for lval %s",lval); FatalError(output); } if (IsCf3VarString(s)) { Debug("Validation: Unable to verify syntax of int \'%s\' due to variable expansion at this stage\n",s); return; } rangep = SplitString(s,','); if ((n = ListLen(rangep)) != 2) { snprintf(output,CF_BUFSIZE,"Int range format specifier for lval %s should be of form \"a,b\" but got %d items",lval,n); ReportError(output); DeleteItemList(rangep); return; } for (ip = rangep; ip != NULL; ip=ip->next) { val = Str2Int(ip->name); if (val > max || val < min) { snprintf(output,CF_BUFSIZE,"Int range item on rhs of lval \'%s\' given as {%s => %ld} is out of bounds (should be in [%s])",lval,s,val,range); ReportError(output); DeleteItemList(rangep); return; } } DeleteItemList(rangep); Debug("CheckParseIntRange - syntax verified\n\n"); } /****************************************************************************/ static void CheckParseReal(char *lval,char *s,char *range) { struct Item *split; double max = (double)CF_LOWINIT, min = (double)CF_HIGHINIT, val; int n; char output[CF_BUFSIZE]; Debug("\nCheckParseReal(%s => %s/%s)\n",lval,s,range); if (s == NULL) { return; } if (strcmp(s,"inf") == 0) { ReportError("keyword \"inf\" has an integer value, cannot be used as real"); return; } if (IsCf3VarString(s)) { Debug("Validation: Unable to verify syntax of real %s due to variable expansion at this stage\n",s); return; } /* Numeric types are registered by range separated by comma str "min,max" */ split = SplitString(range,','); if ((n = ListLen(split)) != 2) { snprintf(output,CF_BUFSIZE,"INTERN:format specifier for real rvalues is not ok for lval %s - %d items",lval,n); FatalError(output); } sscanf(split->name,"%lf",&min); sscanf(split->next->name,"%lf",&max); DeleteItemList(split); if (min == CF_HIGHINIT || max == CF_LOWINIT) { snprintf(output,CF_BUFSIZE,"INTERN:could not parse format specifier for int rvalues for lval %s",lval); FatalError(output); } val = Str2Double(s); if (val > max || val < min) { snprintf(output,CF_BUFSIZE,"Real item on rhs of lval \'%s\' give as {%s => %.3lf} is out of bounds (should be in [%s])",lval,s,val,range); ReportError(output); } Debug("CheckParseReal - syntax verified\n\n"); } /****************************************************************************/ static void CheckParseRealRange(char *lval,char *s,char *range) { struct Item *split,*rangep,*ip; double max = (double)CF_LOWINIT, min = (double)CF_HIGHINIT, val; int n; char output[CF_BUFSIZE]; if (s == NULL) { return; } Debug("\nCheckParseRealRange(%s => %s/%s)\n",lval,s,range); if (*s == '[' || *s == '(') { ReportError("Range specification should not be enclosed in brackets - just \"a,b\""); return; } if (strcmp(s,"inf") == 0) { ReportError("keyword \"inf\" has an integer value, cannot be used as real"); return; } if (IsCf3VarString(s)) { Debug("Validation: Unable to verify syntax of real %s due to variable expansion at this stage\n",s); return; } /* Numeric types are registered by range separated by comma str "min,max" */ split = SplitString(range,','); if ((n = ListLen(split)) != 2) { snprintf(output,CF_BUFSIZE,"INTERN:format specifier for real rvalues is not ok for lval %s - %d items",lval,n); FatalError(output); } sscanf(split->name,"%lf",&min); sscanf(split->next->name,"%lf",&max); DeleteItemList(split); if (min == CF_HIGHINIT || max == CF_LOWINIT) { snprintf(output,CF_BUFSIZE,"INTERN:could not parse format specifier for int rvalues for lval %s",lval); FatalError(output); } rangep = SplitString(s,','); if ((n = ListLen(rangep)) != 2) { snprintf(output,CF_BUFSIZE,"Real range format specifier in lval %s should be of form \"a,b\" but got %d items",lval,n); ReportError(output); DeleteItemList(rangep); return; } for (ip = rangep; ip != NULL; ip=ip->next) { val = Str2Double(ip->name); if (val > max || val < min) { snprintf(output,CF_BUFSIZE,"Real range item on rhs of lval \'%s\' give as {%s => %.3lf} is out of bounds (should be in [%s])",lval,s,val,range); ReportError(output); } } DeleteItemList(rangep); Debug("CheckParseRealRange - syntax verified\n\n"); } /****************************************************************************/ static void CheckParseOpts(char *lval,char *s,char *range) { struct Item *split; int err = false; char output[CF_BUFSIZE]; /* List/menu types are separated by comma str "a,b,c,..." */ Debug("\nCheckParseOpts(%s => %s/%s)\n",lval,s,range); if (s == NULL) { return; } if (IsNakedVar(s,'@')||IsNakedVar(s,'$')) { Debug("Validation: Unable to verify variable expansion of %s at this stage\n",s); return; } split = SplitString(range,','); if (!IsItemIn(split,s)) { snprintf(output,CF_BUFSIZE,"Selection on rhs of lval \'%s\' given as \'%s\' is out of bounds, should be in [%s]",lval,s,range); ReportError(output); err = true; } DeleteItemList(split); if (!err) { Debug("CheckParseOpts - syntax verified\n\n"); } } /****************************************************************************/ int CheckParseVariableName(char *name) { const char *reserved[] = { "promiser", "handle", "promise_filename", "promise_linenumber", NULL }; char *sp,scopeid[CF_MAXVARSIZE],vlval[CF_MAXVARSIZE]; int count = 0, level = 0; if (IsStrIn(name,reserved)) { return false; } scopeid[0] = '\0'; if (strchr(name,'.')) { for (sp = name; *sp != '\0'; sp++) { switch (*sp) { case '.': if (++count > 1 && level != 1) { return false; } break; case '[': level++; break; case ']': level--; break; default: break; } if (level > 1) { yyerror("Too many levels of [] reserved for array use"); return false; } } if (count == 1) { sscanf(name,"%[^.].%s",scopeid,vlval); if (strlen(scopeid) == 0 || strlen(vlval) == 0) { return false; } } } return true; } /****************************************************************************/ static void CheckFnCallType(char *lval,const char *s,enum cfdatatype dtype,char *range) { int i; enum cfdatatype dt; char output[CF_BUFSIZE]; FnCallType *fn; Debug("CheckFnCallType(%s => %s/%s)\n",lval,s,range); if (s == NULL) { return; } fn = FindFunction(s); if (fn) { dt = fn->dtype; if (dtype != dt) { /* Ok to allow fn calls of correct element-type in lists */ if (dt == cf_str && dtype == cf_slist) { return; } if (dt == cf_int && dtype == cf_ilist) { return; } if (dt == cf_real && dtype == cf_rlist) { return; } if (dt == cf_opts && dtype == cf_olist) { return; } if (dt == cf_class && dtype == cf_clist) { return; } snprintf(output,CF_BUFSIZE,"function %s() returns type %s but lhs requires %s",s,CF_DATATYPES[dt],CF_DATATYPES[dtype]); ReportError(output); return; } else { return; } } else { snprintf(output,CF_BUFSIZE,"Unknown built-in function %s()",s); ReportError(output); } } �������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/mod_environ.c��������������������������������������������������������������������0000644�0001750�0001750�00000011026�11715232734�013476� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_environ.c */ /* */ /*****************************************************************************/ /* This file can act as a template for adding functionality to cfengine 3. All functionality can be added by extending the main array CF_MOD_SUBTYPES[CF3_MODULES] and its array dimension, in mod_common, in the manner shown here. */ #define CF3_MOD_ENVIRON #include "cf3.defs.h" #include "cf3.extern.h" /***********************************************************/ /* Read this module file backwards, as dependencies have */ /* to be defined first - these arrays declare pairs of */ /* constraints */ /* */ /* lval => rval */ /* */ /* in the form (lval,type,range) */ /* */ /* If the type is cf_body then the range is a pointer */ /* to another array of pairs, like in a body "sub-routine" */ /* */ /***********************************************************/ struct BodySyntax CF_RESOURCE_BODY[] = { {"env_cpus",cf_int,CF_VALRANGE,"Number of virtual CPUs in the environment"}, {"env_memory",cf_int,CF_VALRANGE,"Amount of primary storage (RAM) in the virtual environment (KB)"}, {"env_disk",cf_int,CF_VALRANGE,"Amount of secondary storage (DISK) in the virtual environment (MB)"}, {"env_baseline",cf_str,CF_ABSPATHRANGE,"The path to an image with which to baseline the virtual environment"}, {"env_spec_file",cf_str,CF_ABSPATHRANGE,"The path to a file containing a technology specific set of promises for the virtual instance"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ struct BodySyntax CF_DESIGNATION_BODY[] = { {"env_addresses",cf_slist,"","The IP addresses of the environment's network interfaces"}, {"env_name",cf_str,"","The hostname of the virtual environment"}, {"env_network",cf_str,"","The hostname of the virtual network"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ struct BodySyntax CF_ENVIRON_BODIES[] = { {"environment_host",cf_str,CF_IPRANGE,"A host for the virtual environment uniquely indicating which physical node will execute this machine"}, {"environment_interface",cf_body,CF_DESIGNATION_BODY,"Virtual environment outward identity and location"}, {"environment_resources",cf_body,CF_RESOURCE_BODY,"Virtual environment resource description"}, {"environment_state",cf_opts,"create,delete,running,suspended,down","The desired dynamical state of the specified environment"}, {"environment_type",cf_opts,"xen,kvm,esx,test,xen_net,kvm_net,esx_net,test_net,zone,ec2,eucalyptus","Virtual environment type"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_ENVIRONMENT_SUBTYPES[] = { {"agent","environments",CF_ENVIRON_BODIES}, {NULL,NULL,NULL}, }; ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/cf3parse.c�����������������������������������������������������������������������0000644�0001750�0001750�00000210650�11715233327�012670� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* A Bison parser, made by GNU Bison 2.5. */ /* Bison implementation for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2011 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 <http://www.gnu.org/licenses/>. */ /* 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.5" /* 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 268 of yacc.c */ #line 2 "cf3parse.y" /*******************************************************************/ /* */ /* PARSER for cfengine 3 */ /* */ /*******************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" extern char *yytext; static void fatal_yyerror(const char *s); /* Line 268 of yacc.c */ #line 89 "cf3parse.c" /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* Enabling the token table. */ #ifndef YYTOKEN_TABLE # define YYTOKEN_TABLE 0 #endif /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { ID = 258, QSTRING = 259, CLASS = 260, CATEGORY = 261, BUNDLE = 262, BODY = 263, ASSIGN = 264, ARROW = 265, NAKEDVAR = 266 }; #endif /* Tokens. */ #define ID 258 #define QSTRING 259 #define CLASS 260 #define CATEGORY 261 #define BUNDLE 262 #define BODY 263 #define ASSIGN 264 #define ARROW 265 #define NAKEDVAR 266 #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 /* Copy the second part of user declarations. */ /* Line 343 of yacc.c */ #line 153 "cf3parse.c" #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #elif (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) typedef signed char yytype_int8; #else typedef short int yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include <stddef.h> /* 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 defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* 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 <alloca.h> /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # 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 EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined EXIT_SUCCESS && (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 EXIT_SUCCESS && (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) # define YYCOPY_NEEDED 1 /* 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 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* 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 #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 8 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 83 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 18 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 44 /* YYNRULES -- Number of rules. */ #define YYNRULES 77 /* YYNRULES -- Number of states. */ #define YYNSTATES 105 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 266 #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, 12, 13, 2, 2, 14, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 17, 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, 15, 2, 16, 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 }; #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, 6, 8, 11, 16, 22, 27, 33, 35, 37, 39, 41, 45, 47, 51, 52, 54, 55, 60, 62, 65, 67, 69, 70, 75, 77, 80, 82, 84, 86, 89, 90, 96, 98, 101, 103, 105, 107, 110, 112, 113, 120, 121, 126, 128, 132, 133, 137, 139, 141, 143, 145, 147, 149, 151, 155, 157, 161, 162, 164, 166, 168, 170, 172, 174, 176, 179, 180, 185, 187, 191, 192, 194, 196, 198 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { 19, 0, -1, -1, 20, -1, 21, -1, 20, 21, -1, 22, 24, 25, 29, -1, 22, 24, 25, 26, 29, -1, 23, 24, 25, 33, -1, 23, 24, 25, 26, 33, -1, 7, -1, 8, -1, 3, -1, 3, -1, 12, 27, 13, -1, 28, -1, 28, 14, 27, -1, -1, 3, -1, -1, 15, 30, 31, 16, -1, 32, -1, 31, 32, -1, 43, -1, 40, -1, -1, 15, 34, 35, 16, -1, 36, -1, 35, 36, -1, 49, -1, 37, -1, 38, -1, 37, 38, -1, -1, 50, 9, 51, 39, 17, -1, 41, -1, 40, 41, -1, 49, -1, 42, -1, 44, -1, 42, 44, -1, 6, -1, -1, 56, 10, 51, 45, 47, 17, -1, -1, 56, 46, 47, 17, -1, 48, -1, 47, 14, 48, -1, -1, 50, 9, 51, -1, 5, -1, 3, -1, 3, -1, 4, -1, 11, -1, 52, -1, 57, -1, 15, 53, 16, -1, 54, -1, 54, 14, 53, -1, -1, 3, -1, 4, -1, 11, -1, 57, -1, 3, -1, 11, -1, 4, -1, 55, 58, -1, -1, 12, 59, 60, 13, -1, 61, -1, 60, 14, 61, -1, -1, 3, -1, 4, -1, 11, -1, 57, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 23, 23, 24, 28, 29, 33, 34, 35, 36, 40, 53, 65, 73, 80, 86, 87, 88, 92, 100, 99, 124, 125, 129, 130, 135, 134, 151, 152, 156, 157, 161, 162, 169, 166, 220, 221, 225, 226, 230, 231, 235, 253, 248, 283, 282, 315, 316, 317, 321, 343, 350, 359, 366, 382, 390, 397, 406, 412, 413, 414, 418, 423, 430, 437, 446, 450, 460, 469, 477, 476, 501, 502, 503, 507, 513, 521, 529 }; #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", "ID", "QSTRING", "CLASS", "CATEGORY", "BUNDLE", "BODY", "ASSIGN", "ARROW", "NAKEDVAR", "'('", "')'", "','", "'{'", "'}'", "';'", "$accept", "specification", "blocks", "block", "bundle", "body", "typeid", "blockid", "usearglist", "aitems", "aitem", "bundlebody", "$@1", "statements", "statement", "bodybody", "$@2", "bodyattribs", "bodyattrib", "selections", "selection", "$@3", "classpromises", "classpromise", "promises", "category", "promise", "$@4", "$@5", "constraints", "constraint", "class", "id", "rval", "list", "litems", "litem", "functionid", "promiser", "usefunction", "givearglist", "$@6", "gaitems", "gaitem", 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, 40, 41, 44, 123, 125, 59 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 18, 19, 19, 20, 20, 21, 21, 21, 21, 22, 23, 24, 25, 26, 27, 27, 27, 28, 30, 29, 31, 31, 32, 32, 34, 33, 35, 35, 36, 36, 37, 37, 39, 38, 40, 40, 41, 41, 42, 42, 43, 45, 44, 46, 44, 47, 47, 47, 48, 49, 50, 51, 51, 51, 51, 51, 52, 53, 53, 53, 54, 54, 54, 54, 55, 55, 56, 57, 59, 58, 60, 60, 60, 61, 61, 61, 61 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 0, 1, 1, 2, 4, 5, 4, 5, 1, 1, 1, 1, 3, 1, 3, 0, 1, 0, 4, 1, 2, 1, 1, 0, 4, 1, 2, 1, 1, 1, 2, 0, 5, 1, 2, 1, 1, 1, 2, 1, 0, 6, 0, 4, 1, 3, 0, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 0, 1, 1, 1, 1, 1, 1, 1, 2, 0, 4, 1, 3, 0, 1, 1, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. Performed when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { 2, 10, 11, 0, 3, 4, 0, 0, 1, 5, 12, 0, 0, 13, 0, 0, 17, 19, 0, 6, 25, 0, 8, 18, 0, 15, 0, 7, 0, 9, 14, 17, 67, 50, 41, 0, 21, 24, 35, 38, 23, 39, 37, 44, 51, 0, 27, 30, 31, 29, 0, 16, 20, 22, 36, 40, 0, 48, 26, 28, 32, 0, 52, 53, 54, 60, 42, 55, 0, 56, 0, 46, 0, 33, 61, 62, 63, 0, 58, 64, 48, 69, 68, 0, 45, 0, 0, 57, 60, 0, 73, 47, 49, 34, 59, 43, 74, 75, 76, 77, 0, 71, 70, 0, 72 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { -1, 3, 4, 5, 6, 7, 11, 14, 18, 24, 25, 19, 26, 35, 36, 22, 28, 45, 46, 47, 48, 86, 37, 38, 39, 40, 41, 80, 57, 70, 71, 42, 50, 66, 67, 77, 78, 68, 43, 69, 82, 90, 100, 101 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -66 static const yytype_int8 yypact[] = { 40, -66, -66, 5, 40, -66, 13, 13, -66, -66, -66, 29, 29, -66, 0, 18, 32, -66, 24, -66, -66, 30, -66, -66, 42, 39, 37, -66, 41, -66, -66, 32, -66, -66, -66, 3, -66, 45, -66, 50, -66, -66, -66, 46, -66, 1, -66, 54, -66, -66, 49, -66, -66, -66, -66, -66, 7, 54, -66, -66, -66, 7, 47, -66, 48, 10, -66, -66, 51, -66, 17, -66, 52, -66, 47, -66, 48, 53, 56, -66, 54, -66, -66, 54, -66, 7, 55, -66, 10, 23, 25, -66, -66, -66, -66, -66, 47, -66, 48, -66, 38, -66, -66, 25, -66 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -66, -66, -66, 58, -66, -66, 57, 59, 60, 34, -66, 61, -66, -66, 31, 62, -66, -66, 22, -66, 21, -66, -66, 36, -66, -66, 35, -66, -66, -4, -6, -25, -56, -59, -66, -10, -66, -66, -66, -65, -66, -66, -66, -23 }; /* 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 YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -67 static const yytype_int8 yytable[] = { 79, 72, 73, 49, 44, 8, 33, 32, 33, 34, 62, 63, 16, 74, 75, 17, 10, 58, 64, 52, 49, 76, 65, 79, 72, 99, 92, 72, 96, 97, 16, 83, 13, 20, 84, 23, 98, 83, 99, 17, 95, 32, 33, 34, 44, 20, 33, 1, 2, 32, 33, 102, 103, 31, 32, 30, 56, 44, 61, -65, -66, 85, 9, 81, 12, 51, 53, 59, 60, 87, 88, 15, 93, 54, 55, 21, 89, 91, 94, 27, 104, 0, 0, 29 }; #define yypact_value_is_default(yystate) \ ((yystate) == (-66)) #define yytable_value_is_error(yytable_value) \ YYID (0) static const yytype_int8 yycheck[] = { 65, 57, 61, 28, 3, 0, 5, 4, 5, 6, 3, 4, 12, 3, 4, 15, 3, 16, 11, 16, 45, 11, 15, 88, 80, 90, 85, 83, 3, 4, 12, 14, 3, 15, 17, 3, 11, 14, 103, 15, 17, 4, 5, 6, 3, 15, 5, 7, 8, 4, 5, 13, 14, 14, 4, 13, 10, 3, 9, 12, 12, 9, 4, 12, 7, 31, 35, 45, 47, 16, 14, 12, 17, 37, 39, 15, 80, 83, 88, 18, 103, -1, -1, 21 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 7, 8, 19, 20, 21, 22, 23, 0, 21, 3, 24, 24, 3, 25, 25, 12, 15, 26, 29, 15, 26, 33, 3, 27, 28, 30, 29, 34, 33, 13, 14, 4, 5, 6, 31, 32, 40, 41, 42, 43, 44, 49, 56, 3, 35, 36, 37, 38, 49, 50, 27, 16, 32, 41, 44, 10, 46, 16, 36, 38, 9, 3, 4, 11, 15, 51, 52, 55, 57, 47, 48, 50, 51, 3, 4, 11, 53, 54, 57, 45, 12, 58, 14, 17, 9, 39, 16, 14, 47, 59, 48, 51, 17, 53, 17, 3, 4, 11, 57, 60, 61, 13, 14, 61 }; #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. However, YYFAIL appears to be in use. Nevertheless, it is formally deprecated in Bison 2.4.2's NEWS entry, where a plan to phase it out is discussed. */ #define YYFAIL goto yyerrlab #if defined YYFAIL /* This is here to suppress warnings from the GCC cpp's -Wunused-macros. Normally we don't worry about that warning, but some users do, and we want to make it easy for users to remove YYFAIL uses, which will produce warnings from Bison 2.5. */ #endif #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ 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 /* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #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 <stdio.h> /* 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 *YYMSG, which is of size *YYMSG_ALLOC, an error message about the unexpected token YYTOKEN for the state stack whose top is YYSSP. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is not large enough to hold the message. In that case, also set *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = 0; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per "expected"). */ int yycount = 0; /* There are many possibilities here to consider: - Assume YYFAIL is not used. It's too flawed to consider. See <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html> for details. YYERROR is fine as it does not invoke this function. - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected tokens because there are none. - The only way there can be no lookahead present (in yychar) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to report. In that case, just report a simple "syntax error". - Don't assume there isn't a lookahead just because this state is a consistent state with a default action. There might have been a previous inconsistent state, consistent state with a non-default action, or user semantic action that manipulated yychar. - Of course, the expected token list depends on states to have correct lookahead information, and it depends on the parser not to perform extra reductions after fetching a lookahead from the scanner and before detecting a syntax error. Thus, state merging (from LALR or IELR) and default reductions corrupt the expected token list. However, the list is correct for canonical LR with one exception: it will still contain any token that will not be accepted due to an error action in a later state. */ if (yytoken != YYEMPTY) { int yyn = yypact[*yyssp]; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. In other words, skip the first -YYN actions for this state because they are default actions. */ 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 yyx; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; break; } yyarg[yycount++] = yytname[yyx]; yysize1 = yysize + yytnamerr (0, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } } } switch (yycount) { # define YYCASE_(N, S) \ case N: \ yyformat = S; \ break YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); # undef YYCASE_ } yysize1 = yysize + yystrlen (yyformat); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; if (*yymsg_alloc < yysize) { *yymsg_alloc = 2 * yysize; if (! (yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; return 1; } /* 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 = *yymsg; int yyi = 0; while ((*yyp = *yyformat) != '\0') if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyformat += 2; } else { yyp++; yyformat++; } } return 0; } #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. | `----------*/ #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 (yypact_value_is_default (yyn)) 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 (yytable_value_is_error (yyn)) 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 2: /* Line 1806 of yacc.c */ #line 23 "cf3parse.y" { yyerror("Something defined outside of a block or missing punctuation in input"); } break; case 10: /* Line 1806 of yacc.c */ #line 41 "cf3parse.y" { DebugBanner("Bundle"); P.block = "bundle"; P.rval = NULL; P.currentRlist = NULL; P.currentstring = NULL; strcpy(P.blockid,""); strcpy(P.blocktype,""); } break; case 11: /* Line 1806 of yacc.c */ #line 54 "cf3parse.y" { DebugBanner("Body"); P.block = "body"; strcpy(P.blockid,""); P.currentRlist = NULL; P.currentstring = NULL; strcpy(P.blocktype,""); } break; case 12: /* Line 1806 of yacc.c */ #line 65 "cf3parse.y" { strncpy(P.blocktype,P.currentid,CF_MAXVARSIZE); Debug("Found block type %s for %s\n",P.blocktype,P.block); P.useargs = NULL; } break; case 13: /* Line 1806 of yacc.c */ #line 73 "cf3parse.y" { strncpy(P.blockid,P.currentid,CF_MAXVARSIZE); Debug("Found identifier %s for %s\n",P.currentid,P.block); } break; case 18: /* Line 1806 of yacc.c */ #line 93 "cf3parse.y" { AppendRlist(&(P.useargs),P.currentid,CF_SCALAR); } break; case 19: /* Line 1806 of yacc.c */ #line 100 "cf3parse.y" { if (RelevantBundle(THIS_AGENT,P.blocktype)) { Debug("We a compiling everything here\n"); INSTALL_SKIP = false; } else if (strcmp(THIS_AGENT,P.blocktype) != 0) { Debug("This is for a different agent\n"); INSTALL_SKIP = true; } P.currentbundle = AppendBundle(&BUNDLES,P.blockid,P.blocktype,P.useargs); P.useargs = NULL; } break; case 20: /* Line 1806 of yacc.c */ #line 117 "cf3parse.y" { INSTALL_SKIP = false; Debug("End promise bundle\n\n"); } break; case 25: /* Line 1806 of yacc.c */ #line 135 "cf3parse.y" { P.currentbody = AppendBody(&BODIES,P.blockid,P.blocktype,P.useargs); P.useargs = NULL; strcpy(P.currentid,""); Debug("Starting block\n"); } break; case 26: /* Line 1806 of yacc.c */ #line 145 "cf3parse.y" { Debug("End promise body\n"); } break; case 33: /* Line 1806 of yacc.c */ #line 169 "cf3parse.y" { CheckSelection(P.blocktype,P.blockid,P.lval,P.rval,P.rtype); if (!INSTALL_SKIP) { if (P.currentclasses == NULL) { AppendConstraint(&((P.currentbody)->conlist),P.lval,P.rval,P.rtype,"any",P.isbody); } else { AppendConstraint(&((P.currentbody)->conlist),P.lval,P.rval,P.rtype,P.currentclasses,P.isbody); } } else { DeleteRvalItem(P.rval,P.rtype); } if (strcmp(P.blockid,"control") == 0 && strcmp(P.blocktype,"common") == 0) { if (strcmp(P.lval,"inputs") == 0) { if (IsDefinedClass(P.currentclasses)) { if (VINPUTLIST == NULL) { if (P.rtype == CF_LIST) { VINPUTLIST = P.rval; } else { yyerror("inputs promise must have a list as rvalue"); } } else { yyerror("Redefinition of input list (broken promise)"); } } } } P.rval = NULL; } break; case 41: /* Line 1806 of yacc.c */ #line 236 "cf3parse.y" { Debug("\n* Begin new promise type category %s in function \n\n",P.currenttype); if (strcmp(P.block,"bundle") == 0) { CheckSubType(P.blocktype,P.currenttype); /* FIXME: unused? */ P.currentstype = AppendSubType(P.currentbundle,P.currenttype); } } break; case 42: /* Line 1806 of yacc.c */ #line 253 "cf3parse.y" { if (P.currentclasses == NULL) { P.currentpromise = AppendPromise(P.currentstype,P.promiser,P.rval,P.rtype,"any",P.blockid,P.blocktype); } else { P.currentpromise = AppendPromise(P.currentstype,P.promiser,P.rval,P.rtype,P.currentclasses,P.blockid,P.blocktype); } } break; case 43: /* Line 1806 of yacc.c */ #line 265 "cf3parse.y" { Debug("End implicit promise %s\n\n",P.promiser); strcpy(P.currentid,""); P.currentRlist = NULL; free(P.promiser); if (P.currentstring) { free(P.currentstring); } P.currentstring = NULL; P.promiser = NULL; P.promisee = NULL; /* reset argptrs etc*/ } break; case 44: /* Line 1806 of yacc.c */ #line 283 "cf3parse.y" { if (P.currentclasses == NULL) { P.currentpromise = AppendPromise(P.currentstype,P.promiser,NULL,CF_NOPROMISEE,"any",P.blockid,P.blocktype); } else { P.currentpromise = AppendPromise(P.currentstype,P.promiser,NULL,CF_NOPROMISEE,P.currentclasses,P.blockid,P.blocktype); } } break; case 45: /* Line 1806 of yacc.c */ #line 295 "cf3parse.y" { Debug("End full promise with promisee %s\n\n",P.promiser); /* Don't free these */ strcpy(P.currentid,""); P.currentRlist = NULL; free(P.promiser); if (P.currentstring) { free(P.currentstring); } P.currentstring = NULL; P.promiser = NULL; P.promisee = NULL; /* reset argptrs etc*/ } break; case 49: /* Line 1806 of yacc.c */ #line 324 "cf3parse.y" { if (!INSTALL_SKIP) { struct SubTypeSyntax ss = CheckSubType(P.blocktype,P.currenttype); CheckConstraint(P.currenttype,P.blockid,P.lval,P.rval,P.rtype,ss); AppendConstraint(&(P.currentpromise->conlist),P.lval,P.rval,P.rtype,"any",P.isbody); P.rval = NULL; strcpy(P.lval,"no lval"); P.currentRlist = NULL; } else { DeleteRvalItem(P.rval,P.rtype); } } break; case 50: /* Line 1806 of yacc.c */ #line 344 "cf3parse.y" { Debug(" New class context \'%s\' :: \n\n",P.currentclasses); } break; case 51: /* Line 1806 of yacc.c */ #line 351 "cf3parse.y" { strncpy(P.lval,P.currentid,CF_MAXVARSIZE); P.currentRlist = NULL; Debug("Recorded LVAL %s\n",P.lval); } break; case 52: /* Line 1806 of yacc.c */ #line 360 "cf3parse.y" { P.rval = strdup(P.currentid); P.rtype = CF_SCALAR; P.isbody = true; Debug("Recorded IDRVAL %s\n",P.rval); } break; case 53: /* Line 1806 of yacc.c */ #line 367 "cf3parse.y" { P.rval = P.currentstring; P.currentstring = NULL; P.rtype = CF_SCALAR; P.isbody = false; Debug("Recorded scalarRVAL %s\n",P.rval); if (P.currentpromise) { if (LvalWantsBody(P.currentpromise->agentsubtype,P.lval)) { yyerror("An rvalue is quoted, but we expect an unquoted body identifier"); } } } break; case 54: /* Line 1806 of yacc.c */ #line 383 "cf3parse.y" { P.rval = P.currentstring; P.currentstring = NULL; P.rtype = CF_SCALAR; P.isbody = false; Debug("Recorded saclarvariableRVAL %s\n",P.rval); } break; case 55: /* Line 1806 of yacc.c */ #line 391 "cf3parse.y" { P.rval = P.currentRlist; P.currentRlist = NULL; P.isbody = false; P.rtype = CF_LIST; } break; case 56: /* Line 1806 of yacc.c */ #line 398 "cf3parse.y" { P.isbody = false; P.rval = P.currentfncall[P.arg_nesting+1]; P.rtype = CF_FNCALL; } break; case 61: /* Line 1806 of yacc.c */ #line 419 "cf3parse.y" { AppendRlist((struct Rlist **)&P.currentRlist,P.currentid,CF_SCALAR); } break; case 62: /* Line 1806 of yacc.c */ #line 424 "cf3parse.y" { AppendRlist((struct Rlist **)&P.currentRlist,(void *)P.currentstring,CF_SCALAR); free(P.currentstring); P.currentstring = NULL; } break; case 63: /* Line 1806 of yacc.c */ #line 431 "cf3parse.y" { AppendRlist((struct Rlist **)&P.currentRlist,(void *)P.currentstring,CF_SCALAR); free(P.currentstring); P.currentstring = NULL; } break; case 64: /* Line 1806 of yacc.c */ #line 438 "cf3parse.y" { Debug("Install function call as list item from level %d\n",P.arg_nesting+1); AppendRlist((struct Rlist **)&P.currentRlist,(void *)P.currentfncall[P.arg_nesting+1],CF_FNCALL); DeleteFnCall(P.currentfncall[P.arg_nesting+1]); } break; case 65: /* Line 1806 of yacc.c */ #line 447 "cf3parse.y" { Debug("Found function identifier %s\n",P.currentid); } break; case 66: /* Line 1806 of yacc.c */ #line 451 "cf3parse.y" { strncpy(P.currentid,P.currentstring,CF_MAXVARSIZE); // Make a var look like an ID free(P.currentstring); P.currentstring = NULL; Debug("Found variable in place of a function identifier %s\n",P.currentid); } break; case 67: /* Line 1806 of yacc.c */ #line 461 "cf3parse.y" { P.promiser = P.currentstring; P.currentstring = NULL; Debug("Promising object name \'%s\'\n",P.promiser); } break; case 68: /* Line 1806 of yacc.c */ #line 470 "cf3parse.y" { Debug("Finished with function call, now at level %d\n\n",P.arg_nesting); } break; case 69: /* Line 1806 of yacc.c */ #line 477 "cf3parse.y" { if (++P.arg_nesting >= CF_MAX_NESTING) { fatal_yyerror("Nesting of functions is deeper than recommended"); } P.currentfnid[P.arg_nesting] = strdup(P.currentid); Debug("Start FnCall %s args level %d\n",P.currentfnid[P.arg_nesting],P.arg_nesting); } break; case 70: /* Line 1806 of yacc.c */ #line 488 "cf3parse.y" { Debug("End args level %d\n",P.arg_nesting); P.currentfncall[P.arg_nesting] = NewFnCall(P.currentfnid[P.arg_nesting],P.giveargs[P.arg_nesting]); P.giveargs[P.arg_nesting] = NULL; strcpy(P.currentid,""); free(P.currentfnid[P.arg_nesting]); P.currentfnid[P.arg_nesting] = NULL; P.arg_nesting--; } break; case 74: /* Line 1806 of yacc.c */ #line 508 "cf3parse.y" { /* currently inside a use function */ AppendRlist(&P.giveargs[P.arg_nesting],P.currentid,CF_SCALAR); } break; case 75: /* Line 1806 of yacc.c */ #line 514 "cf3parse.y" { /* currently inside a use function */ AppendRlist(&P.giveargs[P.arg_nesting],P.currentstring,CF_SCALAR); free(P.currentstring); P.currentstring = NULL; } break; case 76: /* Line 1806 of yacc.c */ #line 522 "cf3parse.y" { /* currently inside a use function */ AppendRlist(&P.giveargs[P.arg_nesting],P.currentstring,CF_SCALAR); free(P.currentstring); P.currentstring = NULL; } break; case 77: /* Line 1806 of yacc.c */ #line 530 "cf3parse.y" { /* Careful about recursion */ AppendRlist(&P.giveargs[P.arg_nesting],(void *)P.currentfncall[P.arg_nesting+1],CF_FNCALL); DeleteRvalItem(P.currentfncall[P.arg_nesting+1],CF_FNCALL); } break; /* Line 1806 of yacc.c */ #line 2001 "cf3parse.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. One alternative is translating here after every semantic action, but that translation would be missed if the semantic action invokes YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an incorrect destructor might then be invoked immediately. In the case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ 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: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ yyssp, yytoken) { char const *yymsgp = YY_("syntax error"); int yysyntax_error_status; yysyntax_error_status = YYSYNTAX_ERROR; if (yysyntax_error_status == 0) yymsgp = yymsg; else if (yysyntax_error_status == 1) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); if (!yymsg) { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; yysyntax_error_status = 2; } else { yysyntax_error_status = YYSYNTAX_ERROR; yymsgp = yymsg; } } yyerror (yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; } # undef YYSYNTAX_ERROR #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 (!yypact_value_is_default (yyn)) { 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) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); 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); } /* Line 2067 of yacc.c */ #line 536 "cf3parse.y" /*****************************************************************/ void yyerror(const char *s) { char *sp = yytext; if (sp == NULL) { fprintf (stderr, "%s> %s:%d,%d: %s, near token \'NULL\'\n",VPREFIX,P.filename,P.line_no,P.line_pos,s); } else if (*sp == '\"' && strlen(sp) > 1) { sp++; } fprintf (stderr, "%s> %s:%d,%d: %s, near token \'%.20s\'\n",VPREFIX,P.filename,P.line_no,P.line_pos,s,sp); ERRORCOUNT++; if (ERRORCOUNT > 10) { FatalError("Too many errors"); } } static void fatal_yyerror(const char *s) { char *sp = yytext; /* Skip quotation mark */ if (sp && *sp == '\"' && sp[1]) { sp++; } FatalError("%s> %s: %d,%d: Fatal error during parsing: %s, near token \'%.20s\'\n", VPREFIX, P.filename, P.line_no, P.line_pos, s, sp ? sp : "NULL"); } /*****************************************************************/ /* EOF */ ����������������������������������������������������������������������������������������cfengine-3.2.4/src/cf3parse.h�����������������������������������������������������������������������0000644�0001750�0001750�00000004407�11715233327�012676� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* A Bison parser, made by GNU Bison 2.5. */ /* Bison interface for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2011 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 <http://www.gnu.org/licenses/>. */ /* 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 { ID = 258, QSTRING = 259, CLASS = 260, CATEGORY = 261, BUNDLE = 262, BODY = 263, ASSIGN = 264, ARROW = 265, NAKEDVAR = 266 }; #endif /* Tokens. */ #define ID 258 #define QSTRING 259 #define CLASS 260 #define CATEGORY 261 #define BUNDLE 262 #define BODY 263 #define ASSIGN 264 #define ARROW 265 #define NAKEDVAR 266 #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; ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/verify_packages.c����������������������������������������������������������������0000644�0001750�0001750�00000210432�11715232734�014323� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: verify_packages.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void VerifyPromisedPatch(struct Attributes a,struct Promise *pp); static int ExecuteSchedule(struct CfPackageManager *schedule,enum package_actions action); static int ExecutePatch(struct CfPackageManager *schedule,enum package_actions action); static int PackageSanityCheck(struct Attributes a,struct Promise *pp); static int VerifyInstalledPackages(struct CfPackageManager **alllists,struct Attributes a,struct Promise *pp); static void VerifyPromisedPackage(struct Attributes a,struct Promise *pp); static void DeletePackageItems(struct CfPackageItem *pi); static int PackageMatch(char *n,char *v,char *a,struct Attributes attr,struct Promise *pp); static int PatchMatch(char *n,char *v,char *a,struct Attributes attr,struct Promise *pp); static int ComparePackages(char *n,char *v,char *a,struct CfPackageItem *pi,enum version_cmp cmp); static void ParsePackageVersion(char *version,struct Rlist **num,struct Rlist **sep); static void SchedulePackageOp(char *name,char *version,char *arch,int installed,int matched,int novers,struct Attributes a,struct Promise *pp); static char *PrefixLocalRepository(struct Rlist *repositories,char *package); static int FindLargestVersionAvail(char *matchName, char *matchVers, char *refAnyVer, char *ver, enum version_cmp package_select, struct Rlist *repositories); static int VersionCmp(char *vs1, char *vs2); static int IsNewerThanInstalled(char *n,char *v,char *a, char *instV, char *instA, struct Attributes attr); static int PackageInItemList(struct CfPackageItem *list,char *name,char *version,char *arch); static int ExecPackageCommandGeneric(char *command,int verify,int setCmdClasses,struct Attributes a,struct Promise *pp); static int PrependPatchItem(struct CfPackageItem **list,char *item,struct CfPackageItem *chklist,struct Attributes a,struct Promise *pp); static int PrependMultiLinePackageItem(struct CfPackageItem **list,char *item,int reset,struct Attributes a,struct Promise *pp); static int ExecPackageCommand(char *command,int verify,int setCmdClasses,struct Attributes a,struct Promise *pp); static void ReportSoftware(struct CfPackageManager *list); static const char *GetSoftwareCacheFilename(char *buffer); static void InvalidateSoftwareCache(void); static void ExecutePackageSchedule(struct CfPackageManager *schedule); static void DeletePackageManagers(struct CfPackageManager *newlist); static struct CfPackageManager *NewPackageManager(struct CfPackageManager **lists,char *mgr,enum package_actions pa,enum action_policy x); static struct CfPackageItem *GetCachedPackageList(struct CfPackageManager *manager,struct Attributes a,struct Promise *pp); /*****************************************************************************/ struct CfPackageManager *PACKAGE_SCHEDULE = NULL; struct CfPackageManager *INSTALLED_PACKAGE_LISTS = NULL; /*****************************************************************************/ void VerifyPackagesPromise(struct Promise *pp) { struct Attributes a = {{0}},al = {{0}}; struct CfLock thislock; char lockname[CF_BUFSIZE]; a = GetPackageAttributes(pp); #ifdef MINGW a.packages.package_list_command = "/Windows_Installer"; #endif if (!PackageSanityCheck(a,pp)) { return; } PromiseBanner(pp); // Now verify the package itself snprintf(lockname,CF_BUFSIZE-1,"package-%s-%s",pp->promiser,a.packages.package_list_command); thislock = AcquireLock(lockname,VUQNAME,CFSTARTTIME,a,pp,false); if (thislock.lock == NULL) { return; } // Start by reseting the root directory in case yum tries to glob regexs(!) chdir("/"); if (!VerifyInstalledPackages(&INSTALLED_PACKAGE_LISTS,a,pp)) { cfPS(cf_error,CF_FAIL,"",pp,a," !! Unable to obtain a list of installed packages - aborting"); return; } switch (a.packages.package_policy) { case cfa_patch: VerifyPromisedPatch(a,pp); break; default: VerifyPromisedPackage(a,pp); break; } YieldCurrentLock(thislock); } /*****************************************************************************/ static int PackageSanityCheck(struct Attributes a,struct Promise *pp) { #ifndef MINGW if (a.packages.package_list_version_regex == NULL) { cfPS(cf_error,CF_FAIL,"",pp,a," !! You must supply a method for determining the version of existing packages"); return false; } if (a.packages.package_list_name_regex == NULL) { cfPS(cf_error,CF_FAIL,"",pp,a," !! You must supply a method for determining the name of existing packages"); return false; } #endif /* NOT MINGW */ if (a.packages.package_list_command == NULL && a.packages.package_file_repositories == NULL) { cfPS(cf_error,CF_FAIL,"",pp,a," !! You must supply a method for determining the list of existing packages (a command or repository list)"); return false; } if (a.packages.package_file_repositories) { struct Rlist *rp; for (rp = a.packages.package_file_repositories; rp != NULL; rp = rp->next) { if (strlen(rp->item) > CF_MAXVARSIZE-1) { cfPS(cf_error,CF_FAIL,"",pp,a," !! The repository path \"%s\" is too long",rp->item); return false; } } } if (a.packages.package_name_regex||a.packages.package_version_regex||a.packages.package_arch_regex) { if (a.packages.package_name_regex && a.packages.package_version_regex && a.packages.package_arch_regex) { if(a.packages.package_version || a.packages.package_architectures) { cfPS(cf_error,CF_FAIL,"",pp,a," !! You must either supply all regexs for (name,version,arch) xor a separate version number and architecture"); return false; } } else { if (a.packages.package_version && a.packages.package_architectures) { cfPS(cf_error,CF_FAIL,"",pp,a," !! You must either supply all regexs for (name,version,arch) xor a separate version number and architecture"); return false; } } } if (a.packages.package_add_command == NULL || a.packages.package_delete_command == NULL) { cfPS(cf_verbose,CF_FAIL,"",pp,a,"!! Package add/delete command undefined"); return false; } if (!a.packages.package_installed_regex) { cfPS(cf_verbose,CF_FAIL,"",pp,a,"!! Package installed regex undefined"); return false; } if(a.packages.package_policy == cfa_verifypack) { if(!a.packages.package_verify_command) { cfPS(cf_verbose,CF_FAIL,"",pp,a,"!! Package verify policy is used, but no package_verify_command is defined"); return false; } else if((a.packages.package_noverify_returncode == CF_NOINT) && (a.packages.package_noverify_regex == NULL)) { cfPS(cf_verbose,CF_FAIL,"",pp,a,"!! Package verify policy is used, but no definition of verification failiure is set (package_noverify_returncode or packages.package_noverify_regex)"); return false; } } if((a.packages.package_noverify_returncode != CF_NOINT) && a.packages.package_noverify_regex) { cfPS(cf_verbose,CF_FAIL,"",pp,a,"!! Both package_noverify_returncode and package_noverify_regex are defined, pick one of them"); return false; } return true; } /*****************************************************************************/ void ExecuteScheduledPackages(void) { if (PACKAGE_SCHEDULE) { ExecutePackageSchedule(PACKAGE_SCHEDULE); } } void CleanScheduledPackages(void) { DeletePackageManagers(PACKAGE_SCHEDULE); PACKAGE_SCHEDULE = NULL; DeletePackageManagers(INSTALLED_PACKAGE_LISTS); INSTALLED_PACKAGE_LISTS = NULL; } /*****************************************************************************/ static void ExecutePackageSchedule(struct CfPackageManager *schedule) { CfOut(cf_verbose,""," >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); CfOut(cf_verbose,""," Offering these package-promise suggestions to the managers\n"); CfOut(cf_verbose,""," >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); /* Normal ordering */ CfOut(cf_verbose,""," -> Deletion schedule...\n"); if (!ExecuteSchedule(schedule,cfa_deletepack)) { CfOut(cf_error,"","Aborting package schedule"); return; } CfOut(cf_verbose,""," -> Addition schedule...\n"); if (!ExecuteSchedule(schedule,cfa_addpack)) { return; } CfOut(cf_verbose,""," -> Update schedule...\n"); if (!ExecuteSchedule(schedule,cfa_update)) { return; } CfOut(cf_verbose,""," -> Patch schedule...\n"); if (!ExecutePatch(schedule,cfa_patch)) { return; } CfOut(cf_verbose,""," -> Verify schedule...\n"); if (!ExecuteSchedule(schedule,cfa_verifypack)) { return; } } /*****************************************************************************/ /* Level */ /*****************************************************************************/ static int VerifyInstalledPackages(struct CfPackageManager **all_mgrs,struct Attributes a,struct Promise *pp) { struct CfPackageManager *manager = NewPackageManager(all_mgrs,a.packages.package_list_command,cfa_pa_none,cfa_no_ppolicy); const int reset = true, update = false; char vbuff[CF_BUFSIZE]; FILE *prp; if (manager == NULL) { CfOut(cf_error,""," !! Can't create a package manager envelope for \"%s\"",a.packages.package_list_command); return false; } if (manager->pack_list != NULL) { CfOut(cf_verbose,""," ?? Already have a package list for this manager "); return true; } manager->pack_list = GetCachedPackageList(manager,a,pp); if (manager->pack_list != NULL) { CfOut(cf_verbose,""," ?? Already have a (cached) package list for this manager "); return true; } #ifdef MINGW CfOut(cf_verbose, "", " Using internal list command for Windows"); if (!NovaWin_GetInstalledPkgs(&(manager->pack_list),a,pp)) { CfOut(cf_error, "", "!! Could not get list of installed packages"); return false; } #else if (a.packages.package_list_command != NULL) { if(strcmp(a.packages.package_list_command,"/cf_internal_rpath_list") == 0) { CfOut(cf_verbose, "", " Using internal list command for rPath"); if(!GetInstalledPkgsRpath(&(manager->pack_list),a,pp)) { CfOut(cf_error, "", "!! Could not get list of installed packages"); return false; } } else { if (a.packages.package_list_update_command != NULL) { ExecPackageCommand(a.packages.package_list_update_command,false,false,a,pp); } CfOut(cf_verbose,""," ???????????????????????????????????????????????????????????????\n"); CfOut(cf_verbose,""," Reading package list from %s\n",GetArg0(a.packages.package_list_command)); CfOut(cf_verbose,""," ???????????????????????????????????????????????????????????????\n"); if (!IsExecutable(GetArg0(a.packages.package_list_command))) { CfOut(cf_error,"","The proposed package list command \"%s\" was not executable",a.packages.package_list_command); return false; } if ((prp = cf_popen(a.packages.package_list_command,"r")) == NULL) { CfOut(cf_error,"cf_popen","Couldn't open the package list with command %s\n",a.packages.package_list_command); return false; } while (!feof(prp)) { memset(vbuff,0,CF_BUFSIZE); CfReadLine(vbuff,CF_BUFSIZE,prp); CF_OCCUR++; if (a.packages.package_multiline_start) { if (FullTextMatch(a.packages.package_multiline_start,vbuff)) { PrependMultiLinePackageItem(&(manager->pack_list),vbuff,reset,a,pp); } else { PrependMultiLinePackageItem(&(manager->pack_list),vbuff,update,a,pp); } } else { if (!FullTextMatch(a.packages.package_installed_regex,vbuff)) { continue; } if (!PrependListPackageItem(&(manager->pack_list),vbuff,a,pp)) { continue; } } } cf_pclose(prp); } } #endif /* NOT MINGW */ ReportSoftware(INSTALLED_PACKAGE_LISTS); /* Now get available updates */ if (a.packages.package_patch_list_command != NULL) { CfOut(cf_verbose,""," ???????????????????????????????????????????????????????????????\n"); CfOut(cf_verbose,""," Reading patches from %s\n",GetArg0(a.packages.package_patch_list_command)); CfOut(cf_verbose,""," ???????????????????????????????????????????????????????????????\n"); if (!IsExecutable(GetArg0(a.packages.package_patch_list_command))) { CfOut(cf_error,"","The proposed patch list command \"%s\" was not executable",a.packages.package_patch_list_command); return false; } if ((prp = cf_popen(a.packages.package_patch_list_command,"r")) == NULL) { CfOut(cf_error,"cf_popen","Couldn't open the patch list with command %s\n",a.packages.package_patch_list_command); return false; } while (!feof(prp)) { memset(vbuff,0,CF_BUFSIZE); CfReadLine(vbuff,CF_BUFSIZE,prp); // assume patch_list_command lists available patches/updates by default if (a.packages.package_patch_installed_regex == NULL || !FullTextMatch(a.packages.package_patch_installed_regex,vbuff)) { PrependPatchItem(&(manager->patch_avail),vbuff,manager->patch_list,a,pp); continue; } if (!PrependPatchItem(&(manager->patch_list),vbuff,manager->patch_list,a,pp)) { continue; } } cf_pclose(prp); } ReportPatches(INSTALLED_PACKAGE_LISTS); CfOut(cf_verbose,""," ???????????????????????????????????????????????????????????????\n"); CfOut(cf_verbose,""," Done checking packages and patches \n"); CfOut(cf_verbose,""," ???????????????????????????????????????????????????????????????\n"); return true; } /*****************************************************************************/ static int VersionCheckSchedulePackage(struct Attributes a, struct Promise *pp, int matches, int installed) { /* The meaning of matches and installed depends on the package policy */ enum package_actions policy = a.packages.package_policy; switch(policy) { case cfa_deletepack: if (matches && installed) { return true; } break; case cfa_reinstall: if (matches && installed) { return true; } else { cfPS(cf_verbose,CF_NOP,"",pp,a," -> Package (%s) already installed and matches criteria\n",pp->promiser); } break; default: if (!installed || !matches) { return true; } else { cfPS(cf_verbose,CF_NOP,"",pp,a," -> Package (%s) already installed and matches criteria\n",pp->promiser); } break; } return false; } /*****************************************************************************/ static void VerifyPromisedPackage(struct Attributes a,struct Promise *pp) { char version[CF_MAXVARSIZE]; char name[CF_MAXVARSIZE]; char arch[CF_MAXVARSIZE]; char *package = pp->promiser; int matches = 0, installed = 0, no_version = false; struct Rlist *rp; if (a.packages.package_version) { /* The version is specified separately */ CfOut(cf_verbose,""," -> Package version specified explicitly in promise body"); if (a.packages.package_architectures == NULL) { strncpy(name,pp->promiser,CF_MAXVARSIZE-1); strncpy(version,a.packages.package_version,CF_MAXVARSIZE-1); strncpy(arch,"*",CF_MAXVARSIZE-1); installed = PackageMatch(name,"*",arch,a,pp); matches = PackageMatch(name,version,arch,a,pp); if (VersionCheckSchedulePackage(a, pp, matches, installed)) { SchedulePackageOp(name,version,arch,installed,matches,no_version,a,pp); } } else { for (rp = a.packages.package_architectures; rp != NULL; rp=rp->next) { CfOut(cf_verbose,""," ... trying listed arch %s\n",rp->item); strncpy(name,pp->promiser,CF_MAXVARSIZE-1); strncpy(version,a.packages.package_version,CF_MAXVARSIZE-1); strncpy(arch,rp->item,CF_MAXVARSIZE-1); installed = PackageMatch(name,"*",arch,a,pp); matches = PackageMatch(name,version,arch,a,pp); if (VersionCheckSchedulePackage(a, pp, matches, installed)) { SchedulePackageOp(name,version,arch,installed,matches,no_version,a,pp); } } } } else if (a.packages.package_version_regex) { /* The name, version and arch are to be extracted from the promiser */ CfOut(cf_verbose,""," -> Package version specified implicitly in promiser's name"); strlcpy(version,ExtractFirstReference(a.packages.package_version_regex,package),CF_MAXVARSIZE); strlcpy(name,ExtractFirstReference(a.packages.package_name_regex,package),CF_MAXVARSIZE); strlcpy(arch,ExtractFirstReference(a.packages.package_arch_regex,package),CF_MAXVARSIZE); if (strlen(arch) == 0) { strncpy(arch,"*",CF_MAXVARSIZE-1); } if (strcmp(arch,"CF_NOMATCH") == 0) // no match on arch regex, use any arch { strcpy(arch,"*"); } installed = PackageMatch(name,"*",arch,a,pp); matches = PackageMatch(name,version,arch,a,pp); if (VersionCheckSchedulePackage(a, pp, matches, installed)) { SchedulePackageOp(name,version,arch,installed,matches,no_version,a,pp); } } else { no_version = true; CfOut(cf_verbose,""," -> Package version was not specified"); if (a.packages.package_architectures == NULL) { strncpy(name,pp->promiser,CF_MAXVARSIZE-1); strncpy(version,"*",CF_MAXVARSIZE-1); strncpy(arch,"*",CF_MAXVARSIZE-1); installed = PackageMatch(name,"*",arch,a,pp); matches = PackageMatch(name,version,arch,a,pp); SchedulePackageOp(name,version,arch,installed,matches,no_version,a,pp); } else { for (rp = a.packages.package_architectures; rp != NULL; rp=rp->next) { CfOut(cf_verbose,""," ... trying listed arch %s\n",rp->item); strncpy(name,pp->promiser,CF_MAXVARSIZE-1); strncpy(version,"*",CF_MAXVARSIZE-1); strncpy(arch,rp->item,CF_MAXVARSIZE-1); installed = PackageMatch(name,"*",arch,a,pp); matches = PackageMatch(name,version,arch,a,pp); SchedulePackageOp(name,version,arch,installed,matches,no_version,a,pp); } } } } /*****************************************************************************/ static void VerifyPromisedPatch(struct Attributes a,struct Promise *pp) { char version[CF_MAXVARSIZE]; char name[CF_MAXVARSIZE]; char arch[CF_MAXVARSIZE]; char *package = pp->promiser; int matches = 0, installed = 0, no_version = false; struct Rlist *rp; if (a.packages.package_version) { /* The version is specified separately */ for (rp = a.packages.package_architectures; rp != NULL; rp=rp->next) { strncpy(name,pp->promiser,CF_MAXVARSIZE-1); strncpy(version,a.packages.package_version,CF_MAXVARSIZE-1); strncpy(arch,rp->item,CF_MAXVARSIZE-1); installed += PatchMatch(name,"*","*",a,pp); matches += PatchMatch(name,version,arch,a,pp); } if (a.packages.package_architectures == NULL) { strncpy(name,pp->promiser,CF_MAXVARSIZE-1); strncpy(version,a.packages.package_version,CF_MAXVARSIZE-1); strncpy(arch,"*",CF_MAXVARSIZE-1); installed = PatchMatch(name,"*","*",a,pp); matches = PatchMatch(name,version,arch,a,pp); } } else if (a.packages.package_version_regex) { /* The name, version and arch are to be extracted from the promiser */ strncpy(version,ExtractFirstReference(a.packages.package_version_regex,package),CF_MAXVARSIZE-1); strncpy(name,ExtractFirstReference(a.packages.package_name_regex,package),CF_MAXVARSIZE-1); strncpy(arch,ExtractFirstReference(a.packages.package_arch_regex,package),CF_MAXVARSIZE-1); installed = PatchMatch(name,"*","*",a,pp); matches = PatchMatch(name,version,arch,a,pp); } else { no_version = true; for (rp = a.packages.package_architectures; rp != NULL; rp=rp->next) { strncpy(name,pp->promiser,CF_MAXVARSIZE-1); strncpy(version,"*",CF_MAXVARSIZE-1); strncpy(arch,rp->item,CF_MAXVARSIZE-1); installed += PatchMatch(name,"*","*",a,pp); matches += PatchMatch(name,version,arch,a,pp); } if (a.packages.package_architectures == NULL) { strncpy(name,pp->promiser,CF_MAXVARSIZE-1); strncpy(version,"*",CF_MAXVARSIZE-1); strncpy(arch,"*",CF_MAXVARSIZE-1); installed = PatchMatch(name,"*","*",a,pp); matches = PatchMatch(name,version,arch,a,pp); } } CfOut(cf_verbose,""," -> %d patch(es) matching the name \"%s\" already installed\n",installed,name); CfOut(cf_verbose,""," -> %d patch(es) match the promise body's criteria fully\n",matches,name); SchedulePackageOp(name,version,arch,installed,matches,no_version,a,pp); } /*****************************************************************************/ static int ExecuteSchedule(struct CfPackageManager *schedule,enum package_actions action) { struct CfPackageItem *pi; struct CfPackageManager *pm; int size,estimated_size,retval = true,verify = false; char *command_string = NULL; struct Attributes a = {{0}}; struct Promise *pp; int ok; for (pm = schedule; pm != NULL; pm = pm->next) { if (pm->action != action) { continue; } if (pm->pack_list == NULL) { continue; } estimated_size = 0; for (pi = pm->pack_list; pi != NULL; pi=pi->next) { size = strlen(pi->name) + strlen(" "); switch (pm->policy) { case cfa_individual: if (size > estimated_size) { estimated_size = size + CF_MAXVARSIZE; } break; case cfa_bulk: estimated_size += size + CF_MAXVARSIZE; break; default: break; } } pp = pm->pack_list->pp; a = GetPackageAttributes(pp); switch (action) { case cfa_addpack: if (a.packages.package_add_command == NULL) { cfPS(cf_verbose,CF_FAIL,"",pp,a,"Package package add command undefined"); return false; } CfOut(cf_verbose,"","Execute scheduled package addition"); if ((command_string = (malloc(estimated_size + strlen(a.packages.package_add_command) + 2)))) { strcpy(command_string,a.packages.package_add_command); } break; case cfa_deletepack: if (a.packages.package_delete_command == NULL) { cfPS(cf_verbose,CF_FAIL,"",pp,a,"Package delete command undefined"); return false; } CfOut(cf_verbose,"","Execute scheduled package deletion"); if ((command_string = (malloc(estimated_size + strlen(a.packages.package_delete_command) + 2)))) { strcpy(command_string,a.packages.package_delete_command); } break; case cfa_update: CfOut(cf_verbose,"","Execute scheduled package update"); if (a.packages.package_update_command == NULL) { cfPS(cf_verbose,CF_FAIL,"",pp,a,"Package update command undefined"); return false; } if ((command_string = (malloc(estimated_size + strlen(a.packages.package_update_command) + 2)))) { memset(command_string, 0, strlen(a.packages.package_update_command) + 2); strcpy(command_string,a.packages.package_update_command); } break; case cfa_verifypack: CfOut(cf_verbose,"","Execute scheduled package verification"); if (a.packages.package_verify_command == NULL) { cfPS(cf_verbose,CF_FAIL,"",pp,a,"Package verify command undefined"); return false; } if ((command_string = (malloc(estimated_size + strlen(a.packages.package_verify_command) + 2)))) { strcpy(command_string,a.packages.package_verify_command); } verify = true; break; default: cfPS(cf_verbose,CF_FAIL,"",pp,a,"Unknown action attempted"); return false; } /* if the command ends with $ then we assume the package manager does not accept package names */ if (*(command_string+strlen(command_string)-1) == '$') { *(command_string+strlen(command_string)-1) = '\0'; CfOut(cf_verbose,"","Command does not allow arguments"); if (ExecPackageCommand(command_string,verify,true,a,pp)) { CfOut(cf_verbose,"","Package schedule execution ok (outcome cannot be promised by cf-agent)"); } else { CfOut(cf_error,"","!! Package schedule execution failed"); } } else { strcat(command_string," "); CfOut(cf_verbose,"","Command prefix: %s\n",command_string); switch (pm->policy) { case cfa_individual: for (pi = pm->pack_list; pi != NULL; pi=pi->next) { char *sp,*offset = command_string + strlen(command_string); if (a.packages.package_file_repositories && ( action == cfa_addpack || action == cfa_update ) ) { if ((sp = PrefixLocalRepository(a.packages.package_file_repositories,pi->name)) != NULL) { strcat(offset,sp); } else { break; } } else { strcat(offset,pi->name); } if (ExecPackageCommand(command_string,verify,true,a,pp)) { CfOut(cf_verbose,"","Package schedule execution ok for %s (outcome cannot be promised by cf-agent)",pi->name); } else { CfOut(cf_error,"","Package schedule execution failed for %s",pi->name); } *offset = '\0'; } break; case cfa_bulk: for (pi = pm->pack_list; pi != NULL; pi=pi->next) { if (pi->name) { char *sp, *offset = command_string + strlen(command_string); if (a.packages.package_file_repositories && ( action == cfa_addpack || action == cfa_update ) ) { if ((sp = PrefixLocalRepository(a.packages.package_file_repositories,pi->name)) != NULL) { strcat(offset,sp); } else { break; } } else { strcat(offset,pi->name); } strcat(command_string," "); } } ok = ExecPackageCommand(command_string,verify,true,a,pp); for (pi = pm->pack_list; pi != NULL; pi=pi->next) { if (ok) { CfOut(cf_verbose,"","Bulk package schedule execution ok for %s (outcome cannot be promised by cf-agent)",pi->name); } else { CfOut(cf_error,"","Bulk package schedule execution failed somewhere - unknown outcome for %s",pi->name); } } break; default: break; } } } if (command_string) { free(command_string); } /* We have performed some operation on packages, our cache is invalid */ InvalidateSoftwareCache(); return retval; } /*****************************************************************************/ static int ExecutePatch(struct CfPackageManager *schedule,enum package_actions action) { struct CfPackageItem *pi; struct CfPackageManager *pm; int size,estimated_size,retval = true,verify = false; char *command_string = NULL; struct Attributes a = {{0}}; struct Promise *pp; for (pm = schedule; pm != NULL; pm = pm->next) { if (pm->action != action) { continue; } if (pm->patch_list == NULL) { continue; } estimated_size = 0; for (pi = pm->patch_list; pi != NULL; pi=pi->next) { size = strlen(pi->name) + strlen(" "); switch (pm->policy) { case cfa_individual: if (size > estimated_size) { estimated_size = size; } break; case cfa_bulk: estimated_size += size; break; default: break; } } pp = pm->patch_list->pp; a = GetPackageAttributes(pp); switch (action) { case cfa_patch: CfOut(cf_verbose,"","Execute scheduled package patch"); if (a.packages.package_patch_command == NULL) { cfPS(cf_verbose,CF_FAIL,"",pp,a,"Package patch command undefined"); return false; } if ((command_string = (malloc(estimated_size + strlen(a.packages.package_patch_command) + 2)))) { strcpy(command_string,a.packages.package_patch_command); } break; default: cfPS(cf_verbose,CF_FAIL,"",pp,a,"Unknown action attempted"); return false; } /* if the command ends with $ then we assume the package manager does not accept package names */ if (*(command_string+strlen(command_string)-1) == '$') { *(command_string+strlen(command_string)-1) = '\0'; CfOut(cf_verbose,"","Command does not allow arguments"); if (ExecPackageCommand(command_string,verify,true,a,pp)) { CfOut(cf_verbose,"","Package patching seemed to succeed (outcome cannot be promised by cf-agent)"); } else { CfOut(cf_error,"","Package patching failed"); } } else { strcat(command_string," "); CfOut(cf_verbose,"","Command prefix: %s\n",command_string); switch (pm->policy) { int ok; case cfa_individual: for (pi = pm->patch_list; pi != NULL; pi=pi->next) { char *offset = command_string + strlen(command_string); strcat(offset,pi->name); if (ExecPackageCommand(command_string,verify,true,a,pp)) { CfOut(cf_verbose,"","Package schedule execution ok for %s (outcome cannot be promised by cf-agent)",pi->name); } else { CfOut(cf_error,"","Package schedule execution failed for %s",pi->name); } *offset = '\0'; } break; case cfa_bulk: for (pi = pm->patch_list; pi != NULL; pi=pi->next) { if (pi->name) { strcat(command_string,pi->name); strcat(command_string," "); } } ok = ExecPackageCommand(command_string,verify,true,a,pp); for (pi = pm->patch_list; pi != NULL; pi=pi->next) { if (ok) { CfOut(cf_verbose,"","Bulk package schedule execution ok for %s (outcome cannot be promised by cf-agent)",pi->name); } else { CfOut(cf_error,"","Bulk package schedule execution failed somewhere - unknown outcome for %s",pi->name); } } break; default: break; } } } if (command_string) { free(command_string); } /* We have performed some operation on packages, our cache is invalid */ InvalidateSoftwareCache(); return retval; } /*****************************************************************************/ /* Level */ /*****************************************************************************/ static struct CfPackageManager *NewPackageManager(struct CfPackageManager **lists,char *mgr,enum package_actions pa,enum action_policy policy) { struct CfPackageManager *np; if (mgr == NULL || strlen(mgr) == 0) { CfOut(cf_error,""," !! Attempted to create a package manager with no name"); return NULL; } for (np = *lists; np != NULL; np=np->next) { if ((strcmp(np->manager,mgr) == 0) && (policy == np->policy)) { return np; } } if ((np = (struct CfPackageManager *)malloc(sizeof(struct CfPackageManager))) == NULL) { CfOut(cf_error,"malloc","Can't allocate new package\n"); return NULL; } np->manager = strdup(mgr); np->action = pa; np->policy = policy; np->pack_list = NULL; np->patch_list = NULL; np->patch_avail = NULL; np->next = *lists; *lists = np; return np; } /*****************************************************************************/ static void DeletePackageManagers(struct CfPackageManager *newlist) { struct CfPackageManager *np,*next; for (np = newlist; np != NULL; np = next) { next = np->next; DeletePackageItems(np->pack_list); free((char *)np); } } /*****************************************************************************/ static struct CfPackageItem *GetCachedPackageList(struct CfPackageManager *manager,struct Attributes a,struct Promise *pp) { struct CfPackageItem *list = NULL; char name[CF_MAXVARSIZE],version[CF_MAXVARSIZE],arch[CF_MAXVARSIZE],mgr[CF_MAXVARSIZE],line[CF_BUFSIZE]; char thismanager[CF_MAXVARSIZE]; FILE *fin; time_t horizon = 24*60,now = time(NULL); struct stat sb; GetSoftwareCacheFilename(name); if (stat(name,&sb) == -1) { return NULL; } if (a.packages.package_list_update_ifelapsed != CF_NOINT) { horizon = a.packages.package_list_update_ifelapsed; } if (now - sb.st_mtime < horizon*60) { CfOut(cf_verbose,""," -> Cache file exists and is sufficiently fresh according to (package_list_update_ifelapsed)"); } else { CfOut(cf_verbose,""," -> Cache file exists, but it is out of date (package_list_update_ifelapsed)"); return NULL; } if ((fin = fopen(name,"r")) == NULL) { CfOut(cf_inform,"fopen","Cannot open the source log %s - you need to run a package discovery promise to create it in cf-agent",name); return NULL; } /* Max 2016 entries - at least a week */ snprintf(thismanager,CF_MAXVARSIZE-1,"%s",ReadLastNode(GetArg0(manager->manager))); while (!feof(fin)) { line[0] = '\0'; fgets(line,CF_BUFSIZE-1,fin); sscanf(line,"%250[^,],%250[^,],%250[^,],%250[^\n]",name,version,arch,mgr); if (strcmp(thismanager,mgr) == 0) { Debug("READPKG: %s\n",line); PrependPackageItem(&list,name,version,arch,a,pp); } } fclose(fin); return list; } /*****************************************************************************/ static int PrependMultiLinePackageItem(struct CfPackageItem **list,char *item,int reset,struct Attributes a,struct Promise *pp) { static char name[CF_MAXVARSIZE]; static char arch[CF_MAXVARSIZE]; static char version[CF_MAXVARSIZE]; static char vbuff[CF_MAXVARSIZE]; if (reset) { if (strcmp(name,"CF_NOMATCH") == 0 || strcmp(version,"CF_NOMATCH") == 0) { return false; } if (strcmp(name,"") != 0 || strcmp(version,"") != 0) { Debug(" -? Extracted package name \"%s\"\n",name); Debug(" -? with version \"%s\"\n",version); Debug(" -? with architecture \"%s\"\n",arch); PrependPackageItem(list,name,version,arch,a,pp); } strcpy(name,"CF_NOMATCH"); strcpy(version,"CF_NOMATCH"); strcpy(arch,"default"); } if (FullTextMatch(a.packages.package_list_name_regex,item)) { strlcpy(vbuff,ExtractFirstReference(a.packages.package_list_name_regex,item),CF_MAXVARSIZE); sscanf(vbuff,"%s",name); /* trim */ } if (FullTextMatch(a.packages.package_list_version_regex,item)) { strncpy(vbuff,ExtractFirstReference(a.packages.package_list_version_regex,item),CF_MAXVARSIZE-1); sscanf(vbuff,"%s",version); /* trim */ } if (a.packages.package_list_arch_regex && FullTextMatch(a.packages.package_list_arch_regex,item)) { if (a.packages.package_list_arch_regex) { strncpy(vbuff,ExtractFirstReference(a.packages.package_list_arch_regex,item),CF_MAXVARSIZE-1); sscanf(vbuff,"%s",arch); /* trim */ } } return false; } /*****************************************************************************/ static int PrependPatchItem(struct CfPackageItem **list,char *item,struct CfPackageItem *chklist,struct Attributes a,struct Promise *pp) { char name[CF_MAXVARSIZE]; char arch[CF_MAXVARSIZE]; char version[CF_MAXVARSIZE]; char vbuff[CF_MAXVARSIZE]; strncpy(vbuff,ExtractFirstReference(a.packages.package_patch_name_regex,item),CF_MAXVARSIZE-1); sscanf(vbuff,"%s",name); /* trim */ strncpy(vbuff,ExtractFirstReference(a.packages.package_patch_version_regex,item),CF_MAXVARSIZE-1); sscanf(vbuff,"%s",version); /* trim */ if (a.packages.package_patch_arch_regex) { strncpy(vbuff,ExtractFirstReference(a.packages.package_patch_arch_regex,item),CF_MAXVARSIZE-1); sscanf(vbuff,"%s",arch); /* trim */ } else { strncpy(arch,"default",CF_MAXVARSIZE-1); } if (strcmp(name,"CF_NOMATCH") == 0 || strcmp(version,"CF_NOMATCH") == 0 || strcmp(arch,"CF_NOMATCH") == 0) { return false; } Debug(" ?? Patch line: \"%s\"",item); Debug(" -? with name \"%s\"\n",name); Debug(" -? with version \"%s\"\n",version); Debug(" -? with architecture \"%s\"\n",arch); if (PackageInItemList(chklist,name,version,arch)) { CfOut(cf_verbose,""," -> Patch for (%s,%s,%s) found, but it appears to be installed already",name,version,arch); return false; } return PrependPackageItem(list,name,version,arch,a,pp); } /*****************************************************************************/ static void DeletePackageItems(struct CfPackageItem *pi) { if (pi) { free(pi->name); free(pi->version); free(pi->arch); DeletePromise(pi->pp); free(pi); } } /*****************************************************************************/ static int PackageMatch(char *n,char *v,char *a,struct Attributes attr,struct Promise *pp) /* * Returns true if any installed packages match (n,v,a), false otherwise. */ { struct CfPackageManager *mp = NULL; struct CfPackageItem *pi; for (mp = INSTALLED_PACKAGE_LISTS; mp != NULL; mp = mp->next) { if (strcmp(mp->manager,attr.packages.package_list_command) == 0) { break; } } CfOut(cf_verbose,""," -> Looking for (%s,%s,%s)\n",n,v,a); for (pi = mp->pack_list; pi != NULL; pi=pi->next) { if (ComparePackages(n,v,a,pi,attr.packages.package_select)) { return true; } } CfOut(cf_verbose,"","No installed packages matched (%s,%s,%s)\n",n,v,a); return false; } /*****************************************************************************/ static int PatchMatch(char *n,char *v,char *a,struct Attributes attr,struct Promise *pp) { struct CfPackageManager *mp = NULL; struct CfPackageItem *pi; for (mp = INSTALLED_PACKAGE_LISTS; mp != NULL; mp = mp->next) { if (strcmp(mp->manager,attr.packages.package_list_command) == 0) { break; } } CfOut(cf_verbose,""," -> Looking for (%s,%s,%s)\n",n,v,a); for (pi = mp->patch_list; pi != NULL; pi=pi->next) { if (FullTextMatch(n,pi->name)) /* Check regexes */ { return true; } else if (ComparePackages(n,v,a,pi,attr.packages.package_select)) { return true; } } CfOut(cf_verbose,""," !! Unsatisfied constraints in promise (%s,%s,%s)\n",n,v,a); return false; } /*****************************************************************************/ static void SchedulePackageOp(char *name,char *version,char *arch,int installed,int matched,int no_version_specified,struct Attributes a,struct Promise *pp) { struct CfPackageManager *manager; char reference[CF_EXPANDSIZE],reference2[CF_EXPANDSIZE]; char refAnyVer[CF_EXPANDSIZE]; char refAnyVerEsc[CF_EXPANDSIZE]; char largestVerAvail[CF_MAXVARSIZE]; char largestPackAvail[CF_MAXVARSIZE]; char instVer[CF_MAXVARSIZE]; char instArch[CF_MAXVARSIZE]; char idBuf[CF_MAXVARSIZE]; char *id,*id_del; char *pathName = NULL; int package_select_in_range = false; enum package_actions policy; CfOut(cf_verbose, "", "Checking if package (%s,%s,%s) is at the desired state (installed=%d,matched=%d)", name, version, arch, installed, matched); /* Now we need to know the name-convention expected by the package manager */ if (a.packages.package_name_convention || a.packages.package_delete_convention) { SetNewScope("cf_pack_context"); NewScalar("cf_pack_context","name",name,cf_str); NewScalar("cf_pack_context","version",version,cf_str); NewScalar("cf_pack_context","arch",arch,cf_str); if(a.packages.package_delete_convention && (a.packages.package_policy == cfa_deletepack)) { ExpandScalar(a.packages.package_delete_convention,reference); id = reference; } else if(a.packages.package_name_convention) { ExpandScalar(a.packages.package_name_convention,reference); id = reference; } else { id = name; } DeleteScope("cf_pack_context"); } else { id = name; } CfOut(cf_verbose,""," -> Package promises to refer to itself as \"%s\" to the manager\n",id); if(strchr(id, '*')) { CfOut(cf_verbose,"","!! Package name contians '*' -- perhaps a missing attribute (name/version/arch) should be specified"); } if (a.packages.package_select == cfa_eq || a.packages.package_select == cfa_ge || a.packages.package_select == cfa_le || a.packages.package_select == cfa_cmp_none) { CfOut(cf_verbose,""," -> Package version seems to match criteria"); package_select_in_range = true; } policy = a.packages.package_policy; if(policy == cfa_addupdate) { if(!installed) { policy = cfa_addpack; } else { policy = cfa_update; } } switch(policy) { case cfa_addpack: if (installed == 0) { if((a.packages.package_file_repositories != NULL) && (a.packages.package_select == cfa_gt || a.packages.package_select == cfa_ge)) { SetNewScope("cf_pack_context_anyver"); NewScalar("cf_pack_context_anyver","name",name,cf_str); NewScalar("cf_pack_context_anyver","version","(.*)",cf_str); NewScalar("cf_pack_context_anyver","arch",arch,cf_str); ExpandScalar(a.packages.package_name_convention,refAnyVer); DeleteScope("cf_pack_context_anyver"); EscapeSpecialChars(refAnyVer, refAnyVerEsc, sizeof(refAnyVerEsc), "(.*)"); if(FindLargestVersionAvail(largestPackAvail, largestVerAvail, refAnyVerEsc, version, a.packages.package_select, a.packages.package_file_repositories)) { CfOut(cf_verbose, "", "Using latest version in file repositories; \"%s\"", largestPackAvail); id = largestPackAvail; } else { CfOut(cf_verbose, "", "No package in file repositories satisfy version constraint"); break; } } CfOut(cf_verbose,""," -> Schedule package for addition\n"); manager = NewPackageManager(&PACKAGE_SCHEDULE,a.packages.package_add_command,cfa_addpack,a.packages.package_changes); PrependPackageItem(&(manager->pack_list),id,"any","any",a,pp); } else { cfPS(cf_verbose,CF_NOP,"",pp,a," -> Package \"%s\" already installed, so we never add it again\n",pp->promiser); } break; case cfa_deletepack: if (matched && package_select_in_range || installed && no_version_specified) { CfOut(cf_verbose,""," -> Schedule package for deletion\n"); // expand local repository in the name convetion, if present if(a.packages.package_file_repositories) { // remove any "$(repo)" from the name convention string if (strncmp(id, "$(firstrepo)", 12) == 0) { snprintf(idBuf, sizeof(idBuf), "%s", id + 12); // and add the correct repo pathName = PrefixLocalRepository(a.packages.package_file_repositories, idBuf); if(pathName) { snprintf(id, CF_MAXVARSIZE, "%s", pathName); CfOut(cf_verbose, "", "Expanded the package repository to %s", id); } else { CfOut(cf_error, "", "!! Package \"%s\" can't be found in any of the listed repositories", idBuf); } } } manager = NewPackageManager(&PACKAGE_SCHEDULE,a.packages.package_delete_command,cfa_deletepack,a.packages.package_changes); PrependPackageItem(&(manager->pack_list),id,"any","any",a,pp); } else { cfPS(cf_verbose,CF_NOP,"",pp,a," -> Package deletion is as promised -- no match\n"); } break; case cfa_reinstall: if (a.packages.package_delete_command == NULL) { cfPS(cf_verbose,CF_FAIL,"",pp,a,"Package delete command undefined"); return; } if (a.packages.package_add_command == NULL) { cfPS(cf_verbose,CF_FAIL,"",pp,a,"Package add command undefined"); return; } if (!no_version_specified) { CfOut(cf_verbose,""," -> Schedule package for reinstallation\n"); if (matched && package_select_in_range || installed && no_version_specified) { manager = NewPackageManager(&PACKAGE_SCHEDULE,a.packages.package_delete_command,cfa_deletepack,a.packages.package_changes); PrependPackageItem(&(manager->pack_list),id,"any","any",a,pp); } manager = NewPackageManager(&PACKAGE_SCHEDULE,a.packages.package_add_command,cfa_addpack,a.packages.package_changes); PrependPackageItem(&(manager->pack_list),id,"any","any",a,pp); } else { cfPS(cf_error,CF_FAIL,"",pp,a,"!! Package reinstallation cannot be promised -- insufficient version info or no match\n"); } break; case cfa_update: *instVer = '\0'; *instArch = '\0'; if ((a.packages.package_file_repositories != NULL) && (a.packages.package_select == cfa_gt || a.packages.package_select == cfa_ge)) { SetNewScope("cf_pack_context_anyver"); NewScalar("cf_pack_context_anyver","name",name,cf_str); NewScalar("cf_pack_context_anyver","version","(.*)",cf_str); NewScalar("cf_pack_context_anyver","arch",arch,cf_str); ExpandScalar(a.packages.package_name_convention,refAnyVer); DeleteScope("cf_pack_context_anyver"); EscapeSpecialChars(refAnyVer, refAnyVerEsc, sizeof(refAnyVerEsc), "(.*)"); if (FindLargestVersionAvail(largestPackAvail, largestVerAvail, refAnyVerEsc, version, a.packages.package_select, a.packages.package_file_repositories)) { CfOut(cf_verbose, "", "Using latest version in file repositories; \"%s\"", largestPackAvail); id = largestPackAvail; } else { CfOut(cf_verbose, "", "No package in file repositories satisfy version constraint"); break; } } else { snprintf(largestVerAvail, sizeof(largestVerAvail), "%s", version); // user-supplied version } if (installed) { CfOut(cf_verbose, "", "Checking if latest available version is newer than installed..."); if (IsNewerThanInstalled(name, largestVerAvail, arch, instVer, instArch, a)) { CfOut(cf_verbose, "", "Installed package (%s,%s,%s) is older than latest available (%s,%s,%s) - updating", name, instVer, instArch, name, largestVerAvail, arch); } else { CfOut(cf_verbose, "", "Installed package is up to date, not updating"); break; } } if ((matched && package_select_in_range && !no_version_specified) || installed) { if (a.packages.package_update_command == NULL) { CfOut(cf_verbose,""," !! Package update command undefined - failing over to delete then add"); // we need to have the version of installed package if (a.packages.package_delete_convention) { if (*instVer == '\0') { instVer[0] = '*'; instVer[1] = '\0'; } if (*instArch == '\0') { instArch[0] = '*'; instArch[1] = '\0'; } SetNewScope("cf_pack_context"); NewScalar("cf_pack_context","name",name,cf_str); NewScalar("cf_pack_context","version",instVer,cf_str); NewScalar("cf_pack_context","arch",instArch,cf_str); ExpandScalar(a.packages.package_delete_convention,reference2); id_del = reference2; DeleteScope("cf_pack_context"); } else { id_del = id; // defaults to the package_name_convention } CfOut(cf_verbose, "", "Scheduling package with id \"%s\" for deletion", id_del); manager = NewPackageManager(&PACKAGE_SCHEDULE,a.packages.package_delete_command,cfa_deletepack,a.packages.package_changes); PrependPackageItem(&(manager->pack_list),id_del,"any","any",a,pp); manager = NewPackageManager(&PACKAGE_SCHEDULE,a.packages.package_add_command,cfa_addpack,a.packages.package_changes); PrependPackageItem(&(manager->pack_list),id,"any","any",a,pp); } else { CfOut(cf_verbose,""," -> Schedule package for update\n"); manager = NewPackageManager(&PACKAGE_SCHEDULE,a.packages.package_update_command,cfa_update,a.packages.package_changes); PrependPackageItem(&(manager->pack_list),id,"any","any",a,pp); } } else { cfPS(cf_error,CF_FAIL,"",pp,a,"!! Package \"%s\" cannot be updated -- no match or not installed",pp->promiser); } break; case cfa_patch: if (matched && !installed) { CfOut(cf_verbose,""," -> Schedule package for patching\n"); manager = NewPackageManager(&PACKAGE_SCHEDULE,a.packages.package_patch_command,cfa_patch,a.packages.package_changes); PrependPackageItem(&(manager->patch_list),id,"any","any",a,pp); } else { cfPS(cf_verbose,CF_NOP,"",pp,a," -> Package patch state of \"%s\" is as promised -- already installed\n",pp->promiser); } break; case cfa_verifypack: if (matched && package_select_in_range || installed && no_version_specified) { CfOut(cf_verbose,""," -> Schedule package for verification\n"); manager = NewPackageManager(&PACKAGE_SCHEDULE,a.packages.package_verify_command,cfa_verifypack,a.packages.package_changes); PrependPackageItem(&(manager->pack_list),id,"any","any",a,pp); } else { cfPS(cf_inform,CF_FAIL,"",pp,a,"!! Package \"%s\" cannot be verified -- no match\n",pp->promiser); } break; default: break; } } /*****************************************************************************/ char *PrefixLocalRepository(struct Rlist *repositories,char *package) { static char quotedPath[CF_MAXVARSIZE]; struct Rlist *rp; struct stat sb; char path[CF_BUFSIZE]; for (rp = repositories; rp != NULL; rp=rp->next) { strncpy(path,rp->item,CF_MAXVARSIZE); AddSlash(path); strcat(path,package); if (cfstat(path,&sb) != -1) { snprintf(quotedPath, sizeof(quotedPath), "\"%s\"", path); return quotedPath; } } return NULL; } /*****************************************************************************/ int FindLargestVersionAvail(char *matchName, char *matchVers, char *refAnyVer, char *ver, enum version_cmp package_select, struct Rlist *repositories) /* Returns true if a version gt/ge ver is found in local repos, false otherwise */ { struct Rlist *rp; const struct dirent *dirp; char largestVer[CF_MAXVARSIZE]; char largestVerName[CF_MAXVARSIZE]; char *matchVer; int match; CFDIR *dirh; Debug("FindLargestVersionAvail()\n"); match = false; // match any version if((strlen(ver) == 0) || (strcmp(ver, "*") == 0)) { memset(largestVer, 0, sizeof(largestVer)); } else { snprintf(largestVer, sizeof(largestVer), "%s", ver); if(package_select == cfa_gt) // either gt or ge { largestVer[strlen(largestVer) - 1]++; } } for (rp = repositories; rp != NULL; rp=rp->next) { if ((dirh = OpenDirLocal(rp->item)) == NULL) { CfOut(cf_error,"opendir","!! Can't open local directory \"%s\"\n", rp->item); continue; } for (dirp = ReadDir(dirh); dirp != NULL; dirp = ReadDir(dirh)) { #ifdef LINUX if(dirp->d_type != DT_REG && dirp->d_type != DT_LNK) { CfOut(cf_verbose, "", "Skipping \"%s\" (not a file)", dirp->d_name); continue; } #endif /* LINUX */ if (FullTextMatch(refAnyVer, dirp->d_name)) { matchVer = ExtractFirstReference(refAnyVer, dirp->d_name); // check if match is largest so far if(VersionCmp(largestVer, matchVer)) { snprintf(largestVer, sizeof(largestVer), "%s", matchVer); snprintf(largestVerName, sizeof(largestVerName), "%s", dirp->d_name); match = true; } } } CloseDir(dirh); } Debug("largest ver is \"%s\", name is \"%s\"\n", largestVer, largestVerName); Debug("match=%d\n", match); if(match) { snprintf(matchName, CF_MAXVARSIZE, "%s", largestVerName); snprintf(matchVers, CF_MAXVARSIZE, "%s", largestVer); } return match; } /*****************************************************************************/ int VersionCmp(char *vs1,char *vs2) /* Returns true if vs2 is a larger or equal version than vs1, false otherwise */ { int i; char ch1,ch2; if (strlen(vs1) > strlen(vs2)) { return false; } if (strlen(vs1) < strlen(vs2)) { return true; } for (i = 0; i < strlen(vs1); i++) { ch1 = (vs1[i] == ',') ? '_' : vs1[i]; // CSV protection. Names will be canonified of commas ch2 = (vs2[i] == ',') ? '_' : vs2[i]; // CSV protection. Names will be canonified of commas if (ch1 < ch2) { return true; } else if (ch1 > ch2) { return false; } } return true; } /*****************************************************************************/ static int IsNewerThanInstalled(char *n,char *v,char *a, char *instV, char *instA, struct Attributes attr) /* Returns true if a package (n, a) is installed and v is larger than * the installed version. instV and instA are the version and arch installed. */ { struct CfPackageManager *mp = NULL; struct CfPackageItem *pi; for (mp = INSTALLED_PACKAGE_LISTS; mp != NULL; mp = mp->next) { if (strcmp(mp->manager,attr.packages.package_list_command) == 0) { break; } } CfOut(cf_verbose,"","Looking for an installed package older than (%s,%s,%s)",n,v,a); for (pi = mp->pack_list; pi != NULL; pi=pi->next) { if ((strcmp(n, pi->name) == 0) && ((strcmp(a, pi->arch) == 0) || (strcmp("default", pi->arch) == 0))) { CfOut(cf_verbose, "", "Found installed package (%s,%s,%s)", pi->name, pi->version, pi->arch); snprintf(instV, CF_MAXVARSIZE, "%s", pi->version); snprintf(instA, CF_MAXVARSIZE, "%s", pi->arch); if (!VersionCmp(v,pi->version)) { return true; } else { return false; } } } CfOut(cf_verbose,""," !! Package (%s,%s) is not installed\n",n,a); return false; } /*****************************************************************************/ static int ExecPackageCommand(char *command,int verify,int setCmdClasses,struct Attributes a,struct Promise *pp) { if(strncmp(command,"/cf_internal_rpath",sizeof("/cf_internal_rpath") - 1) == 0) { return ExecPackageCommandRpath(command,verify,setCmdClasses,a,pp); } else { return ExecPackageCommandGeneric(command,verify,setCmdClasses,a,pp); } } /*****************************************************************************/ int ExecPackageCommandGeneric(char *command,int verify,int setCmdClasses,struct Attributes a,struct Promise *pp) { int retval = true; char line[CF_BUFSIZE], lineSafe[CF_BUFSIZE], *cmd; FILE *pfp; int packmanRetval = 0; if (!IsExecutable(GetArg0(command))) { cfPS(cf_error,CF_FAIL,"",pp,a,"The proposed package schedule command \"%s\" was not executable",command); return false; } if (DONTDO) { CfOut(cf_error,""," -> Need to execute %-.39s...\n",command); return true; } /* Use this form to avoid limited, intermediate argument processing - long lines */ if ((pfp = cf_popen_sh(command,"r")) == NULL) { cfPS(cf_error,CF_FAIL,"cf_popen",pp,a,"Couldn't start command %20s...\n",command); return false; } CfOut(cf_verbose,"","Executing %-.60s...\n",command); /* Look for short command summary */ for (cmd = command; *cmd != '\0' && *cmd != ' '; cmd++) { } while (*(cmd-1) != FILE_SEPARATOR && cmd >= command) { cmd--; } while (!feof(pfp)) { if (ferror(pfp)) /* abortable */ { fflush(pfp); cfPS(cf_error,CF_INTERPT,"read",pp,a,"Couldn't start command %20s...\n",command); break; } line[0] = '\0'; CfReadLine(line,CF_BUFSIZE-1,pfp); ReplaceStr(line,lineSafe,sizeof(lineSafe),"%","%%"); CfOut(cf_inform,"","Q:%20.20s ...:%s",cmd,lineSafe); if (verify && line[0] != '\0') { if (a.packages.package_noverify_regex) { if(FullTextMatch(a.packages.package_noverify_regex,line)) { cfPS(cf_inform,CF_FAIL,"",pp,a,"Package verification error in %-.40s ... :%s",cmd,lineSafe); retval = false; } } } } packmanRetval = cf_pclose(pfp); if(verify && a.packages.package_noverify_returncode != CF_NOINT) { if(a.packages.package_noverify_returncode == packmanRetval) { cfPS(cf_inform,CF_FAIL,"",pp,a,"!! Package verification error (returned %d)",packmanRetval); retval = false; } else { cfPS(cf_inform,CF_NOP,"",pp,a,"-> Package verification succeeded (returned %d)",packmanRetval); } } else if(verify && a.packages.package_noverify_regex) { if(retval) // set status if we succeeded above { cfPS(cf_inform,CF_NOP,"",pp,a,"-> Package verification succeeded (no match with package_noverify_regex)"); } } else if(setCmdClasses) // generic return code check { retval = VerifyCommandRetcode(packmanRetval,true,a,pp); } return retval; } /*****************************************************************************/ /* Level */ /*****************************************************************************/ static int ComparePackages(char *n,char *v,char *a,struct CfPackageItem *pi,enum version_cmp cmp) { struct Rlist *numbers_pr = NULL,*separators_pr = NULL; struct Rlist *numbers_in = NULL,*separators_in = NULL; struct Rlist *rp_pr,*rp_in; int result = true; int version_matched = false; int version_equal = false; int cmp_result; int break_loop = false; Debug("Compare (%s,%s,%s) and (%s,%s,%s)\n",n,v,a,pi->name,pi->version,pi->arch); if (CompareCSVName(n,pi->name) != 0) { return false; } CfOut(cf_verbose,""," -> Matched name %s\n",n); if (strcmp(a,"*") != 0) { if (strcmp(a,pi->arch) != 0) { return false; } CfOut(cf_verbose,""," -> Matched arch %s\n",a); } if (strcmp(v,"*") == 0) { CfOut(cf_verbose,""," -> Matched version *\n"); return true; } ParsePackageVersion(CanonifyChar(v,','),&numbers_pr,&separators_pr); ParsePackageVersion(CanonifyChar(pi->version,','),&numbers_in,&separators_in); /* If the format of the version string doesn't match, we're already doomed */ CfOut(cf_verbose,""," -> Check for compatible versioning model in (%s,%s)\n",v,pi->version); for (rp_pr = separators_pr,rp_in = separators_in; rp_pr != NULL && rp_in != NULL; rp_pr= rp_pr->next,rp_in=rp_in->next) { if (strcmp(rp_pr->item,rp_in->item) != 0) { result = false; break; } if (rp_pr->next == NULL && rp_in->next == NULL) { result = true; break; } if ((rp_pr->next != NULL && rp_in->next == NULL) || (rp_pr->next == NULL && rp_in->next != NULL)) { result = false; break; } } if (result) { CfOut(cf_verbose,""," -> Verified that versioning models are compatible\n"); } else { CfOut(cf_verbose,""," !! Versioning models for (%s,%s) were incompatible\n",v,pi->version); } version_equal = (strcmp(pi->version,v) == 0); if (result) { for (rp_pr = numbers_pr,rp_in = numbers_in; rp_pr != NULL && rp_in != NULL; rp_pr= rp_pr->next,rp_in=rp_in->next) { cmp_result = strcmp(rp_pr->item,rp_in->item); switch (cmp) { case cfa_eq: case cfa_cmp_none: if (version_equal) { version_matched = true; } break; case cfa_neq: if (!version_equal) { version_matched = true; } break; case cfa_gt: if (cmp_result < 0) { version_matched = true; } else if (cmp_result > 0) { break_loop = true; } break; case cfa_lt: if (cmp_result > 0) { version_matched = true; } else if (cmp_result < 0) { break_loop = true; } break; case cfa_ge: if ((cmp_result < 0) || version_equal) { version_matched = true; } else if (cmp_result > 0) { break_loop = true; } break; case cfa_le: if ((cmp_result > 0) || version_equal) { version_matched = true; } else if (cmp_result < 0) { break_loop = true; } break; default: break; } if ((version_matched == true) || break_loop) { break; } } } result = version_matched; if (result) { CfOut(cf_verbose,""," -> Verified version constraint promise kept\n"); } else { CfOut(cf_verbose,""," -> Versions did not match\n"); } DeleteRlist(numbers_pr); DeleteRlist(numbers_in); DeleteRlist(separators_pr); DeleteRlist(separators_in); return result; } /*****************************************************************************/ static int PackageInItemList(struct CfPackageItem *list,char *name,char *version,char *arch) { struct CfPackageItem *pi; if (strlen(name) == 0 || strlen(version) == 0 || strlen(arch) == 0) { return false; } for (pi = list; pi != NULL; pi = pi->next) { if (strcmp(pi->name,name) == 0 && strcmp(pi->version,version) == 0 && strcmp(pi->arch,arch) == 0) { return true; } } return false; } /*****************************************************************************/ /* Level */ /*****************************************************************************/ static void ParsePackageVersion(char *version,struct Rlist **num,struct Rlist **sep) { char *sp,numeral[30],separator[2]; if (version == NULL) { return; } for (sp = version; *sp != '\0'; sp++) { memset(numeral,0,30); memset(separator,0,2); /* Split in 2's complement */ sscanf(sp,"%29[0-9a-zA-Z]",numeral); sp += strlen(numeral); /* Append to end up with left->right (major->minor) comparison */ AppendRScalar(num,numeral,CF_SCALAR); if (*sp == '\0') { return; } sscanf(sp,"%1[^0-9a-zA-Z]",separator); PrependRScalar(sep,separator,CF_SCALAR); } } /*****************************************************************************/ static void InvalidateSoftwareCache(void) { char name[CF_BUFSIZE]; GetSoftwareCacheFilename(name); struct utimbuf epoch = { 0, 0 }; if (utime(name, &epoch) != 0) { if (errno != ENOENT) { CfOut(cf_error, "utimes", "Cannot mark software cache as invalid"); } } } /*****************************************************************************/ static void ReportSoftware(struct CfPackageManager *list) { FILE *fout; struct CfPackageManager *mp = NULL; struct CfPackageItem *pi; char name[CF_BUFSIZE]; GetSoftwareCacheFilename(name); if ((fout = fopen(name,"w")) == NULL) { CfOut(cf_error,"fopen","Cannot open the destination file %s",name); return; } for (mp = list; mp != NULL; mp = mp->next) { for (pi = mp->pack_list; pi != NULL; pi=pi->next) { fprintf(fout,"%s,",CanonifyChar(pi->name,',')); fprintf(fout,"%s,",CanonifyChar(pi->version,',')); fprintf(fout,"%s,%s\n",pi->arch,ReadLastNode(GetArg0(mp->manager))); } } fclose(fout); } /*****************************************************************************/ /* Buffer should be at least CF_BUFSIZE large */ static const char *GetSoftwareCacheFilename(char *buffer) { snprintf(buffer,CF_BUFSIZE,"%s/state/%s",CFWORKDIR,SOFTWARE_PACKAGES_CACHE); MapName(buffer); return buffer; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/manual.c�������������������������������������������������������������������������0000644�0001750�0001750�00000054316�11715232734�012445� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: manual.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" extern char BUILD_DIR[CF_BUFSIZE]; extern char MANDIR[CF_BUFSIZE]; static void TexinfoHeader(FILE *fout); static void TexinfoFooter(FILE *fout); static void TexinfoBodyParts(FILE *fout,struct BodySyntax *bs,char *context); static void TexinfoSubBodyParts(FILE *fout,struct BodySyntax *bs); static void TexinfoShowRange(FILE *fout,char *s,enum cfdatatype type); static void IncludeManualFile(FILE *fout,char *filename); static void TexinfoPromiseTypesFor(FILE *fout,struct SubTypeSyntax *st); static void TexinfoSpecialFunction(FILE *fout,struct FnCallType fn); static void TexinfoVariables(FILE *fout,char *scope); static char *TexInfoEscape(char *s); static void PrintPattern(FILE *fout,char *pattern); /*****************************************************************************/ void TexinfoManual(char *mandir) { char filename[CF_BUFSIZE]; struct SubTypeSyntax *st; struct Item *done = NULL; FILE *fout; int i; snprintf(filename,CF_BUFSIZE-1,"%scf3-Reference.texinfo",BUILD_DIR); if ((fout = fopen(filename,"w")) == NULL) { CfOut(cf_error,"fopen","Unable to open %s for writing\n",filename); return; } TexinfoHeader(fout); /* General background */ fprintf(fout,"@c *****************************************************\n"); fprintf(fout,"@c * CHAPTER \n"); fprintf(fout,"@c *****************************************************\n"); fprintf(fout,"@node Getting started\n@chapter CFEngine %s -- Getting started\n\n",Version()); IncludeManualFile(fout,"reference_basics.texinfo"); /* Control promises */ fprintf(fout,"@c *****************************************************\n"); fprintf(fout,"@c * CHAPTER \n"); fprintf(fout,"@c *****************************************************\n"); fprintf(fout,"@node Control Promises\n@chapter Control promises\n\n"); IncludeManualFile(fout,"reference_control_intro.texinfo"); for (i = 0; CF_ALL_BODIES[i].btype != NULL; i++) { fprintf(fout,"@node control %s\n@section @code{%s} control promises\n\n",CF_ALL_BODIES[i].btype,CF_ALL_BODIES[i].btype); snprintf(filename,CF_BUFSIZE-1,"control_%s_example.texinfo",CF_ALL_BODIES[i].btype); IncludeManualFile(fout,filename); snprintf(filename,CF_BUFSIZE-1,"control_%s_notes.texinfo",CF_ALL_BODIES[i].btype); IncludeManualFile(fout,filename); TexinfoBodyParts(fout,CF_ALL_BODIES[i].bs,CF_ALL_BODIES[i].btype); } /* Components */ for (i = 0; i < CF3_MODULES; i++) { st = (CF_ALL_SUBTYPES[i]); if (st == CF_COMMON_SUBTYPES || st == CF_EXEC_SUBTYPES || st == CF_REMACCESS_SUBTYPES || st == CF_KNOWLEDGE_SUBTYPES || st == CF_MEASUREMENT_SUBTYPES) { CfOut(cf_verbose,"","Dealing with chapter / bundle type %s\n",st->btype); fprintf(fout,"@c *****************************************************\n"); fprintf(fout,"@c * CHAPTER \n"); fprintf(fout,"@c *****************************************************\n"); if (strcmp(st->btype,"*") == 0) { fprintf(fout,"@node Bundles for common\n@chapter Bundles of @code{common}\n\n"); } else { fprintf(fout,"@node Bundles for %s\n@chapter Bundles of @code{%s}\n\n",st->btype,st->btype); } } if (!IsItemIn(done,st->btype)) /* Avoid multiple reading if several modules */ { PrependItem(&done,st->btype,NULL); snprintf(filename,CF_BUFSIZE-1,"bundletype_%s_example.texinfo",st->btype); IncludeManualFile(fout,filename); snprintf(filename,CF_BUFSIZE-1,"bundletype_%s_notes.texinfo",st->btype); IncludeManualFile(fout,filename); } TexinfoPromiseTypesFor(fout,st); } /* Special functions */ CfOut(cf_verbose,"","Dealing with chapter / bundle type - special functions\n"); fprintf(fout,"@c *****************************************************\n"); fprintf(fout,"@c * CHAPTER \n"); fprintf(fout,"@c *****************************************************\n"); fprintf(fout,"@node Special functions\n@chapter Special functions\n\n"); fprintf(fout,"@node Introduction to functions\n@section Introduction to functions\n\n"); IncludeManualFile(fout,"functions_intro.texinfo"); for (i = 0; CF_FNCALL_TYPES[i].name != NULL; i++) { fprintf(fout,"@node Function %s\n@section Function %s \n\n",CF_FNCALL_TYPES[i].name,CF_FNCALL_TYPES[i].name); TexinfoSpecialFunction(fout,CF_FNCALL_TYPES[i]); } /* Special variables */ CfOut(cf_verbose,"","Dealing with chapter / bundle type - special variables\n"); fprintf(fout,"@c *****************************************************\n"); fprintf(fout,"@c * CHAPTER \n"); fprintf(fout,"@c *****************************************************\n"); fprintf(fout,"@node Special Variables\n@chapter Special Variables\n\n"); // scopes const and sys NewScope("edit"); NewScalar("edit","filename","x",cf_str); TexinfoVariables(fout,"const"); TexinfoVariables(fout,"edit"); TexinfoVariables(fout,"match"); TexinfoVariables(fout,"mon"); TexinfoVariables(fout,"sys"); TexinfoVariables(fout,"this"); // Log files CfOut(cf_verbose,"","Dealing with chapter / bundle type - Logs and records\n"); fprintf(fout,"@c *****************************************************\n"); fprintf(fout,"@c * CHAPTER \n"); fprintf(fout,"@c *****************************************************\n"); fprintf(fout,"@node Logs and records\n@chapter Logs and records\n\n"); IncludeManualFile(fout,"reference_logs.texinfo"); TexinfoFooter(fout); fclose(fout); } /*****************************************************************************/ /* Level */ /*****************************************************************************/ static void TexinfoHeader(FILE *fout) { fprintf(fout, "\\input texinfo-altfont\n" "\\input texinfo-logo\n" "\\input texinfo\n" "@selectaltfont{cmbright}\n" "@setlogo{CFEngineFrontPage}\n" "@c *********************************************************************\n" "@c\n" "@c This is an AUTO_GENERATED TEXINFO file. Do not submit patches against it.\n" "@c Refer to the the component .texinfo files instead when patching docs.\n" "@c\n" "@c ***********************************************************************\n" "@c %%** start of header\n" "@setfilename cf3-reference.info\n" "@settitle CFEngine reference manual\n" "@setchapternewpage odd\n" "@c %%** end of header\n" "@titlepage\n" "@title CFEngine Reference Manual\n" "@subtitle Auto generated, self-healing knowledge\n" "@subtitle %s\n" #ifdef HAVE_NOVA "@subtitle %s\n" #endif #ifdef HAVE_CONSTELLATION "@subtitle %s\n" #endif "@author cfengine.com\n" "@c @smallbook\n" "@fonttextsize 10\n" "@page\n" "@vskip 0pt plus 1filll\n" "@cartouche\n" "Under no circumstances shall CFEngine AS be liable for errors or omissions\n" "in this document. All efforts have been made to ensure the correctness of\n" "the information contained herein.\n" "@end cartouche\n" "Copyright @copyright{} 2008,2010 to the year of issue CFEngine AS\n" "@end titlepage\n" "@c *************************** File begins here ************************\n" "@ifinfo\n" "@dircategory CFEngine Training\n" "@direntry\n" "* cfengine Reference:\n" " CFEngine is a language based framework\n" " designed for configuring and maintaining\n" " Unix-like operating systems attached\n" " to a TCP/IP network.\n" "@end direntry\n" "@end ifinfo\n" "@ifnottex\n" "@node Top, Modularization, (dir), (dir)\n" "@top CFEngine-AutoReference\n" "@end ifnottex\n" "@ifhtml\n" "@html\n" "<a href=\"#Contents\"><h1>COMPLETE TABLE OF CONTENTS</h1></a>\n" "<h2>Summary of contents</h2>\n" "@end html\n" "@end ifhtml\n" "@iftex\n" "@contents\n" "@end iftex\n", NameVersion() #ifdef HAVE_NOVA , Nova_NameVersion() #endif #ifdef HAVE_CONSTELLATION , Constellation_NameVersion() #endif ); } /*****************************************************************************/ static void TexinfoFooter(FILE *fout) { fprintf(fout, "@c =========================================================================\n" "@c @node Index, , CFEngine Methods, Top\n" "@c @unnumbered Concept Index\n" "@c @printindex cp\n" "@c =========================================================================\n" "@ifhtml\n" "@html\n" "<a name=\"Contents\">\n" "@contents\n" "@end html\n" "@end ifhtml\n" "@c The file is structured like a programming language. Each chapter\n" "@c starts with a chapter comment.\n" "@c\n" "@c Menus list the subsections so that an online info-reader can parse\n" "@c the file hierarchically.\n" "@ifhtml\n" "@html\n" "<script type=\"text/javascript\">\n" "var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");\n" "document.write(unescape(\"%%3Cscript src='\" + gaJsHost + \"google-analytics.com/ga.js' type='text/javascript'%%3E%%3C/script%%3E\"));\n" "</script>\n" "<script type=\"text/javascript\">\n" "var pageTracker = _gat._getTracker(\"UA-2576171-2\");\n" "pageTracker._initData();\n" "pageTracker._trackPageview();\n" "</script>\n" "@end html\n" "@end ifhtml\n" "@bye\n" ); } /*****************************************************************************/ static void TexinfoPromiseTypesFor(FILE *fout,struct SubTypeSyntax *st) { int j; char filename[CF_BUFSIZE]; /* Each array element is SubtypeSyntax representing an agent-promise assoc */ for (j = 0; st[j].btype != NULL; j++) { CfOut(cf_verbose,""," - Dealing with promise type %s\n",st[j].subtype); if (strcmp("*",st[j].btype) == 0) { fprintf(fout,"\n\n@node %s in common promises\n@section @code{%s} promises\n\n",st[j].subtype,st[j].subtype); snprintf(filename,CF_BUFSIZE-1,"promise_common_intro.texinfo"); IncludeManualFile(fout,filename); TexinfoBodyParts(fout,st[j].bs,st[j].subtype); } else { fprintf(fout,"\n\n@node %s in %s promises\n@section @code{%s} promises in @samp{%s}\n\n",st[j].subtype,st[j].btype,st[j].subtype,st[j].btype); snprintf(filename,CF_BUFSIZE-1,"promise_%s_intro.texinfo",st[j].subtype); IncludeManualFile(fout,filename); snprintf(filename,CF_BUFSIZE-1,"promise_%s_example.texinfo",st[j].subtype); IncludeManualFile(fout,filename); snprintf(filename,CF_BUFSIZE-1,"promise_%s_notes.texinfo",st[j].subtype); IncludeManualFile(fout,filename); TexinfoBodyParts(fout,st[j].bs,st[j].subtype); } } } /*****************************************************************************/ /* Level */ /*****************************************************************************/ static void TexinfoBodyParts(FILE *fout,struct BodySyntax *bs,char *context) { int i; char filename[CF_BUFSIZE],*res; if (bs == NULL) { return; } for (i = 0; bs[i].lval != NULL; i++) { CfOut(cf_verbose,""," - - Dealing with body type %s\n",bs[i].lval); if (bs[i].range == (void *)CF_BUNDLE) { fprintf(fout,"\n\n@node %s in %s\n@subsection @code{%s}\n\n@b{Type}: %s (Separate Bundle) \n",bs[i].lval,context,bs[i].lval,CF_DATATYPES[bs[i].dtype]); } else if (bs[i].dtype == cf_body) { fprintf(fout,"\n\n@node %s in %s\n@subsection @code{%s} (body template)\n@noindent @b{Type}: %s\n\n",bs[i].lval,context,bs[i].lval,CF_DATATYPES[bs[i].dtype]); TexinfoSubBodyParts(fout,(struct BodySyntax *)bs[i].range); } else { fprintf(fout,"\n\n@node %s in %s\n@subsection @code{%s}\n@noindent @b{Type}: %s\n\n",bs[i].lval,context,bs[i].lval,CF_DATATYPES[bs[i].dtype]); TexinfoShowRange(fout,(char *)bs[i].range,bs[i].dtype); if ((res = GetControlDefault(bs[i].lval))) { fprintf(fout,"@noindent @b{Default value:} %s\n",res); } else if ((res = GetBodyDefault(bs[i].lval))) { fprintf(fout,"@noindent @b{Default value:} %s\n",res); } fprintf(fout,"\n@noindent @b{Synopsis}: %s\n\n",bs[i].description); fprintf(fout,"\n@noindent @b{Example}:@*\n"); snprintf(filename,CF_BUFSIZE-1,"bodypart_%s_example.texinfo",bs[i].lval); IncludeManualFile(fout,filename); fprintf(fout,"\n@noindent @b{Notes}:@*\n"); snprintf(filename,CF_BUFSIZE-1,"bodypart_%s_notes.texinfo",bs[i].lval); IncludeManualFile(fout,filename); } } } /*******************************************************************/ static void AppendVariables(struct Scope *sp, struct Rlist **list) { HashIterator i = HashIteratorInit(sp->hashtable); CfAssoc *assoc; while ((assoc = HashIteratorNext(&i))) { CfOut(cf_verbose,"","Appending variable documentation for %s (%c)\n",assoc->lval,assoc->rtype); PrependRScalar(list,assoc->lval,CF_SCALAR); } } /*******************************************************************/ static void TexinfoVariables(FILE *fout,char *scope) { char filename[CF_BUFSIZE],varname[CF_BUFSIZE]; struct Rlist *rp,*list = NULL; int i; fprintf(fout,"\n\n@node Variable context %s\n@section Variable context @code{%s}\n\n",scope,scope); snprintf(filename,CF_BUFSIZE-1,"varcontext_%s_intro.texinfo",scope); IncludeManualFile(fout,filename); AppendVariables(GetScope(scope), &list); for (rp = AlphaSortRListNames(list); rp != NULL; rp = rp->next) { fprintf(fout,"@node Variable %s.%s\n@subsection Variable %s.%s \n\n",scope,rp->item,scope,rp->item); snprintf(filename,CF_BUFSIZE-1,"var_%s_%s.texinfo",scope,rp->item); IncludeManualFile(fout,filename); } DeleteRlist(list); if (strcmp(scope,"mon") == 0) { for (i = 0; i < CF_OBSERVABLES; i++) { if (strcmp(OBS[i][0],"spare") == 0) { break; } snprintf(varname,CF_MAXVARSIZE,"value_%s",OBS[i][0]); fprintf(fout,"\n@node Variable %s.%s\n@subsection Variable %s.%s \n\n",scope,varname,scope,varname); fprintf(fout,"Observational measure collected every 2.5 minutes from cf-monitord, description: @var{%s}.",OBS[i][1]); snprintf(varname,CF_MAXVARSIZE,"av_%s",OBS[i][0]); fprintf(fout,"\n@node Variable %s.%s\n@subsection Variable %s.%s \n\n",scope,varname,scope,varname); fprintf(fout,"Observational measure collected every 2.5 minutes from cf-monitord, description: @var{%s}.",OBS[i][1]); snprintf(varname,CF_MAXVARSIZE,"dev_%s",OBS[i][0]); fprintf(fout,"\n@node Variable %s.%s\n@subsection Variable %s.%s \n\n",scope,varname,scope,varname); fprintf(fout,"Observational measure collected every 2.5 minutes from cf-monitord, description: @var{%s}.",OBS[i][1]); } } } /*******************************************************************/ /* Level */ /*******************************************************************/ static void TexinfoShowRange(FILE *fout,char *s,enum cfdatatype type) { struct Rlist *list = NULL,*rp; if (strlen(s) == 0) { fprintf(fout,"@noindent @b{Allowed input range}: (arbitrary string)\n\n"); return; } if (type == cf_opts || type == cf_olist) { list = SplitStringAsRList(s,','); fprintf(fout,"@noindent @b{Allowed input range}: @*\n@example",TexInfoEscape(s)); for (rp = list; rp != NULL; rp=rp->next) { fprintf(fout,"\n @code{%s}",rp->item); } fprintf(fout,"\n@end example\n"); DeleteRlist(list); } else { fprintf(fout,"@noindent @b{Allowed input range}: @code{%s}\n\n",TexInfoEscape(s)); } } /*****************************************************************************/ static void TexinfoSubBodyParts(FILE *fout,struct BodySyntax *bs) { int i; char filename[CF_BUFSIZE],*res; if (bs == NULL) { return; } fprintf(fout,"@table @samp\n"); for (i = 0; bs[i].lval != NULL; i++) { if (bs[i].range == (void *)CF_BUNDLE) { fprintf(fout,"@item @code{%s}\n@b{Type}: %s\n (Separate Bundle) \n\n",bs[i].lval,CF_DATATYPES[bs[i].dtype]); } else if (bs[i].dtype == cf_body) { fprintf(fout,"@item @code{%s}\n@b{Type}: %s\n\n",bs[i].lval,CF_DATATYPES[bs[i].dtype]); TexinfoSubBodyParts(fout,(struct BodySyntax *)bs[i].range); } else { fprintf(fout,"@item @code{%s}\n@b{Type}: %s\n\n",bs[i].lval,CF_DATATYPES[bs[i].dtype]); TexinfoShowRange(fout,(char *)bs[i].range,bs[i].dtype); fprintf(fout,"\n@noindent @b{Synopsis}: %s\n\n",bs[i].description); if ((res = GetControlDefault(bs[i].lval))) { fprintf(fout,"\n@noindent @b{Default value:} %s\n",res); } else if ((res = GetBodyDefault(bs[i].lval))) { fprintf(fout,"\n@noindent @b{Default value:} %s\n",res); } fprintf(fout,"\n@b{Example}:@*\n"); snprintf(filename,CF_BUFSIZE-1,"bodypart_%s_example.texinfo",bs[i].lval); IncludeManualFile(fout,filename); fprintf(fout,"\n@b{Notes}:@*\n"); snprintf(filename,CF_BUFSIZE-1,"bodypart_%s_notes.texinfo",bs[i].lval); IncludeManualFile(fout,filename); } } fprintf(fout,"@end table\n"); } /*****************************************************************************/ static void IncludeManualFile(FILE *fout,char *file) { struct stat sb; char buffer[CF_BUFSIZE],filename[CF_BUFSIZE]; FILE *fp; AddSlash(MANDIR); snprintf(filename,CF_BUFSIZE-1,"%s%s",MANDIR,file); fprintf(fout,"@*\n"); if (cfstat(filename,&sb) == -1) { if ((fp = fopen(filename,"w")) == NULL) { CfOut(cf_inform,"fopen","Could not write to manual source %s",filename); return; } #ifdef HAVE_CONSTELLATION fprintf(fp,"\n@i{History}: Was introduced in %s, Nova %s, Constellation %s (%d)\n\n",Version(),Nova_Version(),Constellation_Version(), BUILD_YEAR); #elif HAVE_NOVA fprintf(fp,"\n@i{History}: Was introduced in %s, Nova %s (%d)\n\n",Version(),Nova_Version(), BUILD_YEAR); #else fprintf(fp,"\n@i{History}: Was introduced in %s (%d)\n\n", Version(), BUILD_YEAR); #endif fprintf(fp,"\n@verbatim\n\nFill me in (%s)\n\"\"\n@end verbatim\n",filename); fclose(fp); CfOut(cf_verbose,"","Created %s template\n",filename); } if ((fp = fopen(filename,"r")) == NULL) { CfOut(cf_inform,"fopen","Could not read manual source %s\n",filename); fclose(fp); return; } while(!feof(fp)) { buffer[0] = '\0'; fgets(buffer,CF_BUFSIZE,fp); fprintf(fout,"%s",buffer); } fclose(fp); fprintf(fout,"\n"); } /*****************************************************************************/ static void TexinfoSpecialFunction(FILE *fout,struct FnCallType fn) { char filename[CF_BUFSIZE]; struct FnCallArg *args = fn.args; int i; fprintf(fout,"\n@noindent @b{Synopsis}: %s(",fn.name); for (i = 0; args[i].pattern != NULL; i++) { fprintf(fout,"arg%d",i); if (args[i+1].pattern != NULL) { fprintf(fout,","); } } if (fn.numargs == CF_VARARGS) { if (i != 0) { fprintf(fout,","); } fprintf(fout, "..."); } fprintf(fout,") returns type @b{%s}\n\n@*\n",CF_DATATYPES[fn.dtype]); for (i = 0; args[i].pattern != NULL; i++) { fprintf(fout,"@noindent @code{ } @i{arg%d} : %s, @i{in the range} ",i,args[i].description); PrintPattern(fout,args[i].pattern); fprintf(fout,"\n@*\n"); } fprintf(fout,"\n@noindent %s\n\n",fn.description); fprintf(fout,"\n@noindent @b{Example}:@*\n"); snprintf(filename,CF_BUFSIZE-1,"function_%s_example.texinfo",fn.name); IncludeManualFile(fout,filename); fprintf(fout,"\n@noindent @b{Notes}:@*\n"); snprintf(filename,CF_BUFSIZE-1,"function_%s_notes.texinfo",fn.name); IncludeManualFile(fout,filename); } /*****************************************************************************/ static void PrintPattern(FILE *fout,char *pattern) { char *sp; for (sp = pattern; *sp != '\0'; sp++) { switch (*sp) { case '@': case '{': case '}': fputc((int)'@',fout); default: fputc((int)*sp,fout); } } } /*****************************************************************************/ char *TexInfoEscape(char *s) { char *spf,*spt; static char buffer[CF_BUFSIZE]; memset(buffer,0,CF_BUFSIZE); for (spf = s,spt = buffer; *spf != '\0'; spf++) { switch (*spf) { case '{': case '}': case '@': *spt++ = '@'; break; } *spt++ = *spf; } return buffer; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/dbm_api.c������������������������������������������������������������������������0000644�0001750�0001750�00000023240�11715232734�012553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: dbm_api.c */ /* */ /* NOTE: The functions supplied here are *NOT* neccessarily thread safe. */ /* This means that threaded calls to OpenDB()/CloseDB() should be */ /* wrapped by ThreadLock() and ThreadUnlock(). */ /* */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #if defined(SQLITE3) #include "dbm_sqlite3.h" #endif static int DoOpenDB(char *filename, CF_DB **dbp); static int DoCloseDB(CF_DB *dbp); static int SaveDBHandle(CF_DB *dbp); static int RemoveDBHandle(CF_DB *dbp); static int GetDBHandle(CF_DB **dbp); CF_DB *OPENDB[MAX_OPENDB] = {0}; int OpenDB(char *filename, CF_DB **dbp) { int res; Debug("OpenDB(%s)\n", filename); res = DoOpenDB(filename, dbp); // record open DBs if successful if(res) { if(!SaveDBHandle(*dbp)) { FatalError("OpenDB: Could not save DB handle"); } } return res; } /*****************************************************************************/ static int DoOpenDB(char *filename, CF_DB **dbp) { #ifdef TCDB return TCDB_OpenDB(filename, dbp); #elif defined QDB return QDB_OpenDB(filename, dbp); #elif defined SQLITE3 return SQLite3_OpenDB(filename, dbp); #else return BDB_OpenDB(filename, dbp); #endif } /*****************************************************************************/ int CloseDB(CF_DB *dbp) { int res; res = DoCloseDB(dbp); if (!res) { CfOut(cf_error, "", "CloseDB: Could not close DB handle."); CfOut(cf_error, "", "CloseDB: Trying to remove handle from open pool anyway."); } if (!RemoveDBHandle(dbp)) { CfOut(cf_error, "", "CloseDB: Could not find DB handle in open pool."); } return res; } /*****************************************************************************/ static int DoCloseDB(CF_DB *dbp) { #ifdef TCDB return TCDB_CloseDB(dbp); #elif defined QDB return QDB_CloseDB(dbp); #elif defined SQLITE3 return SQLite3_CloseDB(dbp); #else return BDB_CloseDB(dbp); #endif } /*****************************************************************************/ int ValueSizeDB(CF_DB *dbp, char *key) /* Returns size of value corresponding to key, or -1 on not found or error */ { #ifdef TCDB return TCDB_ValueSizeDB(dbp, key); #elif defined QDB return QDB_ValueSizeDB(dbp, key); #elif defined SQLITE3 return SQLite3_ValueSizeDB(dbp, key); #else return BDB_ValueSizeDB(dbp, key); #endif } /*****************************************************************************/ int ReadComplexKeyDB(CF_DB *dbp, char *key, int keySz,void *dest, int destSz) { #ifdef TCDB return TCDB_ReadComplexKeyDB(dbp, key, keySz, dest, destSz); #elif defined QDB return QDB_ReadComplexKeyDB(dbp, key, keySz, dest, destSz); #elif defined SQLITE3 return SQLite3_ReadComplexKeyDB(dbp, key, keySz, dest, destSz); #else return BDB_ReadComplexKeyDB(dbp, key, keySz, dest, destSz); #endif } /*****************************************************************************/ int RevealDB(CF_DB *dbp, char *key, void **result, int *rsize) /* Allocates memory for result, which is later freed automatically (on next call to this function or db close) */ { #ifdef TCDB return TCDB_RevealDB(dbp,key,result,rsize); #elif defined QDB return QDB_RevealDB(dbp,key,result,rsize); #elif defined SQLITE3 return SQLite3_RevealDB(dbp, key, result, rsize); #else return BDB_RevealDB(dbp,key,result,rsize); #endif } /*****************************************************************************/ int WriteComplexKeyDB(CF_DB *dbp, char *key, int keySz, const void *src, int srcSz) { #ifdef TCDB return TCDB_WriteComplexKeyDB(dbp, key, keySz, src, srcSz); #elif defined QDB return QDB_WriteComplexKeyDB(dbp, key, keySz, src, srcSz); #elif defined SQLITE3 return SQLite3_WriteComplexKeyDB(dbp, key, keySz, src, srcSz); #else return BDB_WriteComplexKeyDB(dbp, key, keySz, src, srcSz); #endif } /*****************************************************************************/ int DeleteComplexKeyDB(CF_DB *dbp, char *key, int size) /** * Delete a record (key,value pair) */ { #ifdef TCDB return TCDB_DeleteComplexKeyDB(dbp,key,size); #elif defined QDB return QDB_DeleteComplexKeyDB(dbp,key,size); #elif defined SQLITE3 return SQLite3_DeleteComplexKeyDB(dbp, key, size); #else return BDB_DeleteComplexKeyDB(dbp,key,size); #endif } /*****************************************************************************/ int NewDBCursor(CF_DB *dbp,CF_DBC **dbcp) { #ifdef TCDB return TCDB_NewDBCursor(dbp,dbcp); #elif defined QDB return QDB_NewDBCursor(dbp,dbcp); #elif defined SQLITE3 return SQLite3_NewDBCursor(dbp, dbcp); #else return BDB_NewDBCursor(dbp,dbcp); #endif } /*****************************************************************************/ int NextDB(CF_DB *dbp,CF_DBC *dbcp,char **key,int *ksize,void **value,int *vsize) { #ifdef TCDB return TCDB_NextDB(dbp,dbcp,key,ksize,value,vsize); #elif defined QDB return QDB_NextDB(dbp,dbcp,key,ksize,value,vsize); #elif defined SQLITE3 return SQLite3_NextDB(dbp, dbcp, key, ksize, value, vsize); #else return BDB_NextDB(dbp,dbcp,key,ksize,value,vsize); #endif } /*****************************************************************************/ int DeleteDBCursor(CF_DB *dbp,CF_DBC *dbcp) { #ifdef TCDB return TCDB_DeleteDBCursor(dbp,dbcp); #elif defined QDB return QDB_DeleteDBCursor(dbp,dbcp); #elif defined SQLITE3 return SQLite3_DeleteDBCursor(dbp, dbcp); #else return BDB_DeleteDBCursor(dbp,dbcp); #endif } /*****************************************************************************/ void OpenDBTransaction(CF_DB *dbp) { #if defined SQLITE3 SQLite3_OpenDBTransaction(dbp); #endif } /*****************************************************************************/ void CommitDBTransaction(CF_DB *dbp) { #if defined SQLITE3 SQLite3_CommitDBTransaction(dbp); #endif } /*****************************************************************************/ int ReadDB(CF_DB *dbp, char *key, void *dest, int destSz) { return ReadComplexKeyDB(dbp,key,strlen(key)+1,dest,destSz); } /*****************************************************************************/ int WriteDB(CF_DB *dbp, char *key, const void *src, int srcSz) { return WriteComplexKeyDB(dbp,key,strlen(key)+1,src,srcSz); } /*****************************************************************************/ int DeleteDB(CF_DB *dbp, char *key) { return DeleteComplexKeyDB(dbp,key,strlen(key)+1); } /*****************************************************************************/ void CloseAllDB(void) /* Closes all open DB handles */ { CF_DB *dbp = NULL; int i = 0; Debug("CloseAllDB()\n"); while (true) { if (!GetDBHandle(&dbp)) { FatalError("CloseAllDB: Could not pop next DB handle"); } if (dbp == NULL) { break; } if (!CloseDB(dbp)) { CfOut(cf_error, "", "!! CloseAllDB: Could not close DB with this handle"); } i++; } Debug("Closed %d open DB handles\n", i); } /*****************************************************************************/ static int SaveDBHandle(CF_DB *dbp) { int i; if (!ThreadLock(cft_dbhandle)) { return false; } // find first free slot i = 0; while(OPENDB[i] != NULL) { i++; if(i == MAX_OPENDB) { ThreadUnlock(cft_dbhandle); CfOut(cf_error,"","!! Too many open databases"); return false; } } OPENDB[i] = dbp; ThreadUnlock(cft_dbhandle); return true; } /*****************************************************************************/ static int RemoveDBHandle(CF_DB *dbp) /* Remove a specific DB handle */ { int i; if (!ThreadLock(cft_dbhandle)) { return false; } i = 0; while(OPENDB[i] != dbp) { i++; if(i == MAX_OPENDB) { ThreadUnlock(cft_dbhandle); CfOut(cf_error,"","!! Database handle was not found"); return false; } } // free slot OPENDB[i] = NULL; ThreadUnlock(cft_dbhandle); return true; } /*****************************************************************************/ static int GetDBHandle(CF_DB **dbp) /* Return the first unused DB handle in the parameter - NULL if empty */ { int i; if (!ThreadLock(cft_dbhandle)) { return false; } i = 0; while (OPENDB[i] == NULL) { i++; if(i == MAX_OPENDB) { ThreadUnlock(cft_dbhandle); *dbp = NULL; return true; } } *dbp = OPENDB[i]; ThreadUnlock(cft_dbhandle); return true; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/mon_network_sniffer.c������������������������������������������������������������0000644�0001750�0001750�00000026242�11715232734�015243� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #include "cf3.defs.h" #include "cf3.extern.h" #include "monitoring.h" /* Constants */ static const int SLEEPTIME = 2.5 * 60; /* Should be a fraction of 5 minutes */ /* Global variables */ static bool TCPDUMP; static bool TCPPAUSE; static FILE *TCPPIPE; static struct Item *NETIN_DIST[CF_NETATTR]; static struct Item *NETOUT_DIST[CF_NETATTR]; /* Prototypes */ static void Sniff(long iteration, double *cf_this); static void AnalyzeArrival(long iteration, char *arrival, double *cf_this); /* Implementation */ void MonNetworkSnifferSniff(long iteration, double *cf_this) { if (TCPDUMP) { Sniff(iteration, cf_this); } else { sleep(SLEEPTIME); } } /******************************************************************************/ void MonNetworkSnifferOpen(void) { char tcpbuffer[CF_BUFSIZE]; if (TCPDUMP) { struct stat statbuf; char buffer[CF_MAXVARSIZE]; sscanf(CF_TCPDUMP_COMM,"%s",buffer); if (cfstat(buffer,&statbuf) != -1) { if ((TCPPIPE = cf_popen(CF_TCPDUMP_COMM,"r")) == NULL) { TCPDUMP = false; } /* Skip first banner */ fgets(tcpbuffer,CF_BUFSIZE-1,TCPPIPE); } else { TCPDUMP = false; } } } /******************************************************************************/ void MonNetworkSnifferEnable(bool enable) { TCPDUMP = enable; Debug("use tcpdump = %d\n",TCPDUMP); } /******************************************************************************/ static void CfenvTimeOut(int signum) { alarm(0); TCPPAUSE = true; CfOut(cf_verbose,"","Time out\n"); } /******************************************************************************/ static void Sniff(long iteration, double *cf_this) { char tcpbuffer[CF_BUFSIZE]; CfOut(cf_verbose,"","Reading from tcpdump...\n"); memset(tcpbuffer,0,CF_BUFSIZE); signal(SIGALRM,CfenvTimeOut); alarm(SLEEPTIME); TCPPAUSE = false; while (!feof(TCPPIPE)) { if (TCPPAUSE) { break; } fgets(tcpbuffer,CF_BUFSIZE-1,TCPPIPE); if (TCPPAUSE) { break; } if (strstr(tcpbuffer,"tcpdump:")) /* Error message protect sleeptime */ { Debug("Error - (%s)\n",tcpbuffer); alarm(0); TCPDUMP = false; break; } AnalyzeArrival(iteration, tcpbuffer, cf_this); } signal(SIGALRM,SIG_DFL); TCPPAUSE = false; fflush(TCPPIPE); } /******************************************************************************/ static void IncrementCounter(struct Item **list,char *name) { if (!IsItemIn(*list,name)) { AppendItem(list,name,""); } IncrementItemListCounter(*list,name); } /******************************************************************************/ /* This coarsely classifies TCP dump data */ static void AnalyzeArrival(long iteration, char *arrival, double *cf_this) { char src[CF_BUFSIZE],dest[CF_BUFSIZE], flag = '.', *arr; int isme_dest, isme_src; src[0] = dest[0] = '\0'; if (strstr(arrival,"listening")) { return; } Chop(arrival); /* Most hosts have only a few dominant services, so anomalies will show up even in the traffic without looking too closely. This will apply only to the main interface .. not multifaces New format in tcpdump IP (tos 0x10, ttl 64, id 14587, offset 0, flags [DF], proto TCP (6), length 692) 128.39.89.232.22 > 84.215.40.125.48022: P 1546432:1547072(640) ack 1969 win 1593 <nop,nop,timestamp 25662737 1631360> IP (tos 0x0, ttl 251, id 14109, offset 0, flags [DF], proto UDP (17), length 115) 84.208.20.110.53 > 192.168.1.103.32769: 45266 NXDomain 0/1/0 (87) arp who-has 192.168.1.1 tell 192.168.1.103 arp reply 192.168.1.1 is-at 00:1d:7e:28:22:c6 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.1.103 > 128.39.89.10: ICMP echo request, id 48474, seq 1, length 64 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.1.103 > 128.39.89.10: ICMP echo request, id 48474, seq 2, length 64 */ for (arr = strstr(arrival,"length"); arr != NULL && *arr != ')'; arr++) { } if (arr == NULL) { arr = arrival; } else { arr++; } if (strstr(arrival,"proto TCP") || strstr(arrival,"ack")) { sscanf(arr,"%s %*c %s %c ",src,dest,&flag); DePort(src); DePort(dest); isme_dest = IsInterfaceAddress(dest); isme_src = IsInterfaceAddress(src); switch (flag) { case 'S': Debug("%ld: TCP new connection from %s to %s - i am %s\n",iteration,src,dest,VIPADDRESS); if (isme_dest) { cf_this[ob_tcpsyn_in]++; IncrementCounter(&(NETIN_DIST[tcpsyn]),src); } else if (isme_src) { cf_this[ob_tcpsyn_out]++; IncrementCounter(&(NETOUT_DIST[tcpsyn]),dest); } break; case 'F': Debug("%ld: TCP end connection from %s to %s\n",iteration,src,dest); if (isme_dest) { cf_this[ob_tcpfin_in]++; IncrementCounter(&(NETIN_DIST[tcpfin]),src); } else if (isme_src) { cf_this[ob_tcpfin_out]++; IncrementCounter(&(NETOUT_DIST[tcpfin]),dest); } break; default: Debug("%ld: TCP established from %s to %s\n",iteration,src,dest); if (isme_dest) { cf_this[ob_tcpack_in]++; IncrementCounter(&(NETIN_DIST[tcpack]),src); } else if (isme_src) { cf_this[ob_tcpack_out]++; IncrementCounter(&(NETOUT_DIST[tcpack]),dest); } break; } } else if (strstr(arrival,".53")) { sscanf(arr,"%s %*c %s %c ",src,dest,&flag); DePort(src); DePort(dest); isme_dest = IsInterfaceAddress(dest); isme_src = IsInterfaceAddress(src); Debug("%ld: DNS packet from %s to %s\n",iteration,src,dest); if (isme_dest) { cf_this[ob_dns_in]++; IncrementCounter(&(NETIN_DIST[dns]),src); } else if (isme_src) { cf_this[ob_dns_out]++; IncrementCounter(&(NETOUT_DIST[tcpack]),dest); } } else if (strstr(arrival,"proto UDP")) { sscanf(arr,"%s %*c %s %c ",src,dest,&flag); DePort(src); DePort(dest); isme_dest = IsInterfaceAddress(dest); isme_src = IsInterfaceAddress(src); Debug("%ld: UDP packet from %s to %s\n",iteration,src,dest); if (isme_dest) { cf_this[ob_udp_in]++; IncrementCounter(&(NETIN_DIST[udp]),src); } else if (isme_src) { cf_this[ob_udp_out]++; IncrementCounter(&(NETOUT_DIST[udp]),dest); } } else if (strstr(arrival,"proto ICMP")) { sscanf(arr,"%s %*c %s %c ",src,dest,&flag); DePort(src); DePort(dest); isme_dest = IsInterfaceAddress(dest); isme_src = IsInterfaceAddress(src); Debug("%ld: ICMP packet from %s to %s\n",iteration,src,dest); if (isme_dest) { cf_this[ob_icmp_in]++; IncrementCounter(&(NETIN_DIST[icmp]),src); } else if (isme_src) { cf_this[ob_icmp_out]++; IncrementCounter(&(NETOUT_DIST[icmp]),src); } } else { Debug("%ld: Miscellaneous undirected packet (%.100s)\n",iteration,arrival); cf_this[ob_tcpmisc_in]++; /* Here we don't know what source will be, but .... */ sscanf(arrival,"%s",src); if (!isdigit((int)*src)) { Debug("Assuming continuation line...\n"); return; } DePort(src); if (strstr(arrival,".138")) { snprintf(dest,CF_BUFSIZE-1,"%s NETBIOS",src); } else if (strstr(arrival,".2049")) { snprintf(dest,CF_BUFSIZE-1,"%s NFS",src); } else { strncpy(dest,src,60); } IncrementCounter(&(NETIN_DIST[tcpmisc]),dest); } } /******************************************************************************/ static void SaveTCPEntropyData(struct Item *list,int i,char *inout) { struct Item *ip; FILE *fp; char filename[CF_BUFSIZE]; CfOut(cf_verbose,"","TCP Save %s\n",TCPNAMES[i]); if (list == NULL) { CfOut(cf_verbose,"","No %s-%s events\n",TCPNAMES[i],inout); return; } if (strncmp(inout,"in",2) == 0) { snprintf(filename,CF_BUFSIZE-1,"%s/state/cf_incoming.%s",CFWORKDIR,TCPNAMES[i]); } else { snprintf(filename,CF_BUFSIZE-1,"%s/state/cf_outgoing.%s",CFWORKDIR,TCPNAMES[i]); } CfOut(cf_verbose,"","TCP Save %s\n",filename); if ((fp = fopen(filename,"w")) == NULL) { CfOut(cf_verbose,"","Unable to write datafile %s\n",filename); return; } for (ip = list; ip != NULL; ip=ip->next) { fprintf(fp,"%d %s\n",ip->counter,ip->name); } fclose(fp); } /******************************************************************************/ void MonNetworkSnifferGatherData(double *cf_this) { int i; char vbuff[CF_BUFSIZE]; for (i = 0; i < CF_NETATTR; i++) { struct stat statbuf; time_t now = time(NULL); Debug("save incoming %s\n",TCPNAMES[i]); snprintf(vbuff,CF_MAXVARSIZE,"%s/state/cf_incoming.%s",CFWORKDIR,TCPNAMES[i]); if (cfstat(vbuff,&statbuf) != -1) { if ((ByteSizeList(NETIN_DIST[i]) < statbuf.st_size) && (now < statbuf.st_mtime+40*60)) { CfOut(cf_verbose,"","New state %s is smaller, retaining old for 40 mins longer\n",TCPNAMES[i]); DeleteItemList(NETIN_DIST[i]); NETIN_DIST[i] = NULL; continue; } } SaveTCPEntropyData(NETIN_DIST[i],i,"in"); double entropy = MonEntropyCalculate(NETIN_DIST[i]); MonEntropyClassesSet(TCPNAMES[i], "in", entropy); DeleteItemList(NETIN_DIST[i]); NETIN_DIST[i] = NULL; } for (i = 0; i < CF_NETATTR; i++) { struct stat statbuf; time_t now = time(NULL); Debug("save outgoing %s\n",TCPNAMES[i]); snprintf(vbuff,CF_MAXVARSIZE,"%s/state/cf_outgoing.%s",CFWORKDIR,TCPNAMES[i]); if (cfstat(vbuff,&statbuf) != -1) { if ((ByteSizeList(NETOUT_DIST[i]) < statbuf.st_size) && (now < statbuf.st_mtime+40*60)) { CfOut(cf_verbose,"","New state %s is smaller, retaining old for 40 mins longer\n",TCPNAMES[i]); DeleteItemList(NETOUT_DIST[i]); NETOUT_DIST[i] = NULL; continue; } } SaveTCPEntropyData(NETOUT_DIST[i],i,"out"); double entropy = MonEntropyCalculate(NETOUT_DIST[i]); MonEntropyClassesSet(TCPNAMES[i], "out", entropy); DeleteItemList(NETOUT_DIST[i]); NETOUT_DIST[i] = NULL; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/cfpromises.c���������������������������������������������������������������������0000644�0001750�0001750�00000016115�11715232734�013335� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*******************************************************************/ /* */ /* Promises cfpromises.c */ /* */ /* Cfengine AS 1994/96 */ /* */ /*******************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*******************************************************************/ int main (int argc,char *argv[]); /*******************************************************************/ /* Command line options */ /*******************************************************************/ const char *ID = "The promise agent is a validator and analysis tool for\n" "configuration files belonging to any of the components\n" "of Cfengine. Configurations that make changes must be\n" "approved by this validator before being executed."; const struct option OPTIONS[14] = { { "help",no_argument,0,'h' }, { "bundlesequence",required_argument,0,'b' }, { "debug",optional_argument,0,'d' }, { "verbose",no_argument,0,'v' }, { "dry-run",no_argument,0,'n'}, { "version",no_argument,0,'V' }, { "file",required_argument,0,'f'}, { "define",required_argument,0,'D' }, { "negate",required_argument,0,'N' }, { "inform",no_argument,0,'I'}, { "diagnostic",no_argument,0,'x'}, { "analysis",no_argument,0,'a'}, { "reports",no_argument,0,'r'}, { NULL,0,0,'\0' } }; const char *HINTS[14] = { "Print the help message", "Use the specified bundlesequence for verification", "Set debugging level 0,1,2,3", "Output verbose information about the behaviour of the agent", "All talk and no action mode - make no changes, only inform of promises not kept", "Output the version of the software", "Specify an alternative input file than the default", "Define a list of comma separated classes to be defined at the start of execution", "Define a list of comma separated classes to be undefined at the start of execution", "Print basic information about changes made to the system, i.e. promises repaired", "Activate internal diagnostics (developers only)", "Perform additional analysis of configuration", "Generate reports about configuration and insert into CFDB", NULL }; /*******************************************************************/ /* Level 0 : Main */ /*******************************************************************/ int main(int argc,char *argv[]) { CheckOpts(argc,argv); GenericInitialize(argc,argv,"common"); ThisAgentInit(); AnalyzePromiseConflicts(); GenericDeInitialize(); if (ERRORCOUNT > 0) { CfOut(cf_verbose,""," !! Inputs are invalid\n"); exit(1); } else { CfOut(cf_verbose,""," -> Inputs are valid\n"); exit(0); } } /*******************************************************************/ /* Level 1 */ /*******************************************************************/ void CheckOpts(int argc,char **argv) { extern char *optarg; char arg[CF_BUFSIZE]; int optindex = 0; int c; while ((c=getopt_long(argc,argv,"ad:vnIf:D:N:VSrxMb:",OPTIONS,&optindex)) != EOF) { switch ((char) c) { case 'f': if (optarg && strlen(optarg) < 5) { snprintf(arg,CF_MAXVARSIZE," -f used but argument \"%s\" incorrect",optarg); FatalError(arg); } strncpy(VINPUTFILE,optarg,CF_BUFSIZE-1); VINPUTFILE[CF_BUFSIZE-1] = '\0'; MINUSF = true; break; case 'd': NewClass("opt_debug"); switch ((optarg==NULL) ? '3' : *optarg) { case '1': D1 = true; DEBUG = true; break; case '2': D2 = true; DEBUG = true; break; default: DEBUG = true; break; } break; case 'b': if (optarg) { CBUNDLESEQUENCE = SplitStringAsRList(optarg, ','); CBUNDLESEQUENCE_STR = optarg; } break; case 'K': IGNORELOCK = true; break; case 'D': NewClassesFromString(optarg); break; case 'N': NegateClassesFromString(optarg,&VNEGHEAP); break; case 'I': INFORM = true; break; case 'v': VERBOSE = true; break; case 'n': DONTDO = true; IGNORELOCK = true; LOOKUP = true; NewClass("opt_dry_run"); break; case 'V': PrintVersionBanner("cf-promises"); exit(0); case 'h': Syntax("cf-promises - cfengine's promise analyzer",OPTIONS,HINTS,ID); exit(0); case 'M': ManPage("cf-promises - cfengine's promise analyzer",OPTIONS,HINTS,ID); exit(0); case 'r': PrependRScalar(&GOALS,"goal.*",CF_SCALAR); PrependRScalar(&GOALCATEGORIES,"goals",CF_SCALAR); SHOWREPORTS = true; break; case 'x': SelfDiagnostic(); exit(0); case 'a': printf("Self-analysis is not yet implemented."); exit(0); break; default: Syntax("cf-promises - cfengine's promise analyzer",OPTIONS,HINTS,ID); exit(1); } } if (argv[optind] != NULL) { CfOut(cf_error,"","Unexpected argument with no preceding option: %s\n",argv[optind]); } Debug("Set debugging\n"); } /*******************************************************************/ void ThisAgentInit() { AddGoalsToDB(Rlist2String(GOALS,","),Rlist2String(GOALCATEGORIES,",")); SHOWREPORTS = false; } /* EOF */ ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/prototypes3.h��������������������������������������������������������������������0000644�0001750�0001750�00000155707�11715232734�013516� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: prototypes3.h */ /* */ /* Created: Sun Aug 5 13:43:56 2007 */ /* */ /*****************************************************************************/ #ifndef CFENGINE_PROTOTYPES3_H #define CFENGINE_PROTOTYPES3_H #include "compiler.h" /* Versions */ const char *Version(void); const char *NameVersion(void); /* full-write.c */ int cf_full_write (int desc, char *ptr, size_t len); /* cflex.l */ int yylex (void); /* cfparse.y */ void yyerror (const char *s); int yyparse (void); /* Generic stubs for the agents */ void ThisAgentInit(void); void KeepPromises(void); /* alloc.c */ void *xcalloc(size_t nmemb, size_t size); void *xmalloc(size_t size); void *xrealloc(void *ptr, size_t size); char *xstrdup(const char *str); char *xstrndup(const char *str, size_t n); /* agent.c */ int ScheduleAgentOperations(struct Bundle *bp); /* agentdiagnostic.c */ void AgentDiagnostic(char *inputfile); /* alphalist.c */ void InitAlphaList(struct AlphaList *al); int InAlphaList(struct AlphaList al,const char *string); int MatchInAlphaList(struct AlphaList al,char *string); void PrependAlphaList(struct AlphaList *al, const char *string); void IdempPrependAlphaList(struct AlphaList *al, const char *string); void ListAlphaList(FILE *fp,struct AlphaList al,char sep); void DeleteAlphaList(struct AlphaList *al); struct AlphaList *CopyAlphaListPointers(struct AlphaList *al,struct AlphaList *ap); /* args.c */ int MapBodyArgs(char *scopeid,struct Rlist *give,struct Rlist *take); struct Rlist *NewExpArgs(struct FnCall *fp, struct Promise *pp); void ArgTemplate(struct FnCall *fp,struct FnCallArg *argtemplate,struct Rlist *finalargs); void DeleteExpArgs(struct Rlist *args); /* assoc.c */ struct CfAssoc *NewAssoc(const char *lval,void *rval,char rtype,enum cfdatatype dt); void DeleteAssoc(struct CfAssoc *ap); struct CfAssoc *CopyAssoc(struct CfAssoc *old); /* attributes.c */ struct Attributes GetEnvironmentsAttributes(struct Promise *pp); struct CfEnvironments GetEnvironmentsConstraints(struct Promise *pp); struct Attributes GetOutputsAttributes(struct Promise *pp); struct Attributes GetServicesAttributes(struct Promise *pp); struct CfServices GetServicesConstraints(struct Promise *pp); struct Attributes GetFilesAttributes(struct Promise *pp); struct Attributes GetReportsAttributes(struct Promise *pp); struct Attributes GetExecAttributes(struct Promise *pp); struct Attributes GetProcessAttributes(struct Promise *pp); struct Attributes GetStorageAttributes(struct Promise *pp); struct Attributes GetClassContextAttributes(struct Promise *pp); struct Attributes GetTopicsAttributes(struct Promise *pp); struct Attributes GetThingsAttributes(struct Promise *pp); struct Attributes GetInferencesAttributes(struct Promise *pp); struct Attributes GetOccurrenceAttributes(struct Promise *pp); struct Attributes GetPackageAttributes(struct Promise *pp); struct Attributes GetMeasurementAttributes(struct Promise *pp); struct Attributes GetDatabaseAttributes(struct Promise *pp); struct Packages GetPackageConstraints(struct Promise *pp); struct ExecContain GetExecContainConstraints(struct Promise *pp); struct Recursion GetRecursionConstraints(struct Promise *pp); struct FileSelect GetSelectConstraints(struct Promise *pp); struct FilePerms GetPermissionConstraints(struct Promise *pp); struct TransactionContext GetTransactionConstraints(struct Promise *pp); struct DefineClasses GetClassDefinitionConstraints(struct Promise *pp); struct FileRename GetRenameConstraints(struct Promise *pp); struct FileDelete GetDeleteConstraints(struct Promise *pp); struct FileChange GetChangeMgtConstraints(struct Promise *pp); struct FileCopy GetCopyConstraints(struct Promise *pp); struct FileLink GetLinkConstraints(struct Promise *pp); struct Context GetContextConstraints(struct Promise *pp); struct ProcessSelect GetProcessFilterConstraints(struct Promise *pp); struct ProcessCount GetMatchesConstraints(struct Promise *pp); struct EditDefaults GetEditDefaults(struct Promise *pp); struct Attributes GetMethodAttributes(struct Promise *pp); struct Attributes GetInterfacesAttributes(struct Promise *pp); struct Attributes GetInsertionAttributes(struct Promise *pp); struct EditLocation GetLocationAttributes(struct Promise *pp); struct Attributes GetDeletionAttributes(struct Promise *pp); struct Attributes GetColumnAttributes(struct Promise *pp); struct Attributes GetReplaceAttributes(struct Promise *pp); struct EditRegion GetRegionConstraints(struct Promise *pp); struct EditReplace GetReplaceConstraints(struct Promise *pp); struct EditColumn GetColumnConstraints(struct Promise *pp); struct TopicAssociation GetAssociationConstraints(struct Promise *pp); struct StorageMount GetMountConstraints(struct Promise *pp); struct StorageVolume GetVolumeConstraints(struct Promise *pp); struct CfTcpIp GetTCPIPAttributes(struct Promise *pp); struct Report GetReportConstraints(struct Promise *pp); struct LineSelect GetInsertSelectConstraints(struct Promise *pp); struct LineSelect GetDeleteSelectConstraints(struct Promise *pp); struct Measurement GetMeasurementConstraint(struct Promise *pp); struct CfACL GetAclConstraints(struct Promise *pp); struct CfDatabase GetDatabaseConstraints(struct Promise *pp); /* bootstrap.c */ void CheckAutoBootstrap(void); void SetPolicyServer(char *name); void CreateFailSafe(char *name); void SetDocRoot(char *name); /* cfstream.c */ void CfFOut(char *filename,enum cfreport level,char *errstr,char *fmt, ...); void CfOut(enum cfreport level, const char *errstr, const char *fmt, ...); void cfPS(enum cfreport level,char status,char *errstr,struct Promise *pp,struct Attributes attr,char *fmt, ...); void CfFile(FILE *fp,char *fmt, ...); char *GetErrorStr(void); /* cf_sql.c */ int CfConnectDB(CfdbConn *cfdb,enum cfdbtype dbtype,char *remotehost,char *dbuser, char *passwd, char *db); void CfCloseDB(CfdbConn *cfdb); void CfVoidQueryDB(CfdbConn *cfdb,char *query); void CfNewQueryDB(CfdbConn *cfdb,char *query); char **CfFetchRow(CfdbConn *cfdb); char *CfFetchColumn(CfdbConn *cfdb,int col); void CfDeleteQuery(CfdbConn *cfdb); /* client_code.c */ void DetermineCfenginePort(void); struct cfagent_connection *NewServerConnection(struct Attributes attr,struct Promise *pp); struct cfagent_connection *ServerConnection(char *server,struct Attributes attr,struct Promise *pp); void ServerDisconnection(struct cfagent_connection *conn); int cf_remote_stat(char *file,struct stat *buf,char *stattype,struct Attributes attr,struct Promise *pp); void DeleteClientCache(struct Attributes attr,struct Promise *pp); int CompareHashNet(char *file1,char *file2,struct Attributes attr,struct Promise *pp); int CopyRegularFileNet(char *source,char *new,off_t size,struct Attributes attr,struct Promise *pp); int EncryptCopyRegularFileNet(char *source,char *new,off_t size,struct Attributes attr,struct Promise *pp); int ServerConnect(struct cfagent_connection *conn,char *host,struct Attributes attr, struct Promise *pp); void DestroyServerConnection(struct cfagent_connection *conn); /* Only for OpenDirForPromise implementation */ CFDIR *OpenDirRemote(const char *dirname,struct Attributes attr,struct Promise *pp); /* Mark connection as free */ void ServerNotBusy(struct cfagent_connection *conn); /* client_protocols.c */ int IdentifyAgent(int sd,char *localip,int family); int AuthenticateAgent(struct cfagent_connection *conn,struct Attributes attr,struct Promise *pp); int BadProtoReply(char *buf); int OKProtoReply(char *buf); int FailedProtoReply(char *buf); /* chflags.c */ int ParseFlagString (struct Rlist *flags, u_long *plusmask, u_long *minusmask); /* communication.c */ struct cfagent_connection *NewAgentConn(void); void DeleteAgentConn(struct cfagent_connection *ap); void DePort(char *address); int IsIPV6Address(char *name); int IsIPV4Address(char *name); const char *Hostname2IPString(const char *hostname); char *IPString2Hostname(char *ipaddress); int GetMyHostInfo(char nameBuf[MAXHOSTNAMELEN], char ipBuf[MAXIP4CHARLEN]); /* comparray.c */ int FixCompressedArrayValue (int i, char *value, struct CompressedArray **start); void DeleteCompressedArray (struct CompressedArray *start); int CompressedArrayElementExists (struct CompressedArray *start, int key); char *CompressedArrayValue (struct CompressedArray *start, int key); /* constraints.c */ struct Constraint *AppendConstraint(struct Constraint **conlist,char *lval, void *rval, char type,char *classes,int body); void DeleteConstraintList(struct Constraint *conlist); void EditScalarConstraint(struct Constraint *conlist,char *lval,char *rval); void *GetConstraint(char *lval,struct Promise *list,char type); int GetBooleanConstraint(char *lval,struct Promise *list); int GetRawBooleanConstraint(char *lval,struct Constraint *list); int GetIntConstraint(char *lval,struct Promise *list); double GetRealConstraint(char *lval,struct Promise *list); mode_t GetOctalConstraint(char *lval,struct Promise *list); uid_t GetUidConstraint(char *lval,struct Promise *pp); gid_t GetGidConstraint(char *lval,struct Promise *pp); struct Rlist *GetListConstraint(char *lval,struct Promise *list); void ReCheckAllConstraints(struct Promise *pp); int GetBundleConstraint(char *lval,struct Promise *list); struct PromiseIdent *NewPromiseId(char *handle,struct Promise *pp); void DeleteAllPromiseIds(void); /* conversion.c */ char *EscapeJson(char *s, char *out, int outSz); char *EscapeRegex(char *s, char *out, int outSz); char *EscapeQuotes(char *s, char *out, int outSz); char *MapAddress (char *addr); void IPString2KeyDigest(char *ipv4,char *result); enum cfhypervisors Str2Hypervisors(char *s); enum cfenvironment_state Str2EnvState(char *s); enum insert_match String2InsertMatch(char *s); long Months2Seconds(int m); enum cfinterval Str2Interval(char *s); int SyslogPriority2Int(char *s); enum cfdbtype Str2dbType(char *s); char *Rlist2String(struct Rlist *list,char *sep); int Signal2Int(char *s); enum cfreport String2ReportLevel(char *typestr); enum cfhashes String2HashType(char *typestr); enum cfcomparison String2Comparison(char *s); enum cflinktype String2LinkType(char *s); enum cfdatatype Typename2Datatype(char *name); enum cfdatatype GetControlDatatype(char *varname,struct BodySyntax *bp); enum cfagenttype Agent2Type(char *name); enum cfsbundle Type2Cfs(char *name); enum representations String2Representation(char *s); int GetBoolean(char *val); long Str2Int(char *s); long TimeCounter2Int(const char *s); long TimeAbs2Int(char *s); mode_t Str2Mode(char *s); double Str2Double(char *s); void IntRange2Int(char *intrange,long *min,long *max,struct Promise *pp); int Month2Int(char *string); int MonthLen2Int(char *string, int len); void TimeToDateStr(time_t t, char *outStr, int outStrSz); const char *GetArg0(const char *execstr); void CommPrefix(char *execstr,char *comm); int NonEmptyLine(char *s); int Day2Number(char *datestring); void UtcShiftInterval(time_t t, char *out, int outSz); enum action_policy Str2ActionPolicy(char *s); enum version_cmp Str2PackageSelect(char *s); enum package_actions Str2PackageAction(char *s); enum cf_acl_method Str2AclMethod(char *string); enum cf_acl_type Str2AclType(char *string); enum cf_acl_inherit Str2AclInherit(char *string); enum cf_acl_inherit Str2ServicePolicy(char *string); char *Dtype2Str(enum cfdatatype dtype); char *Item2String(struct Item *ip); int IsNumber(char *s); int IsRealNumber(char *s); enum cfd_menu String2Menu(char *s); #ifndef MINGW struct UidList *Rlist2UidList(struct Rlist *uidnames, struct Promise *pp); struct GidList *Rlist2GidList(struct Rlist *gidnames, struct Promise *pp); uid_t Str2Uid(char *uidbuff,char *copy,struct Promise *pp); gid_t Str2Gid(char *gidbuff,char *copy,struct Promise *pp); #endif /* NOT MINGW */ /* crypto.c */ void KeepKeyPromises(void); void DebugBinOut(char *buffer,int len,char *com); void RandomSeed (void); void LoadSecretKeys (void); int EncryptString (char type,char *in, char *out, unsigned char *key, int len); int DecryptString (char type,char *in, char *out, unsigned char *key, int len); RSA *HavePublicKey (char *username,char *ipaddress,char *digest); RSA *HavePublicKeyByIP(char *username,char *ipaddress); void SavePublicKey (char *username,char *ipaddress,char *digest,RSA *key); int RemovePublicKeys(const char *hostname); /* dbm_api.c */ int OpenDB(char *filename, CF_DB **dbp); int CloseDB(CF_DB *dbp); int ValueSizeDB(CF_DB *dbp, char *key); int ReadComplexKeyDB(CF_DB *dbp, char *key, int keySz,void *dest, int destSz); int RevealDB(CF_DB *dbp, char *key, void **result, int *rsize); int WriteComplexKeyDB(CF_DB *dbp, char *key,int keySz, const void *src, int srcSz); int DeleteComplexKeyDB(CF_DB *dbp, char *key, int size); int NewDBCursor(CF_DB *dbp,CF_DBC **dbcp); int NextDB(CF_DB *dbp,CF_DBC *dbcp,char **key,int *ksize,void **value,int *vsize); int DeleteDBCursor(CF_DB *dbp,CF_DBC *dbcp); int ReadDB(CF_DB *dbp, char *key, void *dest, int destSz); int WriteDB(CF_DB *dbp, char *key, const void *src, int srcSz); int DeleteDB(CF_DB *dbp, char *key); void OpenDBTransaction(CF_DB *dbp); void CommitDBTransaction(CF_DB *dbp); void CloseAllDB(void); /* dbm_berkely.c */ #ifdef BDB // FIXME int BDB_OpenDB(char *filename,DB **dbp); int BDB_CloseDB(DB *dbp); int BDB_ValueSizeDB(DB *dbp, char *key); int BDB_ReadComplexKeyDB(DB *dbp,char *name,int keysize,void *ptr,int size); int BDB_RevealDB(DB *dbp,char *name,void **result,int *rsize); int BDB_WriteComplexKeyDB(DB *dbp,char *name,int keysize, const void *ptr,int size); int BDB_DeleteComplexKeyDB(DB *dbp,char *name,int size); int BDB_NewDBCursor(CF_DB *dbp,CF_DBC **dbcp); int BDB_NextDB(CF_DB *dbp,CF_DBC *dbcp,char **key,int *ksize,void **value,int *vsize); int BDB_DeleteDBCursor(CF_DB *dbp,CF_DBC *dbcp); #endif /* dbm_quick.c */ #ifdef QDB // FIXME int QDB_OpenDB(char *filename, CF_QDB **qdbp); int QDB_CloseDB(CF_QDB *qdbp); int QDB_ValueSizeDB(CF_QDB *qdbp, char *key); int QDB_ReadComplexKeyDB(CF_QDB *qdbp, char *key, int keySz,void *dest, int destSz); int QDB_RevealDB(CF_QDB *qdbp, char *key, void **result, int *rsize); int QDB_WriteComplexKeyDB(CF_QDB *qdbp, char *key, int keySz, const void *src, int srcSz); int QDB_DeleteComplexKeyDB(CF_QDB *qdbp, char *key, int size); int QDB_NewDBCursor(CF_QDB *qdbp,CF_QDBC **qdbcp); int QDB_NextDB(CF_QDB *qdbp,CF_QDBC *qdbcp,char **key,int *ksize,void **value,int *vsize); int QDB_DeleteDBCursor(CF_QDB *qdbp,CF_QDBC *qdbcp); #endif /* dbm_tokyocab.c */ #ifdef TCDB int TCDB_OpenDB(char *filename, CF_TCDB **hdbp); int TCDB_CloseDB(CF_TCDB *hdbp); int TCDB_ValueSizeDB(CF_TCDB *hdbp, char *key); int TCDB_ReadComplexKeyDB(CF_TCDB *hdbp, char *key, int keySz,void *dest, int destSz); int TCDB_RevealDB(CF_TCDB *hdbp, char *key, void **result, int *rsize); int TCDB_WriteComplexKeyDB(CF_TCDB *hdbp, char *key, int keySz, const void *src, int srcSz); int TCDB_DeleteComplexKeyDB(CF_TCDB *hdbp, char *key, int size); int TCDB_NewDBCursor(CF_TCDB *hdbp,CF_TCDBC **hdbcp); int TCDB_NextDB(CF_TCDB *hdbp,CF_TCDBC *hdbcp,char **key,int *ksize,void **value,int *vsize); int TCDB_DeleteDBCursor(CF_TCDB *hdbp,CF_TCDBC *hdbcp); #endif /* dir.c */ CFDIR *OpenDirForPromise(const char *dirname, struct Attributes attr, struct Promise *pp); CFDIR *OpenDirLocal(const char *dirname); const struct dirent *ReadDir(CFDIR *dir); void CloseDir(CFDIR *dir); /* Only for OpenDirRemote implementation */ struct dirent *AllocateDirentForFilename(const char *filename); /* dtypes.c */ int IsSocketType(char *s); int IsTCPType(char *s); /* enterprise_stubs.c */ void WebCache(char *s,char *t); void EnterpriseModuleTrick(void); int CheckDatabaseSanity(struct Attributes a, struct Promise *pp); void VerifyRegistryPromise(struct Attributes a,struct Promise *pp); int CfSessionKeySize(char c); char CfEnterpriseOptions(void); const EVP_CIPHER *CfengineCipher(char type); void Aggregate(char *stylesheet,char *banner,char *footer,char *webdriver); void SetPolicyServer(char *name); int IsEnterprise(void); void EnterpriseContext(void); char *GetProcessOptions(void); int EnterpriseExpiry(void); char *GetConsolePrefix(void); char *MailSubject(void); void CheckAutoBootstrap(void); void CheckLicenses(void); void RegisterBundleDependence(char *absscope,struct Promise *pp); void MapPromiseToTopic(FILE *fp,struct Promise *pp,const char *version); void ShowTopicRepresentation(FILE *fp); void PreSanitizePromise(struct Promise *pp); void Nova_ShowTopicRepresentation(FILE *fp); void NoteEfficiency(double e); void HistoryUpdate(struct Averages newvals); void CfGetClassName(int i,char *name); void LookUpClassName(int i,char *name); void SummarizePromiseRepaired(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web); void SummarizePromiseNotKept(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web); void SummarizeCompliance(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web); void SummarizePerPromiseCompliance(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web); void SummarizeSetuid(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web); void SummarizeFileChanges(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web); void SummarizeValue(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web); void VerifyMeasurement(double *this,struct Attributes a,struct Promise *pp); void SetMeasurementPromises(struct Item **classlist); void LongHaul(void); void VerifyACL(char *file,struct Attributes a, struct Promise *pp); int CheckACLSyntax(char *file,struct CfACL acl,struct Promise *pp); int CfVerifyTablePromise(CfdbConn *cfdb,char *name,struct Rlist *columns,struct Attributes a,struct Promise *pp); void LogFileChange(char *file,int change,struct Attributes a,struct Promise *pp); void RemoteSyslog(struct Attributes a,struct Promise *pp); int VerifyDatabasePromise(CfdbConn *cfdb,char *database,struct Attributes a,struct Promise *pp); int VerifyTablePromise(CfdbConn *cfdb,char *table,struct Rlist *columns,struct Attributes a,struct Promise *pp); void ReportPatches(struct CfPackageManager *list); void SummarizeSoftware(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web); void SummarizeUpdates(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web); void VerifyServices(struct Attributes a,struct Promise *pp); void LoadSlowlyVaryingObservations(void); void MonOtherInit(void); void MonOtherGatherData(double *cf_this); void RegisterLiteralServerData(char *handle,struct Promise *pp); int ReturnLiteralData(char *handle,char *ret); char *GetRemoteScalar(char *proto,char *handle,char *server,int encrypted,char *rcv); char *PromiseID(struct Promise *pp); void NotePromiseCompliance(struct Promise *pp,double val,enum cf_status status,char *reasoin); time_t GetPromiseCompliance(struct Promise *pp,double *value,double *average,double *var,time_t *lastseen); void SyntaxCompletion(char *s); void SyntaxExport(void); int GetRegistryValue(char *key,char *name,char *buf, int bufSz); void NoteVarUsage(void); void NoteVarUsageDB(void); void SummarizeVariables(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web); void CSV2XML(struct Rlist *list); void *CfLDAPValue(char *uri,char *dn,char *filter,char *name,char *scope,char *sec); void *CfLDAPList(char *uri,char *dn,char *filter,char *name,char *scope,char *sec); void *CfLDAPArray(char *array,char *uri,char *dn,char *filter,char *scope,char *sec); void *CfRegLDAP(char *uri,char *dn,char *filter,char *name,char *scope,char *regex,char *sec); void CacheUnreliableValue(char *caller,char *handle,char *buffer); int RetrieveUnreliableValue(char *caller,char *handle,char *buffer); void TranslatePath(char *new,const char *old); void GrandSummary(void); void TrackValue(char *date,double kept,double repaired, double notkept); void SetBundleOutputs(char *name); void ResetBundleOutputs(char *name); void SetPromiseOutputs(struct Promise *pp); void VerifyOutputsPromise(struct Promise *pp); void SpecialQuote(char *topic,char *type); void LastSawBundle(char *name); int GetInstalledPkgsRpath(struct CfPackageItem **pkgList, struct Attributes a, struct Promise *pp); int ExecPackageCommandRpath(char *command,int verify,int setCmdClasses,struct Attributes a,struct Promise *pp); int ForeignZone(char *s); void NewPromiser(struct Promise *pp); void AnalyzePromiseConflicts(void); void AddGoalsToDB(char *goal_patterns, char *goal_categories); /* env_context.c */ /* - Parsing/evaluating expressions - */ void ValidateClassSyntax(const char *str); bool IsDefinedClass(const char *class); bool IsExcluded(const char *exception); bool EvalProcessResult(const char *process_result, struct AlphaList *proc_attr); bool EvalFileResult(const char *file_result, struct AlphaList *leaf_attr); /* - Rest - */ int Abort(void); void KeepClassContextPromise(struct Promise *pp); void PushPrivateClassContext(void); void PopPrivateClassContext(void); void DeletePrivateClassContext(void); void DeleteEntireHeap(void); void NewPersistentContext(char *name,unsigned int ttl_minutes,enum statepolicy policy); void DeletePersistentContext(char *name); void LoadPersistentContext(void); void AddEphemeralClasses(struct Rlist *classlist); void NewClass(const char *oclass); /* Copies oclass */ void NewBundleClass(char *class,char *bundle); struct Rlist *SplitContextExpression(char *context,struct Promise *pp); void DeleteClass(char *class); int VarClassExcluded(struct Promise *pp,char **classes); void NewClassesFromString(char *classlist); void NegateClassesFromString(char *class,struct Item **heap); void AddPrefixedClasses(char *name,char *classlist); int IsHardClass (char *sp); void SaveClassEnvironment(void); /* env_monitor.c */ void MonInitialize(void); void StartServer (int argc, char **argv); /* evalfunction.c */ struct Rval CallFunction(FnCallType *function, struct FnCall *fp, struct Rlist *finalargs); void *CfReadFile(char *filename,int maxsize); void ModuleProtocol(char *command,char *line,int print); /* expand.c */ void ExpandPromise(enum cfagenttype ag,char *scopeid,struct Promise *pp,void *fnptr); void ExpandPromiseAndDo(enum cfagenttype ag,char *scope,struct Promise *p,struct Rlist *scalarvars,struct Rlist *listvars,void (*fnptr)()); struct Rval ExpandDanglers(char *scope,struct Rval rval,struct Promise *pp); void ScanRval(char *scope,struct Rlist **los,struct Rlist **lol,void *string,char type,struct Promise *pp); int IsExpandable(const char *str); int ExpandScalar(const char *string, char buffer[CF_EXPANDSIZE]); int ExpandThis(enum cfreport level,char *string,char buffer[CF_EXPANDSIZE]); struct Rval ExpandBundleReference(char *scopeid,void *rval,char type); struct FnCall *ExpandFnCall(char *contextid,struct FnCall *f,int expandnaked); struct Rval ExpandPrivateRval(char *contextid,void *rval,char type); struct Rlist *ExpandList(char *scopeid,struct Rlist *list,int expandnaked); struct Rval EvaluateFinalRval(char *scopeid,void *rval,char rtype,int forcelist,struct Promise *pp); int IsNakedVar(char *str,char vtype); void GetNaked(char *s1, char *s2); void ConvergeVarHashPromise(char *scope,struct Promise *pp,int checkdup); /* exec_tool.c */ int IsExecutable(const char *file); int ShellCommandReturnsZero(char *comm,int useshell); int GetExecOutput(char *command,char *buffer,int useshell); void ActAsDaemon(int preserve); char *ShEscapeCommand(char *s); int ArgSplitCommand(char *comm,char arg[CF_MAXSHELLARGS][CF_BUFSIZE]); /* files_copy.c */ void *CopyFileSources(char *destination,struct Attributes attr,struct Promise *pp); int CopyRegularFileDisk(char *source,char *new,struct Attributes attr,struct Promise *pp); void CheckForFileHoles(struct stat *sstat,struct Promise *pp); int FSWrite(char *new,int dd,char *buf,int towrite,int *last_write_made_hole,int n_read,struct Attributes attr,struct Promise *pp); /* files_edit.c */ struct edit_context *NewEditContext(char *filename,struct Attributes a,struct Promise *pp); void FinishEditContext(struct edit_context *ec,struct Attributes a,struct Promise *pp); int LoadFileAsItemList(struct Item **liststart,char *file,struct Attributes a,struct Promise *pp); int SaveItemListAsFile(struct Item *liststart,char *file,struct Attributes a,struct Promise *pp); int AppendIfNoSuchLine(char *filename, char *line); /* files_editline.c */ int ScheduleEditLineOperations(char *filename,struct Bundle *bp,struct Attributes a,struct Promise *pp); /* files_links.c */ char VerifyLink(char *destination,char *source,struct Attributes attr,struct Promise *pp); char VerifyAbsoluteLink(char *destination,char *source,struct Attributes attr,struct Promise *pp); char VerifyRelativeLink(char *destination,char *source,struct Attributes attr,struct Promise *pp); char VerifyHardLink(char *destination,char *source,struct Attributes attr,struct Promise *pp); int KillGhostLink(char *name,struct Attributes attr,struct Promise *pp); int MakeHardLink (char *from,char *to,struct Attributes attr,struct Promise *pp); int ExpandLinks(char *dest,char *from,int level); /* files_hashes.c */ int FileHashChanged(char *filename,unsigned char digest[EVP_MAX_MD_SIZE+1],int warnlevel,enum cfhashes type,struct Attributes attr,struct Promise *pp); void PurgeHashes(char *file,struct Attributes attr,struct Promise *pp); void DeleteHash(CF_DB *dbp,enum cfhashes type,char *name); struct Checksum_Value *NewHashValue(unsigned char digest[EVP_MAX_MD_SIZE+1]); int CompareFileHashes(char *file1,char *file2,struct stat *sstat,struct stat *dstat,struct Attributes attr,struct Promise *pp); int CompareBinaryFiles(char *file1,char *file2,struct stat *sstat,struct stat *dstat,struct Attributes attr,struct Promise *pp); void HashFile(char *filename,unsigned char digest[EVP_MAX_MD_SIZE+1],enum cfhashes type); void HashString(char *buffer,int len,unsigned char digest[EVP_MAX_MD_SIZE+1],enum cfhashes type); int HashesMatch(unsigned char digest1[EVP_MAX_MD_SIZE+1],unsigned char digest2[EVP_MAX_MD_SIZE+1],enum cfhashes type); char *HashPrint(enum cfhashes type,unsigned char digest[EVP_MAX_MD_SIZE+1]); char *HashPrintSafe(enum cfhashes type,unsigned char digest[EVP_MAX_MD_SIZE+1], char buffer[EVP_MAX_MD_SIZE*4]); char *FileHashName(enum cfhashes id); void HashPubKey(RSA *key,unsigned char digest[EVP_MAX_MD_SIZE+1],enum cfhashes type); /* files_interfaces.c */ void SourceSearchAndCopy(char *from,char *to,int maxrecurse,struct Attributes attr,struct Promise *pp); void VerifyCopy(char *source,char *destination,struct Attributes attr,struct Promise *pp); void LinkCopy(char *sourcefile,char *destfile,struct stat *sb,struct Attributes attr, struct Promise *pp); int cfstat(const char *path, struct stat *buf); int cf_stat(char *file,struct stat *buf,struct Attributes attr, struct Promise *pp); int cf_lstat(char *file,struct stat *buf,struct Attributes attr, struct Promise *pp); struct cfdirent *cf_readdir(CFDIR *cfdirh,struct Attributes attr, struct Promise *pp); int CopyRegularFile(char *source,char *dest,struct stat sstat,struct stat dstat,struct Attributes attr, struct Promise *pp); int CfReadLine(char *buff,int size,FILE *fp); int cf_readlink(char *sourcefile,char *linkbuf,int buffsize,struct Attributes attr, struct Promise *pp); /* files_names.c */ int IsNewerFileTree(char *dir,time_t reftime); char *Titleize (char *str); int DeEscapeQuotedString(const char *in, char *out); int CompareCSVName(char *s1,char *s2); int IsDir(char *path); int EmptyString(char *s); char *JoinPath(char *path, const char *leaf); char *JoinSuffix(char *path,char *leaf); int JoinMargin(char *path, const char *leaf, char **nextFree, int bufsize, int margin); int StartJoin(char *path,char *leaf,int bufsize); int Join(char *path, const char *leaf, int bufsize); int JoinSilent(char *path, const char *leaf, int bufsize); int EndJoin(char *path,char *leaf,int bufsize); int IsAbsPath(char *path); void AddSlash(char *str); void DeleteSlash(char *str); const char *LastFileSeparator(const char *str); int ChopLastNode(char *str); char *CanonifyName(const char *str); void CanonifyNameInPlace(char *str); char *CanonifyChar(const char *str,char ch); const char *ReadLastNode(const char *str); int CompressPath(char *dest,char *src); void Chop(char *str); void StripTrailingNewline(char *str); bool IsStrIn(const char *str, const char **strs); bool IsStrCaseIn(const char *str, const char **strs); void FreeStringArray(char **strs); int IsAbsoluteFileName(const char *f); bool IsFileOutsideDefaultRepository(const char *f); int RootDirLength(char *f); char ToLower (char ch); char ToUpper (char ch); char *ToUpperStr (char *str); char *ToLowerStr (char *str); int SubStrnCopyChr(char *to,char *from,int len,char sep); int CountChar(char *string,char sp); void ReplaceChar(char *in, char *out, int outSz, char from, char to); void ReplaceTrailingChar(char *str, char from, char to); void ReplaceTrailingStr(char *str, char *from, char to); int ReplaceStr(char *in, char *out, int outSz, char* from, char *to); #if defined HAVE_PTHREAD_H && (defined HAVE_LIBPTHREAD || defined BUILDTIN_GCC_THREAD) void *ThreadUniqueName(pthread_t tid); #endif /* HAVE PTHREAD */ /* files_operators.c */ int VerifyFileLeaf(char *path,struct stat *sb,struct Attributes attr,struct Promise *pp); int CfCreateFile(char *file,struct Promise *pp,struct Attributes attr); FILE *CreateEmptyStream(void); int ScheduleCopyOperation(char *destination,struct Attributes attr,struct Promise *pp); int ScheduleLinkChildrenOperation(char *destination,char *source,int rec,struct Attributes attr,struct Promise *pp); int ScheduleLinkOperation(char *destination,char *source,struct Attributes attr,struct Promise *pp); int ScheduleEditOperation(char *filename,struct Attributes attr,struct Promise *pp); struct FileCopy *NewFileCopy(struct Promise *pp); void VerifyFileAttributes(char *file,struct stat *dstat,struct Attributes attr,struct Promise *pp); void VerifyFileIntegrity(char *file,struct Attributes attr,struct Promise *pp); int VerifyOwner(char *file,struct Promise *pp,struct Attributes attr,struct stat *statbuf); void VerifyCopiedFileAttributes(char *file,struct stat *dstat,struct stat *sstat,struct Attributes attr,struct Promise *pp); int MoveObstruction(char *from,struct Attributes attr,struct Promise *pp); void TouchFile(char *path,struct stat *sb,struct Attributes attr,struct Promise *pp); int MakeParentDirectory(char *parentandchild,int force); void RotateFiles(char *name,int number); void CreateEmptyFile(char *name); void VerifyFileChanges(char *file,struct stat *sb,struct Attributes attr,struct Promise *pp); #ifndef MINGW struct UidList *MakeUidList(char *uidnames); struct GidList *MakeGidList(char *gidnames); void AddSimpleUidItem(struct UidList **uidlist,uid_t uid,char *uidname); void AddSimpleGidItem(struct GidList **gidlist,gid_t gid,char *gidname); #endif /* NOT MINGW */ void LogHashChange(char *file); /* files_properties.c */ int ConsiderFile(const char *nodename,char *path,struct Attributes attr,struct Promise *pp); void SetSearchDevice(struct stat *sb,struct Promise *pp); int DeviceBoundary(struct stat *sb,struct Promise *pp); /* files_repository.c */ int ArchiveToRepository(char *file,struct Attributes attr,struct Promise *pp); /* files_select.c */ int SelectLeaf(char *path,struct stat *sb,struct Attributes attr,struct Promise *pp); int GetOwnerName(char *path, struct stat *lstatptr, char *owner, int ownerSz); /* fncall.c */ int IsBuiltinFnCall(void *rval,char rtype); struct FnCall *NewFnCall(char *name, struct Rlist *args); struct FnCall *CopyFnCall(struct FnCall *f); int PrintFnCall(char *buffer, int bufsize,struct FnCall *fp); void DeleteFnCall(struct FnCall *fp); void ShowFnCall(FILE *fout,struct FnCall *fp); struct Rval EvaluateFunctionCall(struct FnCall *fp,struct Promise *pp); enum cfdatatype FunctionReturnType(const char *name); FnCallType *FindFunction(const char *name); void SetFnCallReturnStatus(char *fname,int status,char *message,char *fncall_classes); /* generic_agent.c */ void GenericInitialize(int argc,char **argv,char *agents); void GenericDeInitialize(void); void InitializeGA(int argc,char **argv); void CheckOpts(int argc,char **argv); void Syntax(const char *comp, const struct option options[], const char *hints[], const char *id); void ManPage(const char *component, const struct option options[], const char *hints[], const char *id); void PrintVersionBanner(const char *component); int CheckPromises(enum cfagenttype ag); void ReadPromises(enum cfagenttype ag,char *agents); int NewPromiseProposals(void); void CompilationReport(char *filename); void HashVariables(char *name); void HashControls(void); void Cf3CloseLog(void); struct Constraint *ControlBodyConstraints(enum cfagenttype agent); void SetFacility(const char *retval); struct Bundle *GetBundle(char *name,char *agent); struct SubType *GetSubTypeForBundle(char *type,struct Bundle *bp); void CheckBundleParameters(char *scope,struct Rlist *args); void PromiseBanner(struct Promise *pp); void BannerBundle(struct Bundle *bp,struct Rlist *args); void BannerSubBundle(struct Bundle *bp,struct Rlist *args); void WritePID(char *filename); void OpenCompilationReportFiles(const char *fname); /* granules.c */ char *ConvTimeKey (char *str); char *GenTimeKey (time_t now); int GetTimeSlot(time_t here_and_now); int GetShiftSlot(time_t here_and_now); time_t GetShiftSlotStart(time_t t); /* hashes.c */ int RefHash(char *name); int ElfHash(char *key); int OatHash(const char *key); void InitHashes(struct CfAssoc **table); void CopyHashes(struct CfAssoc **newhash,struct CfAssoc **oldhash); int GetHash(const char *name); void PrintHashes(FILE *sp,struct CfAssoc **table,int html); void DeleteHashes(struct CfAssoc **hashtable); /* Deletes element from hashtable, returning whether element was found */ bool HashDeleteElement(CfAssoc **hashtable, const char *element); /* Looks up element in hashtable, returns NULL if not found */ CfAssoc *HashLookupElement(CfAssoc **hashtable, const char *element); /* Clear whole hash table */ void HashClear(CfAssoc **hashtable); /* Insert element if it does not exist in hash table. Returns false if element already exists in table or if table is full. */ bool HashInsertElement(CfAssoc **hashtable, const char *element, void *rval, char rtype, enum cfdatatype dtype); /* Hash table iterators: call HashIteratorNext() until it returns NULL */ HashIterator HashIteratorInit(CfAssoc **hashtable); CfAssoc *HashIteratorNext(HashIterator *iterator); /* html.c */ void CfHtmlHeader(FILE *fp,char *title,char *css,char *webdriver,char *banner); void CfHtmlFooter(FILE *fp,char *footer); void CfHtmlTitle(FILE *fp,char *title); int IsHtmlHeader(char *s); /* item-lib.c */ void PrependFullItem(struct Item **liststart,char *itemstring,char *classes,int counter,time_t t); void PurgeItemList(struct Item **list,char *name); struct Item *ReturnItemIn(struct Item *list,char *item); struct Item *ReturnItemInClass(struct Item *list,char *item,char *classes); struct Item *ReturnItemAtIndex(struct Item *list,int index); int GetItemIndex(struct Item *list,char *item); struct Item *EndOfList(struct Item *start); int IsItemInRegion(char *item,struct Item *begin,struct Item *end,struct Attributes a,struct Promise *pp); void PrependItemList(struct Item **liststart,char *itemstring); int SelectItemMatching(struct Item *s,char *regex,struct Item *begin,struct Item *end,struct Item **match,struct Item **prev,char *fl); int SelectNextItemMatching(char *regexp,struct Item *begin,struct Item *end,struct Item **match,struct Item **prev); int SelectLastItemMatching(char *regexp,struct Item *begin,struct Item *end,struct Item **match,struct Item **prev); void InsertAfter(struct Item **filestart,struct Item *ptr,char *string); int NeighbourItemMatches(struct Item *start,struct Item *location,char *string,enum cfeditorder pos,struct Attributes a,struct Promise *pp); int RawSaveItemList(struct Item *liststart, char *file); struct Item *SplitStringAsItemList(char *string,char sep); struct Item *SplitString(char *string,char sep); int DeleteItemGeneral (struct Item **filestart, char *string, enum matchtypes type); int DeleteItemLiteral (struct Item **filestart, char *string); int DeleteItemStarting (struct Item **list,char *string); int DeleteItemNotStarting (struct Item **list,char *string); int DeleteItemMatching (struct Item **list,char *string); int DeleteItemNotMatching (struct Item **list,char *string); int DeleteItemContaining (struct Item **list,char *string); int DeleteItemNotContaining (struct Item **list,char *string); int CompareToFile(struct Item *liststart,char *file,struct Attributes a,struct Promise *pp); struct Item *String2List(char *string); int ListLen (struct Item *list); int ByteSizeList(const struct Item *list); int IsItemIn (struct Item *list, const char *item); int IsMatchItemIn(struct Item *list,char *item); struct Item *ConcatLists (struct Item *list1, struct Item *list2); void CopyList(struct Item **dest,struct Item *source); int FuzzySetMatch(char *s1, char *s2); int FuzzyMatchParse(char *item); int FuzzyHostMatch(char *arg0, char *arg1,char *basename); int FuzzyHostParse(char *arg1,char *arg2); void IdempItemCount(struct Item **liststart,char *itemstring,char *classes); struct Item *IdempPrependItem(struct Item **liststart,char *itemstring,char *classes); struct Item *IdempPrependItemClass(struct Item **liststart,char *itemstring,char *classes); struct Item *PrependItem(struct Item **liststart, const char *itemstring, const char *classes); void AppendItem(struct Item **liststart, const char *itemstring, char *classes); void DeleteItemList (struct Item *item); void DeleteItem (struct Item **liststart, struct Item *item); void DebugListItemList (struct Item *liststart); struct Item *SplitStringAsItemList (char *string, char sep); void IncrementItemListCounter (struct Item *ptr, char *string); void SetItemListCounter (struct Item *ptr, char *string,int value); struct Item *SortItemListNames(struct Item *list); struct Item *SortItemListClasses(struct Item *list); struct Item *SortItemListCounters(struct Item *list); struct Item *SortItemListTimes(struct Item *list); char *ItemList2CSV(struct Item *list); int ItemListSize(struct Item *list); int MatchRegion(char *chunk,struct Item *location,struct Item *begin,struct Item *end); struct Item *DeleteRegion(struct Item **liststart,struct Item *begin,struct Item *end); /* iteration.c */ struct Rlist *NewIterationContext(char *scopeid,struct Rlist *listvars); void DeleteIterationContext(struct Rlist *lol); int IncrementIterationContext(struct Rlist *iterators,int count); int EndOfIteration(struct Rlist *iterator); int NullIterators(struct Rlist *iterator); /* instrumentation.c */ struct timespec BeginMeasure(void); void EndMeasure(char *eventname,struct timespec start); void EndMeasurePromise(struct timespec start,struct Promise *pp); void NoteClassUsage(struct AlphaList list); void LastSaw(char *username,char *ipaddress,unsigned char digest[EVP_MAX_MD_SIZE+1],enum roles role); double GAverage(double anew,double aold,double p); bool RemoveHostFromLastSeen(const char *hostname, char *hostkey); /* install.c */ int RelevantBundle(char *agent,char *blocktype); struct Bundle *AppendBundle(struct Bundle **start,char *name, char *type, struct Rlist *args); struct Body *AppendBody(struct Body **start,char *name, char *type, struct Rlist *args); struct SubType *AppendSubType(struct Bundle *bundle,char *typename); struct Promise *AppendPromise(struct SubType *type,char *promiser, void *promisee,char petype,char *classes,char *bundle,char *bundletype); void DeleteBundles(struct Bundle *bp); void DeleteBodies(struct Body *bp); /* interfaces.c */ void VerifyInterfacePromise(char *vifdev,char *vaddress,char *vnetmask,char *vbroadcast); /* keyring.c */ int HostKeyAddressUnknown(char *value); /* logging.c */ void BeginAudit(void); void EndAudit(void); void ClassAuditLog(struct Promise *pp,struct Attributes attr,char *str,char status,char *error); void PromiseLog(char *s); void FatalError(char *s, ...) FUNC_ATTR_NORETURN; void AuditStatusMessage(FILE*fp,char status); /* manual.c */ void TexinfoManual(char *mandir); /* matching.c */ bool ValidateRegEx(const char *regex); int FullTextMatch (char *regptr, const char *cmpptr); char *ExtractFirstReference(char *regexp, const char *teststring); int BlockTextMatch (char *regexp,char *teststring,int *s,int *e); int IsRegexItemIn(struct Item *list,char *regex); int IsPathRegex(char *str); int IsRegex(char *str); int MatchRlistItem(struct Rlist *listofregex,const char *teststring); void EscapeSpecialChars(char *str, char *strEsc, int strEscSz, char *noEsc); char *EscapeChar(char *str, int strSz, char esc); void AnchorRegex(char *regex, char *out, int outSz); int MatchPolicy(char *needle,char *haystack,struct Attributes a,struct Promise *pp); /* mod_defaults.c */ char *GetControlDefault(char *bodypart); char *GetBodyDefault(char *bodypart); /* modes.c */ int ParseModeString (char *modestring, mode_t *plusmask, mode_t *minusmask); /* net.c */ int SendTransaction (int sd, char *buffer,int len, char status); int ReceiveTransaction (int sd, char *buffer,int *more); int RecvSocketStream (int sd, char *buffer, int toget, int nothing); int SendSocketStream (int sd, char *buffer, int toget, int flags); /* nfs.c */ #ifndef MINGW int LoadMountInfo(struct Rlist **list); void DeleteMountInfo(struct Rlist *list); int VerifyNotInFstab(char *name,struct Attributes a,struct Promise *pp); int VerifyInFstab(char *name,struct Attributes a,struct Promise *pp); int VerifyMount(char *name,struct Attributes a,struct Promise *pp); int VerifyUnmount(char *name,struct Attributes a,struct Promise *pp); void MountAll(void); #endif /* NOT MINGW */ /* ontology.c */ void AddInference(struct Inference **list,char *result,char *pre,char *qual); struct Topic *IdempInsertTopic(char *classified_name); struct Topic *InsertTopic(char *name,char *context); struct Topic *FindTopic(char *name); int GetTopicPid(char *typed_topic); struct Topic *AddTopic(struct Topic **list,char *name,char *type); void AddTopicAssociation(struct Topic *tp,struct TopicAssociation **list,char *fwd_name,char *bwd_name,struct Rlist *li,int ok,char *from_context,char *from_topic); void AddOccurrence(struct Occurrence **list,char *reference,struct Rlist *represents,enum representations rtype,char *context); struct Topic *TopicExists(char *topic_name,char *topic_type); struct Topic *GetCanonizedTopic(struct Topic *list,char *topic_name); struct Topic *GetTopic(struct Topic *list,char *topic_name); struct TopicAssociation *AssociationExists(struct TopicAssociation *list,char *fwd,char *bwd); struct Occurrence *OccurrenceExists(struct Occurrence *list,char *locator,enum representations repy_type,char *s); void DeClassifyTopic(char *typdetopic,char *topic,char *type); /* patches.c */ int IsPrivileged (void); char *StrStr (char *s1,char *s2); int StrnCmp (char *s1,char *s2,size_t n); int cf_strcmp(const char *s1, const char *s2); int cf_strncmp(const char *s1,const char *s2, size_t n); char *cf_strcpy(char *s1, const char *s2); char *cf_strncpy(char *s1, const char *s2, size_t n); char *cf_strdup(const char *s); int cf_strlen(const char *s); char *cf_strchr(const char *s, int c); char *MapName(char *s); char *MapNameForward(char *s); char *cf_ctime(const time_t *timep); char *cf_strtimestamp_local(const time_t time, char *buf); char *cf_strtimestamp_utc(const time_t time, char *buf); int cf_closesocket(int sd); int cf_mkdir(const char *path, mode_t mode); int cf_chmod(const char *path, mode_t mode); int cf_rename(const char *oldpath, const char *newpath); void OpenNetwork(void); void CloseNetwork(void); void CloseWmi(void); int LinkOrCopy(const char *from, const char *to, int sym); /* pipes.c */ FILE *cf_popen(char *command,char *type); FILE *cf_popensetuid(char *command,char *type,uid_t uid,gid_t gid,char *chdirv,char *chrootv,int background); FILE *cf_popen_sh(char *command,char *type); FILE *cf_popen_shsetuid(char *command,char *type,uid_t uid,gid_t gid,char *chdirv,char *chrootv,int background); int cf_pclose(FILE *pp); int cf_pclose_def(FILE *pfp,struct Attributes a,struct Promise *pp); int VerifyCommandRetcode(int retcode, int fallback, struct Attributes a, struct Promise *pp); #ifndef MINGW int cf_pwait(pid_t pid); #endif /* NOT MINGW */ /* processes_select.c */ int SelectProcess(char *procentry,char **names,int *start,int *end,struct Attributes a,struct Promise *pp); bool IsProcessNameRunning(char *procNameRegex); /* promises.c */ char *BodyName(struct Promise *pp); struct Body *IsBody(struct Body *list,char *key); struct Bundle *IsBundle(struct Bundle *list,char *key); struct Promise *DeRefCopyPromise(char *scopeid,struct Promise *pp); struct Promise *ExpandDeRefPromise(char *scopeid,struct Promise *pp); struct Promise *CopyPromise(char *scopeid,struct Promise *pp); void DeletePromise(struct Promise *pp); void DeletePromises(struct Promise *pp); void PromiseRef(enum cfreport level,struct Promise *pp); struct Promise *NewPromise(char *typename,char *promiser); void HashPromise(char *salt,struct Promise *pp,unsigned char digest[EVP_MAX_MD_SIZE+1],enum cfhashes type); /* recursion.c */ int DepthSearch(char *name,struct stat *sb,int rlevel,struct Attributes attr,struct Promise *pp); int SkipDirLinks(char *path,const char *lastnode,struct Recursion r); /* reporting.c */ void ShowContext(void); void ShowPromises(struct Bundle *bundles,struct Body *bodies); void ShowPromise(struct Promise *pp, int indent); void ShowScopedVariables(void); void SyntaxTree(void); void ShowBody(struct Body *body,int ident); void DebugBanner(char *s); void ReportError(char *s); void BannerSubType(char *bundlename,char *type,int p); void BannerSubSubType(char *bundlename,char *type); void Banner(char *s); void ShowPromisesInReport(struct Bundle *bundles, struct Body *bodies); void ShowPromiseInReport(const char *version, struct Promise* pp, int indent); /* rlist.c */ int PrintRval(char *buffer,int bufsize,void *item,char type); int PrintRlist(char *buffer,int bufsize,struct Rlist *list); int GetStringListElement(char *strList, int index, char *outBuf, int outBufSz); int StripListSep(char *strList, char *outBuf, int outBufSz); struct Rlist *ParseShownRlist(char *string); int IsStringIn(struct Rlist *list,char *s); int IsIntIn(struct Rlist *list,int i); struct Rlist *KeyInRlist(struct Rlist *list,char *key); int RlistLen(struct Rlist *start); void PopStack(struct Rlist **liststart, void **item,size_t size); void PushStack(struct Rlist **liststart,void *item); int IsInListOfRegex(struct Rlist *list,char *str); void *CopyRvalItem(void *item, char type); void DeleteRvalItem(void *rval, char type); struct Rlist *CopyRlist(struct Rlist *list); int CompareRval(void *rval1, char rtype1, void *rval2, char rtype2); void DeleteRlist(struct Rlist *list); void DeleteRlistEntry(struct Rlist **liststart,struct Rlist *entry); struct Rlist *AppendRlistAlien(struct Rlist **start,void *item); struct Rlist *PrependRlistAlien(struct Rlist **start,void *item); struct Rlist *OrthogAppendRlist(struct Rlist **start,void *item, char type); struct Rlist *IdempAppendRScalar(struct Rlist **start,void *item, char type); struct Rlist *AppendRScalar(struct Rlist **start,void *item, char type); struct Rlist *IdempAppendRlist(struct Rlist **start,void *item, char type); struct Rlist *IdempPrependRScalar(struct Rlist **start,void *item, char type); struct Rlist *PrependRScalar(struct Rlist **start,void *item, char type); struct Rlist *PrependRlist(struct Rlist **start,void *item, char type); struct Rlist *AppendRlist(struct Rlist **start,void *item, char type); struct Rlist *PrependRlist(struct Rlist **start,void *item, char type); struct Rlist *SplitStringAsRList(char *string,char sep); struct Rlist *SplitRegexAsRList(char *string,char *regex,int max,int purge); struct Rlist *SortRlist(struct Rlist *list, int (*CompareItems)()); struct Rlist *AlphaSortRListNames(struct Rlist *list); void ShowRlist(FILE *fp,struct Rlist *list); void ShowRval(FILE *fp,void *rval,char type); int PrependListPackageItem(struct CfPackageItem **list,char *item,struct Attributes a,struct Promise *pp); int PrependPackageItem(struct CfPackageItem **list,char *name,char *version,char* arch,struct Attributes a,struct Promise *pp); /* scope.c */ void SetScope(char *id); void SetNewScope(char *id); void NewScope(char *name); void DeleteScope(char *name); struct Scope *GetScope(char *scope); void CopyScope(char *new, char *old); void DeleteAllScope(void); void AugmentScope(char *scope,struct Rlist *lvals,struct Rlist *rvals); void DeleteFromScope(char *scope,struct Rlist *args); void PushThisScope(void); void PopThisScope(void); void ShowScope(char *name); /* selfdiagnostic.c */ void SelfDiagnostic(void); void TestVariableScan(void); void TestExpandPromise(void); void TestExpandVariables(void); /* server_transform.c */ void KeepPromiseBundles(void); void KeepControlPromises(void); struct Auth *GetAuthPath(char *path,struct Auth *list); void Summarize(void); /* signals.c */ void HandleSignals(int signum); void SelfTerminatePrelude(void); /* sockaddr.c */ /* Not thread-safe */ char *sockaddr_ntop (struct sockaddr *sa); /* Thread-safe. Returns boolean success. It's up to caller to provide large enough addr. */ bool sockaddr_pton (int af,void *src, void *addr); /* storage_tools.c */ off_t GetDiskUsage(char *file, enum cfsizes type); /* syntax.c */ int LvalWantsBody(char *stype,char *lval); int CheckParseVariableName(char *name); void CheckBundle(char *name,char *type); void CheckBody(char *name,char *type); struct SubTypeSyntax CheckSubType(char *btype,char *type); void CheckConstraint(char *type,char *name,char *lval,void *rval,char rvaltype,struct SubTypeSyntax ss); void CheckSelection(char *type,char *name,char *lval,void *rval,char rvaltype); void CheckConstraintTypeMatch(char *lval,void *rval,char rvaltype,enum cfdatatype dt,char *range,int level); int CheckParseClass(char *lv,char *s,char *range); enum cfdatatype StringDataType(char *scopeid,char *string); enum cfdatatype ExpectedDataType(char *lvalname); /* sysinfo.c */ void GetNameInfo3(void); void CfGetInterfaceInfo(enum cfagenttype ag); void Get3Environment(void); void BuiltinClasses(void); void OSClasses(void); void SetSignals(void); int IsInterfaceAddress(char *adr); int GetCurrentUserName(char *userName, int userNameLen); #ifndef MINGW void Unix_GetInterfaceInfo(enum cfagenttype ag); void Unix_FindV6InterfaceInfo(void); char *GetHome(uid_t uid); #endif /* NOT MINGW */ /* transaction.c */ void SummarizeTransaction(struct Attributes attr,struct Promise *pp,char *logname); struct CfLock AcquireLock(char *operand,char *host,time_t now,struct Attributes attr,struct Promise *pp, int ignoreProcesses); void YieldCurrentLock(struct CfLock this); void GetLockName(char *lockname,char *locktype,char *base,struct Rlist *params); int ThreadLock(enum cf_thread_mutex name); int ThreadUnlock(enum cf_thread_mutex name); void AssertThreadLocked(enum cf_thread_mutex name, char *fname); void PurgeLocks(void); int ShiftChange(void); /* timeout.c */ void SetTimeOut(int timeout); void TimeOut(void); void SetReferenceTime(int setclasses); void SetStartTime(int setclasses); /* unix.c */ #ifndef MINGW int Unix_GracefulTerminate(pid_t pid); int Unix_GetCurrentUserName(char *userName, int userNameLen); int Unix_ShellCommandReturnsZero(char *comm,int useshell); int Unix_DoAllSignals(struct Item *siglist,struct Attributes a,struct Promise *pp); int Unix_LoadProcessTable(struct Item **procdata); void Unix_CreateEmptyFile(char *name); int Unix_IsExecutable(const char *file); char *Unix_GetErrorStr(void); #endif /* NOT MINGW */ /* vars.c */ void LoadSystemConstants(void); void ForceScalar(char *lval,char *rval); void NewScalar(char *scope,char *lval,char *rval,enum cfdatatype dt); void DeleteScalar(char *scope,char *lval); void NewList(char *scope,char *lval,void *rval,enum cfdatatype dt); enum cfdatatype GetVariable(const char *scope, const char *lval,void **returnv,char *rtype); void DeleteVariable(char *scope,char *id); int CompareVariable(const char *lval, struct CfAssoc *ap); int CompareVariableValue(void *rval,char rtype,struct CfAssoc *ap); int StringContainsVar(char *s,char *v); int DefinedVariable(char *name); int IsCf3VarString(char *str); int BooleanControl(char *scope,char *name); const char *ExtractInnerCf3VarString(const char *str,char *substr); const char *ExtractOuterCf3VarString(const char *str, char *substr); int UnresolvedVariables(struct CfAssoc *ap,char rtype); int UnresolvedArgs(struct Rlist *args); int IsQualifiedVariable(char *var); int IsCfList(char *type); int AddVariableHash(char *scope,char *lval,void *rval,char rtype,enum cfdatatype dtype,char *fname,int no); void DeRefListsInHashtable(char *scope,struct Rlist *list,struct Rlist *reflist); /* verify_databases.c */ void VerifyDatabasePromises(struct Promise *pp); /* verify_environments.c */ void VerifyEnvironmentsPromise(struct Promise *pp); /* verify_exec.c */ void VerifyExecPromise(struct Promise *pp); /* verify_files.c */ void VerifyFilePromise(char *path,struct Promise *pp); void LocateFilePromiserGroup(char *wildpath,struct Promise *pp,void (*fnptr)(char *path, struct Promise *ptr)); void *FindAndVerifyFilesPromises(struct Promise *pp); int FileSanityChecks(char *path,struct Attributes a,struct Promise *pp); /* verify_interfaces.c */ void VerifyInterface(struct Attributes a,struct Promise *pp); void VerifyInterfacesPromise(struct Promise *pp); /* verify_measurements.c */ void VerifyMeasurementPromise(double *this,struct Promise *pp); /* verify_methods.c */ void VerifyMethodsPromise(struct Promise *pp); int VerifyMethod(struct Attributes a,struct Promise *pp); /* verify_packages.c */ void VerifyPackagesPromise(struct Promise *pp); void ExecuteScheduledPackages(void); void CleanScheduledPackages(void); /* verify_processes.c */ void VerifyProcessesPromise(struct Promise *pp); void VerifyProcesses(struct Attributes a, struct Promise *pp); int LoadProcessTable(struct Item **procdata); int DoAllSignals(struct Item *siglist,struct Attributes a,struct Promise *pp); int GracefulTerminate(pid_t pid); void GetProcessColumnNames(char *proc,char **names,int *start,int *end); /* verify_services.c */ void VerifyServicesPromise(struct Promise *pp); /* verify_storage.c */ void *FindAndVerifyStoragePromises(struct Promise *pp); void VerifyStoragePromise(char *path,struct Promise *pp); /* verify_reports.c */ void VerifyReportPromise(struct Promise *pp); #endif ���������������������������������������������������������cfengine-3.2.4/src/attributes.c���������������������������������������������������������������������0000644�0001750�0001750�00000145476�11715232734�013366� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: files_transform.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void ShowAttributes(struct Attributes a); /*******************************************************************/ struct Attributes GetFilesAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; memset(&attr,0,sizeof(attr)); // default for file copy attr.havedepthsearch = GetBooleanConstraint("depth_search",pp); attr.haveselect = GetBooleanConstraint("file_select",pp); attr.haverename = GetBooleanConstraint("rename",pp); attr.havedelete = GetBooleanConstraint("delete",pp); attr.haveperms = GetBooleanConstraint("perms",pp); attr.havechange = GetBooleanConstraint("changes",pp); attr.havecopy = GetBooleanConstraint("copy_from",pp); attr.havelink = GetBooleanConstraint("link_from",pp); attr.haveeditline = GetBundleConstraint("edit_line",pp); attr.haveeditxml = GetBundleConstraint("edit_xml",pp); attr.haveedit = attr.haveeditline || attr.haveeditxml; /* Files, specialist */ attr.repository = (char *)GetConstraint("repository",pp,CF_SCALAR); attr.create = GetBooleanConstraint("create",pp); attr.touch = GetBooleanConstraint("touch",pp); attr.transformer = (char *)GetConstraint("transformer",pp,CF_SCALAR); attr.move_obstructions = GetBooleanConstraint("move_obstructions",pp); attr.pathtype = (char *)GetConstraint("pathtype",pp,CF_SCALAR); attr.acl = GetAclConstraints(pp); attr.perms = GetPermissionConstraints(pp); attr.select = GetSelectConstraints(pp); attr.delete = GetDeleteConstraints(pp); attr.rename = GetRenameConstraints(pp); attr.change = GetChangeMgtConstraints(pp); attr.copy = GetCopyConstraints(pp); attr.link = GetLinkConstraints(pp); attr.edits = GetEditDefaults(pp); /* Files, multiple use */ attr.recursion = GetRecursionConstraints(pp); /* Common ("included") */ attr.havetrans = GetBooleanConstraint(CF_TRANSACTION,pp); attr.transaction = GetTransactionConstraints(pp); attr.haveclasses = GetBooleanConstraint(CF_DEFINECLASSES,pp); attr.classes = GetClassDefinitionConstraints(pp); if (DEBUG) { ShowAttributes(attr); } if (attr.haverename || attr.havedelete || attr.haveperms || attr.havechange || attr.havecopy || attr.havelink || attr.haveedit || attr.create || attr.touch || attr.transformer || attr.acl.acl_entries) { } else { if (THIS_AGENT_TYPE == cf_common) { cfPS(cf_error,CF_WARN,"",pp,attr," !! files promise makes no intention about system state"); } } if ((THIS_AGENT_TYPE == cf_common) && attr.create && attr.havecopy) { if (attr.copy.compare != cfa_checksum && attr.copy.compare != cfa_hash) { CfOut(cf_error,""," !! Promise constraint conflicts - %s file will never be copied as created file is always newer",pp->promiser); PromiseRef(cf_error,pp); } else { CfOut(cf_verbose,""," !! Promise constraint conflicts - %s file cannot strictly both be created empty and copied from a source file.",pp->promiser); } } if ((THIS_AGENT_TYPE == cf_common) && attr.create && attr.havelink) { CfOut(cf_error,""," !! Promise constraint conflicts - %s cannot be created and linked at the same time",pp->promiser); PromiseRef(cf_error,pp); } return attr; } /*******************************************************************/ struct Attributes GetOutputsAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.transaction = GetTransactionConstraints(pp); attr.classes = GetClassDefinitionConstraints(pp); attr.output.promiser_type = GetConstraint("promiser_type",pp,CF_SCALAR); attr.output.level = GetConstraint("output_level",pp,CF_SCALAR); return attr; } /*******************************************************************/ struct Attributes GetReportsAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.transaction = GetTransactionConstraints(pp); attr.classes = GetClassDefinitionConstraints(pp); attr.report = GetReportConstraints(pp); return attr; } /*******************************************************************/ struct Attributes GetEnvironmentsAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.transaction = GetTransactionConstraints(pp); attr.classes = GetClassDefinitionConstraints(pp); attr.env = GetEnvironmentsConstraints(pp); return attr; } /*******************************************************************/ struct Attributes GetServicesAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.transaction = GetTransactionConstraints(pp); attr.classes = GetClassDefinitionConstraints(pp); attr.service = GetServicesConstraints(pp); return attr; } /*******************************************************************/ struct Attributes GetPackageAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.transaction = GetTransactionConstraints(pp); attr.classes = GetClassDefinitionConstraints(pp); attr.packages = GetPackageConstraints(pp); return attr; } /*******************************************************************/ struct Attributes GetDatabaseAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.transaction = GetTransactionConstraints(pp); attr.classes = GetClassDefinitionConstraints(pp); attr.database = GetDatabaseConstraints(pp); return attr; } /*******************************************************************/ struct Attributes GetClassContextAttributes(struct Promise *pp) { struct Attributes a; a.transaction = GetTransactionConstraints(pp); a.classes = GetClassDefinitionConstraints(pp); a.context = GetContextConstraints(pp); return a; } /*******************************************************************/ struct Attributes GetExecAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.contain = GetExecContainConstraints(pp); attr.havecontain = GetBooleanConstraint("contain",pp); attr.args = GetConstraint("args",pp,CF_SCALAR); attr.module = GetBooleanConstraint("module",pp); /* Common ("included") */ attr.havetrans = GetBooleanConstraint(CF_TRANSACTION,pp); attr.transaction = GetTransactionConstraints(pp); attr.haveclasses = GetBooleanConstraint(CF_DEFINECLASSES,pp); attr.classes = GetClassDefinitionConstraints(pp); return attr; } /*******************************************************************/ struct Attributes GetProcessAttributes(struct Promise *pp) { static struct Attributes attr = {{0}}; attr.signals = GetListConstraint("signals",pp); attr.process_stop = (char *)GetConstraint("process_stop",pp,CF_SCALAR); attr.haveprocess_count = GetBooleanConstraint("process_count",pp); attr.haveselect = GetBooleanConstraint("process_select",pp); attr.restart_class = (char *)GetConstraint("restart_class",pp,CF_SCALAR); attr.process_count = GetMatchesConstraints(pp); attr.process_select = GetProcessFilterConstraints(pp); /* Common ("included") */ attr.havetrans = GetBooleanConstraint(CF_TRANSACTION,pp); attr.transaction = GetTransactionConstraints(pp); attr.haveclasses = GetBooleanConstraint(CF_DEFINECLASSES,pp); attr.classes = GetClassDefinitionConstraints(pp); return attr; } /*******************************************************************/ struct Attributes GetStorageAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.mount = GetMountConstraints(pp); attr.volume = GetVolumeConstraints(pp); attr.havevolume = GetBooleanConstraint("volume",pp); attr.havemount = GetBooleanConstraint("mount",pp); /* Common ("included") */ if (attr.edits.maxfilesize <= 0) { attr.edits.maxfilesize = EDITFILESIZE; } attr.havetrans = GetBooleanConstraint(CF_TRANSACTION,pp); attr.transaction = GetTransactionConstraints(pp); attr.haveclasses = GetBooleanConstraint(CF_DEFINECLASSES,pp); attr.classes = GetClassDefinitionConstraints(pp); return attr; } /*******************************************************************/ struct Attributes GetMethodAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.havebundle = GetBundleConstraint("usebundle",pp); /* Common ("included") */ attr.havetrans = GetBooleanConstraint(CF_TRANSACTION,pp); attr.transaction = GetTransactionConstraints(pp); attr.haveclasses = GetBooleanConstraint(CF_DEFINECLASSES,pp); attr.classes = GetClassDefinitionConstraints(pp); return attr; } /*******************************************************************/ struct Attributes GetInterfacesAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.havetcpip = GetBundleConstraint("usebundle",pp); attr.tcpip = GetTCPIPAttributes(pp); /* Common ("included") */ attr.havetrans = GetBooleanConstraint(CF_TRANSACTION,pp); attr.transaction = GetTransactionConstraints(pp); attr.haveclasses = GetBooleanConstraint(CF_DEFINECLASSES,pp); attr.classes = GetClassDefinitionConstraints(pp); return attr; } /*******************************************************************/ struct Attributes GetTopicsAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.fwd_name = GetConstraint("forward_relationship",pp,CF_SCALAR); attr.bwd_name = GetConstraint("backward_relationship",pp,CF_SCALAR); attr.associates = GetListConstraint("associates",pp); attr.synonyms = GetListConstraint("synonyms",pp); attr.general = GetListConstraint("generalizations",pp); return attr; } /*******************************************************************/ struct Attributes GetThingsAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; struct Rlist *rp; char *cert = GetConstraint("certainty",pp,CF_SCALAR); enum knowledgecertainty certainty; attr.synonyms = GetListConstraint("synonyms",pp); attr.general = GetListConstraint("generalizations",pp); if (cert && strcmp(cert,"possible") == 0) { certainty = cfk_possible; } else if (cert && strcmp(cert,"uncertain") == 0) { certainty = cfk_uncertain; } else { certainty = cfk_certain; } // Select predefined physics if (rp = GetListConstraint("is_part_of",pp)) { switch (certainty) { case cfk_certain: attr.fwd_name = KM_PARTOF_CERT_F; attr.bwd_name = KM_PARTOF_CERT_B; break; case cfk_uncertain: attr.fwd_name = KM_PARTOF_UNCERT_F; attr.bwd_name = KM_PARTOF_UNCERT_B; break; case cfk_possible: attr.fwd_name = KM_PARTOF_POSS_F; attr.bwd_name = KM_PARTOF_POSS_B; break; } attr.associates = rp; } else if (rp = GetListConstraint("determines",pp)) { switch (certainty) { case cfk_certain: attr.fwd_name = KM_DETERMINES_CERT_F; attr.bwd_name = KM_DETERMINES_CERT_B; break; case cfk_uncertain: attr.fwd_name = KM_DETERMINES_UNCERT_F; attr.bwd_name = KM_DETERMINES_UNCERT_B; break; case cfk_possible: attr.fwd_name = KM_DETERMINES_POSS_F; attr.bwd_name = KM_DETERMINES_POSS_B; break; } attr.associates = rp; } else if (rp = GetListConstraint("is_connected_to",pp)) { switch (certainty) { case cfk_certain: attr.fwd_name = KM_CONNECTS_CERT_F; attr.bwd_name = KM_CONNECTS_CERT_B; break; case cfk_uncertain: attr.fwd_name = KM_CONNECTS_UNCERT_F; attr.bwd_name = KM_CONNECTS_UNCERT_B; break; case cfk_possible: attr.fwd_name = KM_CONNECTS_POSS_F; attr.bwd_name = KM_CONNECTS_POSS_B; break; } attr.associates = rp; } else if (rp = GetListConstraint("uses",pp)) { switch (certainty) { case cfk_certain: attr.fwd_name = KM_USES_CERT_F; attr.bwd_name = KM_USES_CERT_B; break; case cfk_uncertain: attr.fwd_name = KM_USES_UNCERT_F; attr.bwd_name = KM_USES_UNCERT_B; break; case cfk_possible: attr.fwd_name = KM_USES_POSS_F; attr.bwd_name = KM_USES_POSS_B; break; } attr.associates = rp; } else if (rp = GetListConstraint("provides",pp)) { switch (certainty) { case cfk_certain: attr.fwd_name = KM_PROVIDES_CERT_F; attr.bwd_name = KM_PROVIDES_CERT_B; break; case cfk_uncertain: attr.fwd_name = KM_PROVIDES_UNCERT_F; attr.bwd_name = KM_PROVIDES_UNCERT_B; break; case cfk_possible: attr.fwd_name = KM_PROVIDES_POSS_F; attr.bwd_name = KM_PROVIDES_POSS_B; break; } attr.associates = rp; } else if (rp = GetListConstraint("belongs_to",pp)) { switch (certainty) { case cfk_certain: attr.fwd_name = KM_BELONGS_CERT_F; attr.bwd_name = KM_BELONGS_CERT_B; break; case cfk_uncertain: attr.fwd_name = KM_BELONGS_UNCERT_F; attr.bwd_name = KM_BELONGS_UNCERT_B; break; case cfk_possible: attr.fwd_name = KM_BELONGS_POSS_F; attr.bwd_name = KM_BELONGS_POSS_B; break; } attr.associates = rp; } else if (rp = GetListConstraint("affects",pp)) { switch (certainty) { case cfk_certain: attr.fwd_name = KM_AFFECTS_CERT_F; attr.bwd_name = KM_AFFECTS_CERT_B; break; case cfk_uncertain: attr.fwd_name = KM_AFFECTS_UNCERT_F; attr.bwd_name = KM_AFFECTS_UNCERT_B; break; case cfk_possible: attr.fwd_name = KM_AFFECTS_POSS_F; attr.bwd_name = KM_AFFECTS_POSS_B; break; } attr.associates = rp; } else if (rp = GetListConstraint("causes",pp)) { switch (certainty) { case cfk_certain: attr.fwd_name = KM_CAUSE_CERT_F; attr.bwd_name = KM_CAUSE_CERT_B; break; case cfk_uncertain: attr.fwd_name = KM_CAUSE_UNCERT_F; attr.bwd_name = KM_CAUSE_UNCERT_B; break; case cfk_possible: attr.fwd_name = KM_CAUSE_POSS_F; attr.bwd_name = KM_CAUSE_POSS_B; break; } attr.associates = rp; } else if (rp = GetListConstraint("caused_by",pp)) { switch (certainty) { case cfk_certain: attr.bwd_name = KM_CAUSE_CERT_F; attr.fwd_name = KM_CAUSE_CERT_B; break; case cfk_uncertain: attr.bwd_name = KM_CAUSE_UNCERT_F; attr.fwd_name = KM_CAUSE_UNCERT_B; break; case cfk_possible: attr.bwd_name = KM_CAUSE_POSS_F; attr.fwd_name = KM_CAUSE_POSS_B; break; } attr.associates = rp; } else if (rp = GetListConstraint("needs",pp)) { switch (certainty) { case cfk_certain: attr.fwd_name = KM_NEEDS_CERT_F; attr.bwd_name = KM_NEEDS_CERT_B; break; case cfk_uncertain: attr.fwd_name = KM_NEEDS_UNCERT_F; attr.bwd_name = KM_NEEDS_UNCERT_B; break; case cfk_possible: attr.fwd_name = KM_NEEDS_POSS_F; attr.bwd_name = KM_NEEDS_POSS_B; break; } attr.associates = rp; } return attr; } /*******************************************************************/ struct Attributes GetInferencesAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.precedents = GetListConstraint("precedents",pp); attr.qualifiers = GetListConstraint("qualifers",pp); return attr; } /*******************************************************************/ struct Attributes GetOccurrenceAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.represents = GetListConstraint("represents",pp); attr.rep_type = GetConstraint("representation",pp,CF_SCALAR); attr.web_root = GetConstraint("web_root",pp,CF_SCALAR); attr.path_root = GetConstraint("path_root",pp,CF_SCALAR); return attr; } /*******************************************************************/ struct Attributes GetMeasurementAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.measure = GetMeasurementConstraint(pp); /* Common ("included") */ attr.havetrans = GetBooleanConstraint(CF_TRANSACTION,pp); attr.transaction = GetTransactionConstraints(pp); attr.haveclasses = GetBooleanConstraint(CF_DEFINECLASSES,pp); attr.classes = GetClassDefinitionConstraints(pp); return attr; } /*******************************************************************/ /* Level */ /*******************************************************************/ struct CfServices GetServicesConstraints(struct Promise *pp) { struct CfServices s; s.service_type = GetConstraint("service_type",pp,CF_SCALAR); s.service_policy = Str2ServicePolicy(GetConstraint("service_policy",pp,CF_SCALAR)); s.service_autostart_policy = GetConstraint("service_autostart_policy",pp,CF_SCALAR); s.service_args = GetConstraint("service_args",pp,CF_SCALAR); s.service_depend = GetListConstraint("service_dependencies",pp); s.service_depend_chain = GetConstraint("service_dependence_chain",pp,CF_SCALAR); return s; } /*******************************************************************/ struct CfEnvironments GetEnvironmentsConstraints(struct Promise *pp) { struct CfEnvironments e; e.cpus = GetIntConstraint("env_cpus",pp); e.memory = GetIntConstraint("env_memory",pp); e.disk = GetIntConstraint("env_disk",pp); e.baseline = GetConstraint("env_baseline",pp,CF_SCALAR); e.specfile = GetConstraint("env_spec_file",pp,CF_SCALAR); e.host = GetConstraint("environment_host",pp,CF_SCALAR); e.addresses = GetListConstraint("env_addresses",pp); e.name = GetConstraint("env_name",pp,CF_SCALAR); e.type = GetConstraint("environment_type",pp,CF_SCALAR); e.state = Str2EnvState(GetConstraint("environment_state",pp,CF_SCALAR)); return e; } /*******************************************************************/ struct ExecContain GetExecContainConstraints(struct Promise *pp) { struct ExecContain e; e.useshell = GetBooleanConstraint("useshell",pp); e.umask = GetOctalConstraint("umask",pp); e.owner = GetUidConstraint("exec_owner",pp); e.group = GetGidConstraint("exec_group",pp); e.preview = GetBooleanConstraint("preview",pp); e.nooutput = GetBooleanConstraint("no_output",pp); e.timeout = GetIntConstraint("exec_timeout",pp); e.chroot = GetConstraint("chroot",pp,CF_SCALAR); e.chdir = GetConstraint("chdir",pp,CF_SCALAR); return e; } /*******************************************************************/ struct Recursion GetRecursionConstraints(struct Promise *pp) { struct Recursion r; r.travlinks = GetBooleanConstraint("traverse_links",pp); r.rmdeadlinks = GetBooleanConstraint("rmdeadlinks",pp); r.depth = GetIntConstraint("depth",pp); if (r.depth == CF_NOINT) { r.depth = 0; } r.xdev = GetBooleanConstraint("xdev",pp); r.include_dirs = GetListConstraint("include_dirs",pp); r.exclude_dirs = GetListConstraint("exclude_dirs",pp); r.include_basedir = GetBooleanConstraint("include_basedir",pp); return r; } /*******************************************************************/ struct CfACL GetAclConstraints(struct Promise *pp) { struct CfACL ac; ac.acl_method = Str2AclMethod(GetConstraint("acl_method",pp,CF_SCALAR)); ac.acl_type = Str2AclType(GetConstraint("acl_type",pp,CF_SCALAR)); ac.acl_directory_inherit = Str2AclInherit(GetConstraint("acl_directory_inherit",pp,CF_SCALAR)); ac.acl_entries = GetListConstraint("aces",pp); ac.acl_inherit_entries = GetListConstraint("specify_inherit_aces",pp); return ac; } /*******************************************************************/ struct FilePerms GetPermissionConstraints(struct Promise *pp) { struct FilePerms p; char *value; struct Rlist *list; value = (char *)GetConstraint("mode",pp,CF_SCALAR); p.plus = CF_SAMEMODE; p.minus = CF_SAMEMODE; if (!ParseModeString(value,&p.plus,&p.minus)) { CfOut(cf_error,"","Problem validating a mode string"); PromiseRef(cf_error,pp); } list = GetListConstraint("bsdflags",pp); p.plus_flags = 0; p.minus_flags = 0; if (list && !ParseFlagString(list,&p.plus_flags,&p.minus_flags)) { CfOut(cf_error,"","Problem validating a BSD flag string"); PromiseRef(cf_error,pp); } #ifdef MINGW p.owners = NovaWin_Rlist2SidList((struct Rlist *)GetConstraint("owners",pp,CF_LIST),pp); #else /* NOT MINGW */ p.owners = Rlist2UidList((struct Rlist *)GetConstraint("owners",pp,CF_LIST),pp); p.groups = Rlist2GidList((struct Rlist *)GetConstraint("groups",pp,CF_LIST),pp); #endif /* NOT MINGW */ p.findertype = (char *)GetConstraint("findertype",pp,CF_SCALAR); p.rxdirs = GetBooleanConstraint("rxdirs",pp); // The default should be true if (!GetConstraint("rxdirs",pp,CF_SCALAR)) { p.rxdirs = true; } return p; } /*******************************************************************/ struct FileSelect GetSelectConstraints(struct Promise *pp) { struct FileSelect s; char *value; struct Rlist *rp; mode_t plus,minus; u_long fplus,fminus; int entries = false; s.name = (struct Rlist *)GetConstraint("leaf_name",pp,CF_LIST); s.path = (struct Rlist *)GetConstraint("path_name",pp,CF_LIST); s.filetypes = (struct Rlist *)GetConstraint("file_types",pp,CF_LIST); s.issymlinkto = (struct Rlist *)GetConstraint("issymlinkto",pp,CF_LIST); s.perms = GetListConstraint("search_mode",pp); for (rp = s.perms; rp != NULL; rp=rp->next) { plus = 0; minus = 0; value = (char *)rp->item; if (!ParseModeString(value,&plus,&minus)) { CfOut(cf_error,"","Problem validating a mode string"); PromiseRef(cf_error,pp); } } s.bsdflags = GetListConstraint("search_bsdflags",pp); fplus = 0; fminus = 0; if (!ParseFlagString(s.bsdflags,&fplus,&fminus)) { CfOut(cf_error,"","Problem validating a BSD flag string"); PromiseRef(cf_error,pp); } if (s.name||s.path||s.filetypes||s.issymlinkto||s.perms||s.bsdflags) { entries = true; } s.owners = (struct Rlist *)GetConstraint("search_owners",pp,CF_LIST); s.groups = (struct Rlist *)GetConstraint("search_groups",pp,CF_LIST); value = (char *)GetConstraint("search_size",pp,CF_SCALAR); if (value) { entries++; } IntRange2Int(value,(long *)&s.min_size,(long *)&s.max_size,pp); value = (char *)GetConstraint("ctime",pp,CF_SCALAR); if (value) { entries++; } IntRange2Int(value,(long *)&s.min_ctime,(long *)&s.max_ctime,pp); value = (char *)GetConstraint("atime",pp,CF_SCALAR); if (value) { entries++; } IntRange2Int(value,(long *)&s.min_atime,(long *)&s.max_atime,pp); value = (char *)GetConstraint("mtime",pp,CF_SCALAR); if (value) { entries++; } IntRange2Int(value,(long *)&s.min_mtime,(long *)&s.max_mtime,pp); s.exec_regex = (char *)GetConstraint("exec_regex",pp,CF_SCALAR); s.exec_program = (char *)GetConstraint("exec_program",pp,CF_SCALAR); if (s.owners||s.min_size||s.exec_regex||s.exec_program) { entries = true; } if ((s.result = (char *)GetConstraint("file_result",pp,CF_SCALAR)) == NULL) { if (!entries) { CfOut(cf_error,""," !! file_select body missing its a file_result return value"); } } return s; } /*******************************************************************/ struct TransactionContext GetTransactionConstraints(struct Promise *pp) { struct TransactionContext t; char *value; value = GetConstraint("action_policy",pp,CF_SCALAR); if (value && ((strcmp(value,"warn") == 0)||(strcmp(value,"nop") == 0))) { t.action = cfa_warn; } else { t.action = cfa_fix; // default } t.background = GetBooleanConstraint("background",pp); t.ifelapsed = GetIntConstraint("ifelapsed",pp); if (t.ifelapsed == CF_NOINT) { t.ifelapsed = VIFELAPSED; } t.expireafter = GetIntConstraint("expireafter",pp); if (t.expireafter == CF_NOINT) { t.expireafter = VEXPIREAFTER; } t.audit = GetBooleanConstraint("audit",pp); t.log_string = GetConstraint("log_string",pp,CF_SCALAR); t.log_priority = SyslogPriority2Int(GetConstraint("log_priority",pp,CF_SCALAR)); t.log_kept = GetConstraint("log_kept",pp,CF_SCALAR); t.log_repaired = GetConstraint("log_repaired",pp,CF_SCALAR); t.log_failed = GetConstraint("log_failed",pp,CF_SCALAR); if ((t.value_kept = GetRealConstraint("value_kept",pp)) == CF_NODOUBLE) { t.value_kept = 1.0; } if ((t.value_repaired = GetRealConstraint("value_repaired",pp)) == CF_NODOUBLE) { t.value_repaired = 0.5; } if ((t.value_notkept = GetRealConstraint("value_notkept",pp)) == CF_NODOUBLE) { t.value_notkept = -1.0; } value = GetConstraint("log_level",pp,CF_SCALAR); t.log_level = String2ReportLevel(value); value = GetConstraint("report_level",pp,CF_SCALAR); t.report_level = String2ReportLevel(value); t.measure_id = GetConstraint("measurement_class",pp,CF_SCALAR); return t; } /*******************************************************************/ struct DefineClasses GetClassDefinitionConstraints(struct Promise *pp) { struct DefineClasses c; char *pt = NULL; c.change = (struct Rlist *)GetListConstraint("promise_repaired",pp); c.failure = (struct Rlist *)GetListConstraint("repair_failed",pp); c.denied = (struct Rlist *)GetListConstraint("repair_denied",pp); c.timeout = (struct Rlist *)GetListConstraint("repair_timeout",pp); c.kept = (struct Rlist *)GetListConstraint("promise_kept",pp); c.interrupt = (struct Rlist *)GetListConstraint("on_interrupt",pp); c.del_change = (struct Rlist *)GetListConstraint("cancel_repaired",pp); c.del_kept = (struct Rlist *)GetListConstraint("cancel_kept",pp); c.del_notkept = (struct Rlist *)GetListConstraint("cancel_notkept",pp); c.retcode_kept = (struct Rlist *)GetListConstraint("kept_returncodes",pp); c.retcode_repaired = (struct Rlist *)GetListConstraint("repaired_returncodes",pp); c.retcode_failed = (struct Rlist *)GetListConstraint("failed_returncodes",pp); c.persist = GetIntConstraint("persist_time",pp); if (c.persist == CF_NOINT) { c.persist = 0; } pt = GetConstraint("timer_policy",pp,CF_SCALAR); if (pt && strncmp(pt,"abs",3) == 0) { c.timer = cfpreserve; } else { c.timer = cfreset; } return c; } /*******************************************************************/ struct FileDelete GetDeleteConstraints(struct Promise *pp) { struct FileDelete f; char *value; value = (char *)GetConstraint("dirlinks",pp,CF_SCALAR); if (value && strcmp(value,"keep") == 0) { f.dirlinks = cfa_linkkeep; } else { f.dirlinks = cfa_linkdelete; } f.rmdirs = GetBooleanConstraint("rmdirs",pp); return f; } /*******************************************************************/ struct FileRename GetRenameConstraints(struct Promise *pp) { struct FileRename r; char *value; value = (char *)GetConstraint("disable_mode",pp,CF_SCALAR); if (!ParseModeString(value,&r.plus,&r.minus)) { CfOut(cf_error,"","Problem validating a mode string"); PromiseRef(cf_error,pp); } r.disable = GetBooleanConstraint("disable",pp); r.disable_suffix = (char *)GetConstraint("disable_suffix",pp,CF_SCALAR); r.newname = (char *)GetConstraint("newname",pp,CF_SCALAR); r.rotate = GetIntConstraint("rotate",pp); return r; } /*******************************************************************/ struct FileChange GetChangeMgtConstraints(struct Promise *pp) { struct FileChange c; char *value; value = (char *)GetConstraint("hash",pp,CF_SCALAR); if (value && strcmp(value,"best") == 0) { #ifdef HAVE_NOVA c.hash = cf_sha512; #else c.hash = cf_besthash; #endif } else if (value && strcmp(value,"md5") == 0) { c.hash = cf_md5; } else if (value && strcmp(value,"sha1") == 0) { c.hash = cf_sha1; } else if (value && strcmp(value,"sha256") == 0) { c.hash = cf_sha256; } else if (value && strcmp(value,"sha384") == 0) { c.hash = cf_sha384; } else if (value && strcmp(value,"sha512") == 0) { c.hash = cf_sha512; } else { c.hash = CF_DEFAULT_DIGEST; } if (FIPS_MODE && c.hash == cf_md5) { CfOut(cf_error,""," !! FIPS mode is enabled, and md5 is not an approved algorithm"); PromiseRef(cf_error,pp); } value = (char *)GetConstraint("report_changes",pp,CF_SCALAR); if (value && strcmp(value,"content") == 0) { c.report_changes = cfa_contentchange; } else if (value && strcmp(value,"stats") == 0) { c.report_changes = cfa_statschange; } else if (value && strcmp(value,"all") == 0) { c.report_changes = cfa_allchanges; } else { c.report_changes = cfa_noreport; } if (GetConstraint("update_hashes",pp,CF_SCALAR)) { c.update = GetBooleanConstraint("update_hashes",pp); } else { c.update = CHECKSUMUPDATES; } c.report_diffs = GetBooleanConstraint("report_diffs",pp); return c; } /*******************************************************************/ struct FileCopy GetCopyConstraints(struct Promise *pp) { struct FileCopy f; char *value; long min,max; f.source = (char *)GetConstraint("source",pp,CF_SCALAR); value = (char *)GetConstraint("compare",pp,CF_SCALAR); if (value == NULL) { value = DEFAULT_COPYTYPE; } f.compare = String2Comparison(value); value = (char *)GetConstraint("link_type",pp,CF_SCALAR); f.link_type = String2LinkType(value); f.servers = GetListConstraint("servers",pp); f.portnumber = (short)GetIntConstraint("portnumber",pp); f.timeout = (short)GetIntConstraint("timeout",pp); f.link_instead = GetListConstraint("linkcopy_patterns",pp); f.copy_links = GetListConstraint("copylink_patterns",pp); value = (char *)GetConstraint("copy_backup",pp,CF_SCALAR); if (value && strcmp(value,"false") == 0) { f.backup = cfa_nobackup; } else if (value && strcmp(value,"timestamp") == 0) { f.backup = cfa_timestamp; } else { f.backup = cfa_backup; } f.stealth = GetBooleanConstraint("stealth",pp); f.collapse = GetBooleanConstraint("collapse_destination_dir",pp); f.preserve = GetBooleanConstraint("preserve",pp); f.type_check = GetBooleanConstraint("type_check",pp); f.force_update = GetBooleanConstraint("force_update",pp); f.force_ipv4 = GetBooleanConstraint("force_ipv4",pp); f.check_root = GetBooleanConstraint("check_root",pp); value = (char *)GetConstraint("copy_size",pp,CF_SCALAR); IntRange2Int(value,&min,&max,pp); f.min_size = (size_t) min; f.max_size = (size_t) max; f.trustkey = GetBooleanConstraint("trustkey",pp); f.encrypt = GetBooleanConstraint("encrypt",pp); f.verify = GetBooleanConstraint("verify",pp); f.purge = GetBooleanConstraint("purge",pp); f.destination = NULL; return f; } /*******************************************************************/ struct FileLink GetLinkConstraints(struct Promise *pp) { struct FileLink f; char *value; f.source = (char *)GetConstraint("source",pp,CF_SCALAR); value = (char *)GetConstraint("link_type",pp,CF_SCALAR); f.link_type = String2LinkType(value); f.copy_patterns = GetListConstraint("copy_patterns",pp); value = (char *)GetConstraint("when_no_source",pp,CF_SCALAR); if (value && strcmp(value,"force") == 0) { f.when_no_file = cfa_force; } else if (value && strcmp(value,"delete") == 0) { f.when_no_file = cfa_delete; } else { f.when_no_file = cfa_skip; } value = (char *)GetConstraint("when_linking_children",pp,CF_SCALAR); if (value && strcmp(value,"override_file") == 0) { f.when_linking_children = cfa_override; } else { f.when_linking_children = cfa_onlynonexisting; } f.link_children = GetBooleanConstraint("link_children",pp); return f; } /*******************************************************************/ struct EditDefaults GetEditDefaults(struct Promise *pp) { struct EditDefaults e; char *value; e.maxfilesize = GetIntConstraint("max_file_size",pp); if (e.maxfilesize == CF_NOINT || e.maxfilesize == 0) { e.maxfilesize = EDITFILESIZE; } value = (char *)GetConstraint("edit_backup",pp,CF_SCALAR); if (value && strcmp(value,"false") == 0) { e.backup = cfa_nobackup; } else if (value && strcmp(value,"timestamp") == 0) { e.backup = cfa_timestamp; } else { e.backup = cfa_backup; } e.empty_before_use = GetBooleanConstraint("empty_file_before_editing",pp); e.joinlines = GetBooleanConstraint("recognize_join",pp); return e; } /*******************************************************************/ struct Context GetContextConstraints(struct Promise *pp) { struct Context a; struct Constraint *cp; int i; a.broken = -1; a.expression = NULL; for (cp = pp->conlist; cp != NULL; cp=cp->next) { for (i = 0; CF_CLASSBODY[i].lval != NULL; i++) { if (strcmp(cp->lval,CF_CLASSBODY[i].lval) == 0) { a.expression = cp; a.broken++; } } } return a; } /*******************************************************************/ struct Packages GetPackageConstraints(struct Promise *pp) { struct Packages p; enum package_actions action; enum version_cmp operator; enum action_policy change_policy; p.have_package_methods = GetBooleanConstraint("havepackage_method",pp); p.package_version = (char *)GetConstraint("package_version",pp,CF_SCALAR); p.package_architectures = GetListConstraint("package_architectures",pp); action = Str2PackageAction((char *)GetConstraint("package_policy",pp,CF_SCALAR)); p.package_policy = action; operator = Str2PackageSelect((char *)GetConstraint("package_select",pp,CF_SCALAR)); p.package_select = operator; change_policy = Str2ActionPolicy((char *)GetConstraint("package_changes",pp,CF_SCALAR)); p.package_changes = change_policy; p.package_file_repositories = GetListConstraint("package_file_repositories",pp); p.package_patch_list_command = (char *)GetConstraint("package_patch_list_command",pp,CF_SCALAR); p.package_patch_name_regex = (char *)GetConstraint("package_patch_name_regex",pp,CF_SCALAR); p.package_patch_arch_regex = (char *)GetConstraint("package_patch_arch_regex",pp,CF_SCALAR); p.package_patch_version_regex = (char *)GetConstraint("package_patch_version_regex",pp,CF_SCALAR); p.package_patch_installed_regex = (char *)GetConstraint("package_patch_installed_regex",pp,CF_SCALAR); p.package_list_update_command = (char *)GetConstraint("package_list_update_command",pp,CF_SCALAR); p.package_list_update_ifelapsed = GetIntConstraint("package_list_update_ifelapsed",pp); p.package_list_command = (char *)GetConstraint("package_list_command",pp,CF_SCALAR); p.package_list_version_regex = (char *)GetConstraint("package_list_version_regex",pp,CF_SCALAR); p.package_list_name_regex = (char *)GetConstraint("package_list_name_regex",pp,CF_SCALAR); p.package_list_arch_regex = (char *)GetConstraint("package_list_arch_regex",pp,CF_SCALAR); p.package_installed_regex = (char *)GetConstraint("package_installed_regex",pp,CF_SCALAR); p.package_version_regex = (char *)GetConstraint("package_version_regex",pp,CF_SCALAR); p.package_name_regex = (char *)GetConstraint("package_name_regex",pp,CF_SCALAR); p.package_arch_regex = (char *)GetConstraint("package_arch_regex",pp,CF_SCALAR); p.package_add_command = (char *)GetConstraint("package_add_command",pp,CF_SCALAR); p.package_delete_command = (char *)GetConstraint("package_delete_command",pp,CF_SCALAR); p.package_update_command = (char *)GetConstraint("package_update_command",pp,CF_SCALAR); p.package_patch_command = (char *)GetConstraint("package_patch_command",pp,CF_SCALAR); p.package_verify_command = (char *)GetConstraint("package_verify_command",pp,CF_SCALAR); p.package_noverify_regex = (char *)GetConstraint("package_noverify_regex",pp,CF_SCALAR); p.package_noverify_returncode = GetIntConstraint("package_noverify_returncode",pp); p.package_name_convention = (char *)GetConstraint("package_name_convention",pp,CF_SCALAR); p.package_delete_convention = (char *)GetConstraint("package_delete_convention",pp,CF_SCALAR); p.package_multiline_start = (char *)GetConstraint("package_multiline_start",pp,CF_SCALAR); return p; } /*******************************************************************/ struct ProcessSelect GetProcessFilterConstraints(struct Promise *pp) { struct ProcessSelect p; char *value; int entries = 0; p.owner = GetListConstraint("process_owner",pp); value = (char *)GetConstraint("pid",pp,CF_SCALAR); if (value) { entries++; } IntRange2Int(value,&p.min_pid,&p.max_pid,pp); value = (char *)GetConstraint("ppid",pp,CF_SCALAR); if (value) { entries++; } IntRange2Int(value,&p.min_ppid,&p.max_ppid,pp); value = (char *)GetConstraint("pgid",pp,CF_SCALAR); if (value) { entries++; } IntRange2Int(value,&p.min_pgid,&p.max_pgid,pp); value = (char *)GetConstraint("rsize",pp,CF_SCALAR); if (value) { entries++; } IntRange2Int(value,&p.min_rsize,&p.max_rsize,pp); value = (char *)GetConstraint("vsize",pp,CF_SCALAR); if (value) { entries++; } IntRange2Int(value,&p.min_vsize,&p.max_vsize,pp); value = (char *)GetConstraint("ttime_range",pp,CF_SCALAR); if (value) { entries++; } IntRange2Int(value,(long *)&p.min_ttime,(long *)&p.max_ttime,pp); value = (char *)GetConstraint("stime_range",pp,CF_SCALAR); if (value) { entries++; } IntRange2Int(value,(long *)&p.min_stime,(long *)&p.max_stime,pp); p.status = (char *)GetConstraint("status",pp,CF_SCALAR); p.command = (char *)GetConstraint("command",pp,CF_SCALAR); p.tty = (char *)GetConstraint("tty",pp,CF_SCALAR); value = (char *)GetConstraint("priority",pp,CF_SCALAR); if (value) { entries++; } IntRange2Int(value,&p.min_pri,&p.max_pri,pp); value = (char *)GetConstraint("threads",pp,CF_SCALAR); if (value) { entries++; } IntRange2Int(value,&p.min_thread,&p.max_thread,pp); if (p.owner||p.status||p.command||p.tty) { entries = true; } if ((p.process_result = (char *)GetConstraint("process_result",pp,CF_SCALAR)) == NULL) { if (entries) { CfOut(cf_error,""," !! process_select body missing its a process_result return value"); } } return p; } /*******************************************************************/ struct ProcessCount GetMatchesConstraints(struct Promise *pp) { struct ProcessCount p; char *value; value = (char *)GetConstraint("match_range",pp,CF_SCALAR); IntRange2Int(value,&p.min_range,&p.max_range,pp); p.in_range_define = GetListConstraint("in_range_define",pp); p.out_of_range_define = GetListConstraint("out_of_range_define",pp); return p; } /*******************************************************************/ static void ShowAttributes(struct Attributes a) { printf(".....................................................\n"); printf("File Attribute Set =\n\n"); if (a.havedepthsearch) printf(" * havedepthsearch\n"); if (a.haveselect) printf(" * haveselect\n"); if (a.haverename) printf(" * haverename\n"); if (a.havedelete) printf(" * havedelete\n"); if (a.haveperms) printf(" * haveperms\n"); if (a.havechange) printf(" * havechange\n"); if (a.havecopy) printf(" * havecopy\n"); if (a.havelink) printf(" * havelink\n"); if (a.haveedit) printf(" * haveedit\n"); if (a.create) printf(" * havecreate\n"); if (a.touch) printf(" * havetouch\n"); if (a.move_obstructions) printf(" * move_obstructions\n"); if (a.repository) printf(" * repository %s\n",a.repository); if (a.transformer)printf(" * transformer %s\n",a.transformer); /* if (a.perms) printf(" * perms %o\n",a.perms.mode); a.select = GetSelectConstraints(pp); a.delete = GetDeleteConstraints(pp); a.rename = GetRenameConstraints(pp); a.change = GetChangeMgtConstraints(pp); a.copy = GetCopyConstraints(pp); a.link = GetLinkConstraints(pp); a.recursion = GetRecursionConstraints(pp); a.transaction = GetTransactionConstraints(pp); a.classes = GetClassDefinitionConstraints(pp); */ printf(".....................................................\n\n"); } /*******************************************************************/ /* Edit sub-bundles have their own attributes */ /*******************************************************************/ struct Attributes GetInsertionAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.havelocation = GetBooleanConstraint("location",pp); attr.location = GetLocationAttributes(pp); attr.sourcetype = GetConstraint("insert_type",pp,CF_SCALAR); attr.expandvars = GetBooleanConstraint("expand_scalars",pp); attr.haveinsertselect = GetBooleanConstraint("insert_select",pp); attr.line_select = GetInsertSelectConstraints(pp); attr.insert_match = GetListConstraint("whitespace_policy",pp); /* Common ("included") */ attr.haveregion = GetBooleanConstraint("select_region",pp); attr.region = GetRegionConstraints(pp); attr.havetrans = GetBooleanConstraint(CF_TRANSACTION,pp); attr.transaction = GetTransactionConstraints(pp); attr.haveclasses = GetBooleanConstraint(CF_DEFINECLASSES,pp); attr.classes = GetClassDefinitionConstraints(pp); return attr; } /*******************************************************************/ struct EditLocation GetLocationAttributes(struct Promise *pp) { struct EditLocation e; char *value; e.line_matching = GetConstraint("select_line_matching",pp,CF_SCALAR); value = GetConstraint("before_after",pp,CF_SCALAR); if (value && strcmp(value,"before") == 0) { e.before_after = cfe_before; } else { e.before_after = cfe_after; } e.first_last = GetConstraint("first_last",pp,CF_SCALAR); return e; } /*******************************************************************/ struct Attributes GetDeletionAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.not_matching = GetBooleanConstraint("not_matching",pp); attr.havedeleteselect = GetBooleanConstraint("delete_select",pp); attr.line_select = GetDeleteSelectConstraints(pp); /* common */ attr.haveregion = GetBooleanConstraint("select_region",pp); attr.region = GetRegionConstraints(pp); attr.havetrans = GetBooleanConstraint(CF_TRANSACTION,pp); attr.transaction = GetTransactionConstraints(pp); attr.haveclasses = GetBooleanConstraint(CF_DEFINECLASSES,pp); attr.classes = GetClassDefinitionConstraints(pp); return attr; } /*******************************************************************/ struct Attributes GetColumnAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.havecolumn = GetBooleanConstraint("edit_field",pp); attr.column = GetColumnConstraints(pp); /* common */ attr.haveregion = GetBooleanConstraint("select_region",pp); attr.region = GetRegionConstraints(pp); attr.havetrans = GetBooleanConstraint(CF_TRANSACTION,pp); attr.transaction = GetTransactionConstraints(pp); attr.haveclasses = GetBooleanConstraint(CF_DEFINECLASSES,pp); attr.classes = GetClassDefinitionConstraints(pp); return attr; } /*******************************************************************/ struct Attributes GetReplaceAttributes(struct Promise *pp) { struct Attributes attr = {{0}}; attr.havereplace = GetBooleanConstraint("replace_patterns",pp); attr.replace = GetReplaceConstraints(pp); attr.havecolumn = GetBooleanConstraint("replace_with",pp); /* common */ attr.haveregion = GetBooleanConstraint("select_region",pp); attr.region = GetRegionConstraints(pp); attr.havetrans = GetBooleanConstraint(CF_TRANSACTION,pp); attr.transaction = GetTransactionConstraints(pp); attr.haveclasses = GetBooleanConstraint(CF_DEFINECLASSES,pp); attr.classes = GetClassDefinitionConstraints(pp); return attr; } /*******************************************************************/ struct EditRegion GetRegionConstraints(struct Promise *pp) { struct EditRegion e; e.select_start = GetConstraint("select_start",pp,CF_SCALAR); e.select_end = GetConstraint("select_end",pp,CF_SCALAR); e.include_start = GetBooleanConstraint("include_start_delimiter",pp); e.include_end = GetBooleanConstraint("include_end_delimiter",pp); return e; } /*******************************************************************/ struct EditReplace GetReplaceConstraints(struct Promise *pp) { struct EditReplace r; r.replace_value = GetConstraint("replace_value",pp,CF_SCALAR); r.occurrences = GetConstraint("occurrences",pp,CF_SCALAR); return r; } /*******************************************************************/ struct EditColumn GetColumnConstraints(struct Promise *pp) { struct EditColumn c; char *value; c.column_separator = GetConstraint("field_separator",pp,CF_SCALAR); c.select_column = GetIntConstraint("select_field",pp); if (c.select_column != CF_NOINT && GetBooleanConstraint("start_fields_from_zero",pp)) { c.select_column++; } value = GetConstraint("value_separator",pp,CF_SCALAR); if (value) { c.value_separator = *value; } else { c.value_separator = '\0'; } c.column_value = GetConstraint("field_value",pp,CF_SCALAR); c.column_operation = GetConstraint("field_operation",pp,CF_SCALAR); c.extend_columns = GetBooleanConstraint("extend_fields",pp); c.blanks_ok = GetBooleanConstraint("allow_blank_fields",pp); return c; } /*******************************************************************/ /* Storage */ /*******************************************************************/ struct StorageMount GetMountConstraints(struct Promise *pp) { struct StorageMount m; m.mount_type = GetConstraint("mount_type",pp,CF_SCALAR); m.mount_source = GetConstraint("mount_source",pp,CF_SCALAR); m.mount_server = GetConstraint("mount_server",pp,CF_SCALAR); m.mount_options = GetListConstraint("mount_options",pp); m.editfstab = GetBooleanConstraint("edit_fstab",pp); m.unmount = GetBooleanConstraint("unmount",pp); return m; } /*******************************************************************/ struct StorageVolume GetVolumeConstraints(struct Promise *pp) { struct StorageVolume v; char *value; v.check_foreign = GetBooleanConstraint("check_foreign",pp); value = GetConstraint("freespace",pp,CF_SCALAR); v.freespace = (long) Str2Int(value); value = GetConstraint("sensible_size",pp,CF_SCALAR); v.sensible_size = (int) Str2Int(value); value = GetConstraint("sensible_count",pp,CF_SCALAR); v.sensible_count = (int) Str2Int(value); v.scan_arrivals = GetBooleanConstraint("scan_arrivals",pp); // defaults if(v.sensible_size == CF_NOINT) { v.sensible_size = 1000; } if(v.sensible_count == CF_NOINT) { v.sensible_count = 2; } return v; } /*******************************************************************/ struct CfTcpIp GetTCPIPAttributes(struct Promise *pp) { struct CfTcpIp t; t.ipv4_address = GetConstraint("ipv4_address",pp,CF_SCALAR); t.ipv4_netmask = GetConstraint("ipv4_netmask",pp,CF_SCALAR); return t; } /*******************************************************************/ struct Report GetReportConstraints(struct Promise *pp) { struct Report r; if (GetConstraint("lastseen",pp,CF_SCALAR)) { r.havelastseen = true; r.lastseen = GetIntConstraint("lastseen",pp); if (r.lastseen == CF_NOINT) { r.lastseen = 0; } } else { r.havelastseen = false; r.lastseen = 0; } r.intermittency = GetRealConstraint("intermittency",pp); if (r.intermittency == CF_NODOUBLE) { r.intermittency = 0; } r.haveprintfile = GetBooleanConstraint("printfile",pp); r.filename = (char *)GetConstraint("file_to_print",pp,CF_SCALAR); r.numlines = GetIntConstraint("number_of_lines",pp); if (r.numlines == CF_NOINT) { r.numlines = 5; } r.showstate = GetListConstraint("showstate",pp); r.friend_pattern = GetConstraint("friend_pattern",pp,CF_SCALAR); r.to_file = GetConstraint("report_to_file",pp,CF_SCALAR); return r; } /*******************************************************************/ struct LineSelect GetInsertSelectConstraints(struct Promise *pp) { struct LineSelect s; s.startwith_from_list = GetListConstraint("insert_if_startwith_from_list",pp); s.not_startwith_from_list = GetListConstraint("insert_if_not_startwith_from_list",pp); s.match_from_list = GetListConstraint("insert_if_match_from_list",pp); s.not_match_from_list = GetListConstraint("insert_if_not_match_from_list",pp); s.contains_from_list = GetListConstraint("insert_if_contains_from_list",pp); s.not_contains_from_list = GetListConstraint("insert_if_not_contains_from_list",pp); return s; } /*******************************************************************/ struct LineSelect GetDeleteSelectConstraints(struct Promise *pp) { struct LineSelect s; s.startwith_from_list = GetListConstraint("delete_if_startwith_from_list",pp); s.not_startwith_from_list = GetListConstraint("delete_if_not_startwith_from_list",pp); s.match_from_list = GetListConstraint("delete_if_match_from_list",pp); s.not_match_from_list = GetListConstraint("delete_if_not_match_from_list",pp); s.contains_from_list = GetListConstraint("delete_if_contains_from_list",pp); s.not_contains_from_list = GetListConstraint("delete_if_not_contains_from_list",pp); return s; } /*******************************************************************/ struct Measurement GetMeasurementConstraint(struct Promise *pp) { struct Measurement m; char *value; m.stream_type = GetConstraint("stream_type",pp,CF_SCALAR); value = GetConstraint("data_type",pp,CF_SCALAR); m.data_type = Typename2Datatype(value); if (m.data_type == cf_notype) { m.data_type = cf_str; } m.history_type = GetConstraint("history_type",pp,CF_SCALAR); m.select_line_matching = GetConstraint("select_line_matching",pp,CF_SCALAR); m.select_line_number = GetIntConstraint("select_line_number",pp); m.extraction_regex = GetConstraint("extraction_regex",pp,CF_SCALAR); m.units = GetConstraint("units",pp,CF_SCALAR); m.growing = GetBooleanConstraint("track_growing_file",pp); return m; } /*******************************************************************/ struct CfDatabase GetDatabaseConstraints(struct Promise *pp) { struct CfDatabase d; char *value; d.db_server_owner = GetConstraint("db_server_owner",pp,CF_SCALAR); d.db_server_password = GetConstraint("db_server_password",pp,CF_SCALAR); d.db_server_host = GetConstraint("db_server_host",pp,CF_SCALAR); d.db_connect_db = GetConstraint("db_server_connection_db",pp,CF_SCALAR); d.type = GetConstraint("database_type",pp,CF_SCALAR); d.server = GetConstraint("database_server",pp,CF_SCALAR); d.columns = GetListConstraint("database_columns",pp); d.rows = GetListConstraint("database_rows",pp); d.operation = GetConstraint("database_operation",pp,CF_SCALAR); d.exclude = GetListConstraint("registry_exclude",pp); value = GetConstraint("db_server_type",pp,CF_SCALAR); d.db_server_type = Str2dbType(value); if (value && d.db_server_type == cfd_notype) { CfOut(cf_error,"","Unsupported database type \"%s\" in databases promise",value); PromiseRef(cf_error,pp); } return d; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/mod_outputs.c��������������������������������������������������������������������0000644�0001750�0001750�00000006150�11715232734�013543� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_environ.c */ /* */ /*****************************************************************************/ /* This file can act as a template for adding functionality to cfengine 3. All functionality can be added by extending the main array CF_MOD_SUBTYPES[CF3_MODULES] and its array dimension, in mod_common, in the manner shown here. */ #define CF3_MOD_OUTPUTS #include "cf3.defs.h" #include "cf3.extern.h" /***********************************************************/ /* Read this module file backwards, as dependencies have */ /* to be defined first - these arrays declare pairs of */ /* constraints */ /* */ /* lval => rval */ /* */ /* in the form (lval,type,range) */ /* */ /* If the type is cf_body then the range is a pointer */ /* to another array of pairs, like in a body "sub-routine" */ /* */ /***********************************************************/ struct BodySyntax CF_OUTPUTS_BODIES[] = { {"output_level",cf_opts,"verbose,debug,inform","Output level to observe for the named promise or bundle (meta-promise)"}, {"promiser_type",cf_opts,"promise,bundle","Output level to observe for the named promise or bundle (meta-promise)"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_OUTPUTS_SUBTYPES[] = { {"agent","outputs",CF_OUTPUTS_BODIES}, {NULL,NULL,NULL}, }; ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/mon_entropy.c��������������������������������������������������������������������0000644�0001750�0001750�00000007131�11715232734�013532� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #include "cf3.defs.h" #include "cf3.extern.h" #include "monitoring.h" /* Globals */ static struct Item *PREVIOUS_STATE = NULL; static struct Item *ENTROPIES = NULL; static char ENVFILE_NEW[CF_BUFSIZE]; static char ENVFILE[CF_BUFSIZE]; /* Implementation */ void MonEntropyClassesInit(void) { snprintf(ENVFILE_NEW,CF_BUFSIZE,"%s/state/%s",CFWORKDIR,CF_ENVNEW_FILE); MapName(ENVFILE_NEW); snprintf(ENVFILE,CF_BUFSIZE,"%s/state/%s",CFWORKDIR,CF_ENV_FILE); MapName(ENVFILE); } /****************************************************************************/ void MonEntropyClassesReset(void) { ENTROPIES = NULL; /*?*/ } /****************************************************************************/ /* * This function calculates entropy of items distribution. * * Let's define: * N = length of items list * q_i = items[i]->counter * p_i = q_i / sum_{i=1..N}(q_i) * -- normalized values, or probability of i-th class amongst all * * Entropy is * --- * - > q_i * ln(q_i) * --- i=0..N * E = ------------------------- * ln(N) * * Divisor is a uncertainity per digit, to normalize it to [0..1] we divide it * by ln(N). */ double MonEntropyCalculate(const struct Item *items) { double S = 0.0; double sum = 0.0; int numclasses = 0; const struct Item *i; for (i = items; i; i = i->next) { sum += i->counter; numclasses++; } if (numclasses < 2) { return 0.0; } for (i = items; i; i = i->next) { double q = ((double)i->counter) / sum; S -= q * log(q); } return S / log(numclasses); } /****************************************************************************/ void MonEntropyClassesSet(const char *service, const char *direction, double entropy) { char class[CF_MAXVARSIZE]; const char *class_type = "medium"; if (entropy > 0.9) { class_type = "high"; } if (entropy < 0.2) { class_type = "low"; } snprintf(class, CF_MAXVARSIZE, "entropy_%s_%s_%s", service, direction, class_type); AppendItem(&ENTROPIES,class,""); } /****************************************************************************/ void MonEntropyClassesPublish(struct Item *classlist) { FILE *fp; struct Item *ip; unlink(ENVFILE_NEW); if ((fp = fopen(ENVFILE_NEW,"a")) == NULL) { DeleteItemList(PREVIOUS_STATE); PREVIOUS_STATE = classlist; return; } for (ip = classlist; ip != NULL; ip=ip->next) { fprintf(fp,"%s\n",ip->name); } DeleteItemList(PREVIOUS_STATE); PREVIOUS_STATE = classlist; for (ip = ENTROPIES; ip != NULL; ip=ip->next) { fprintf(fp,"%s\n",ip->name); } DeleteItemList(ENTROPIES); fclose(fp); cf_rename(ENVFILE_NEW,ENVFILE); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/timeout.c������������������������������������������������������������������������0000644�0001750�0001750�00000011156�11715232734�012651� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: timeout.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /* Prototypes */ static void AddTimeClass(time_t time); /*************************************************************************/ void SetTimeOut(int timeout) { ALARM_PID = -1; signal(SIGALRM,(void *)TimeOut); alarm(timeout); } /*************************************************************************/ void TimeOut() { alarm(0); if (ALARM_PID != -1) { CfOut(cf_verbose,"","Time out of process %d\n",ALARM_PID); GracefulTerminate(ALARM_PID); } else { CfOut(cf_verbose,"","%s> Time out\n",VPREFIX); } } /*************************************************************************/ void SetReferenceTime(int setclasses) { time_t tloc; char vbuff[CF_BUFSIZE]; if ((tloc = time((time_t *)NULL)) == -1) { CfOut(cf_error,"time","Couldn't read system clock\n"); } CFSTARTTIME = tloc; snprintf(vbuff,CF_BUFSIZE,"%s",cf_ctime(&tloc)); CfOut(cf_verbose,"","Reference time set to %s\n",cf_ctime(&tloc)); if (setclasses) { AddTimeClass(tloc); } } /*******************************************************************/ void SetStartTime(int setclasses) { time_t tloc; if ((tloc = time((time_t *)NULL)) == -1) { CfOut(cf_error,"time","Couldn't read system clock\n"); } CFINITSTARTTIME = tloc; Debug("Job start time set to %s\n",cf_ctime(&tloc)); } /*********************************************************************/ static void AddTimeClass(time_t time) { struct tm parsed_time; struct tm gmt_parsed_time; char buf[CF_BUFSIZE]; if (localtime_r(&time, &parsed_time) == NULL) { CfOut(cf_error, "localtime_r", "Unable to parse passed time"); return; } if (gmtime_r(&time, &gmt_parsed_time) == NULL) { CfOut(cf_error, "gmtime_r", "Unable to parse passed date"); return; } /* Lifecycle */ snprintf(buf, CF_BUFSIZE, "Lcycle_%d",((parsed_time.tm_year + 1900)%3)); NewClass(buf); /* Year */ snprintf(VYEAR, CF_BUFSIZE, "%04d", parsed_time.tm_year + 1900); snprintf(buf, CF_BUFSIZE, "Yr%04d", parsed_time.tm_year + 1900); NewClass(buf); /* Month */ strlcpy(VMONTH, MONTH_TEXT[parsed_time.tm_mon], 4); NewClass(MONTH_TEXT[parsed_time.tm_mon]); /* Day of week */ /* Monday is 1 in tm_wday, 0 in DAY_TEXT Tuesday is 2 in tm_wday, 1 in DAY_TEXT ... Sunday is 0 in tm_wday, 6 in DAY_TEXT */ int day_text_index = (parsed_time.tm_wday + 6) % 7; NewClass(DAY_TEXT[day_text_index]); /* Day */ snprintf(VDAY, CF_BUFSIZE, "%d", parsed_time.tm_mday); snprintf(buf, CF_BUFSIZE, "Day%d", parsed_time.tm_mday); NewClass(buf); /* Shift */ strcpy(VSHIFT, SHIFT_TEXT[parsed_time.tm_hour / 6]); NewClass(VSHIFT); /* Hour */ snprintf(buf, CF_BUFSIZE, "Hr%02d", parsed_time.tm_hour); NewClass(buf); /* GMT hour */ snprintf(buf, CF_BUFSIZE, "GMT_Hr%d\n", gmt_parsed_time.tm_hour); NewClass(buf); /* Quarter */ int quarter = parsed_time.tm_min / 15 + 1; snprintf(buf, CF_BUFSIZE, "Q%d", quarter); NewClass(buf); snprintf(buf, CF_BUFSIZE, "Hr%02d_Q%d", parsed_time.tm_hour,quarter); NewClass(buf); /* Minute */ snprintf(buf, CF_BUFSIZE, "Min%02d", parsed_time.tm_min); NewClass(buf); int interval_start = (parsed_time.tm_min / 5) * 5; int interval_end = (interval_start + 5) % 60; snprintf(buf, CF_BUFSIZE, "Min%02d_%02d", interval_start, interval_end); NewClass(buf); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/monitoring.h���������������������������������������������������������������������0000644�0001750�0001750�00000003751�11715232734�013357� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifndef CFENGINE_MONITORING_H #define CFENGINE_MONITORING_H /* mon_entropy.c */ void MonEntropyClassesInit(void); void MonEntropyClassesReset(void); void MonEntropyClassesSet(const char *service, const char *direction, double entropy); void MonEntropyClassesPublish(struct Item *classlist); double MonEntropyCalculate(const struct Item *items); /* mon_cpu.c */ void MonCPUGatherData(double *cf_this); /* mon_disk.c */ void MonDiskGatherData(double *cf_this); /* mon_load.c */ void MonLoadGatherData(double *cf_this); /* mon_network.c */ void MonNetworkInit(void); void MonNetworkGatherData(double *cf_this); /* mon_network_sniffer.c */ void MonNetworkSnifferInit(void); void MonNetworkSnifferOpen(void); void MonNetworkSnifferEnable(bool enable); void MonNetworkSnifferSniff(long iteration, double *cf_this); void MonNetworkSnifferGatherData(double *cf_this); /* mon_processes.c */ void MonProcessesGatherData(double *cf_this); /* mon_temp.c */ void MonTempInit(void); void MonTempGatherData(double *cf_this); #endif �����������������������cfengine-3.2.4/src/cfreport.c�����������������������������������������������������������������������0000644�0001750�0001750�00000223312�11715232734�013006� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: cfreport.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" int main (int argc,char *argv[]); void CheckOpts(int argc,char **argv); void ThisAgentInit(void); void KeepReportsControlPromises(void); void KeepReportsPromises(void); void ShowLastSeen(void); void ShowPerformance(void); void ShowLastSeen(void); void ShowClasses(void); void ShowChecksums(void); void ShowLocks (int active); void ShowCurrentAudit(void); char *Format(char *s,int width); int CompareClasses(const void *a, const void *b); void ReadAverages(void); void SummarizeAverages(void); void WriteGraphFiles(void); void WriteHistograms(void); void DiskArrivals(void); void PeerIntermittency(void); void GetFQHN(void); void OpenFiles(void); void CloseFiles(void); void MagnifyNow(void); void OpenMagnifyFiles(void); void CloseMagnifyFiles(void); void EraseAverages(void); void RemoveHostSeen(char *hosts); extern struct BodySyntax CFRE_CONTROLBODY[]; /*******************************************************************/ /* GLOBAL VARIABLES */ /*******************************************************************/ extern struct BodySyntax CFRP_CONTROLBODY[]; int HTML = false; int GRAPH = false; int TITLES = false; int TIMESTAMPS = false; int HIRES = false; int ERRORBARS = true; int NOSCALING = true; int NOWOPT = false; int EMBEDDED = false; unsigned int HISTOGRAM[CF_OBSERVABLES][7][CF_GRAINS]; int SMOOTHHISTOGRAM[CF_OBSERVABLES][7][CF_GRAINS]; char ERASE[CF_BUFSIZE]; double AGE; static struct Averages MAX,MIN; char OUTPUTDIR[CF_BUFSIZE],*sp; char REMOVEHOSTS[CF_BUFSIZE] = {0}; char NOVA_EXPORT_TYPE[CF_MAXVARSIZE] = {0}; char NOVA_IMPORT_FILE[CF_MAXVARSIZE] = {0}; int HUBQUERY = false; char PROMISEHANDLE[CF_MAXVARSIZE] = {0}; char HOSTKEY[CF_MAXVARSIZE] = {0}; char CLASSREGEX[CF_MAXVARSIZE] = {0}; char LSDATA[CF_MAXVARSIZE] = {0}; char NAME[CF_MAXVARSIZE] = {0}; FILE *FPAV=NULL,*FPVAR=NULL, *FPNOW=NULL; FILE *FPE[CF_OBSERVABLES],*FPQ[CF_OBSERVABLES]; FILE *FPM[CF_OBSERVABLES]; struct Rlist *REPORTS = NULL; struct Rlist *CSVLIST = NULL; /*******************************************************************/ /* Command line options */ /*******************************************************************/ const char *ID = "The reporting agent is a merger between the older\n" "cfengine programs cfshow and cfenvgraph. It outputs\n" "data stored in cfengine's embedded databases in human\n" "readable form."; const struct option OPTIONS[32] = { { "help",no_argument,0,'h' }, { "class-regex",required_argument,0,'c'}, { "csv",no_argument,0,'C'}, { "debug",optional_argument,0,'d' }, { "verbose",no_argument,0,'v' }, { "inform",no_argument,0,'I' }, { "version",no_argument,0,'V' }, { "no-lock",no_argument,0,'K'}, { "file",required_argument,0,'f' }, { "hostkey",required_argument,0,'k'}, { "html",no_argument,0,'H'}, { "xml",no_argument,0,'X'}, { "version",no_argument,0,'V'}, { "purge",no_argument,0,'P'}, { "erasehistory",required_argument,0,'E' }, { "nova-export",required_argument,0,'x'}, { "nova-import",required_argument,0,'i'}, { "outputdir",required_argument,0,'o' }, { "promise-handle",required_argument,0,'p'}, { "query-hub",optional_argument,0,'q'}, { "titles",no_argument,0,'t'}, { "timestamps",no_argument,0,'T'}, { "resolution",no_argument,0,'R'}, { "show",required_argument,0,'1'}, { "syntax",no_argument,0,'S'}, { "syntax-export",no_argument,0,'s'}, { "no-error-bars",no_argument,0,'e'}, { "no-scaling",no_argument,0,'n'}, { "verbose",no_argument,0,'v'}, { "remove-hosts",required_argument,0,'r'}, { NULL,0,0,'\0' } }; const char *HINTS[32] = { "Print the help message", "Specify a class regular expression to search for", "Enable CSV output mode in hub queries", "Set debugging level 0,1,2,3", "Output verbose information about the behaviour of the agent", "Output information about actions performed by the agent", "Output the version of the software", "Ignore ifelapsed locks", "Specify an alternative input file than the default", "Specify a hostkey to lookup", "Print output in HTML", "Print output in XML", "Print version string for software", "Purge data about peers not seen beyond the threshold horizon for assumed-dead", "Erase historical data from the cf-monitord monitoring database", "Export Nova reports to file - delta or full report", "Import Nova reports from file - specify the path (only on Nova policy hub)", "Set output directory for printing graph data", "Specify a promise-handle to look up", "Query hub database interactively with optional regex search string", "Add title data to generated graph files", "Add a time stamp to directory name for graph file data", "Print graph data in high resolution", "Show data matching named criteria (software,variables,classes)", "Print a syntax summary for this cfengine version", "Export a syntax tree in Javascript format", "Do not add error bars to the printed graphs", "Do not automatically scale the axes", "Generate verbose output", "Remove comma separated list of key hash entries from the hosts-seen database", NULL }; #define CF_ACTIVE 1 #define CF_INACTIVE 0 /*******************************************************************/ struct CEnt /* For sorting */ { char name[256]; char date[32]; double q; double d; }; /*******************************************************************/ enum cf_format { cfx_entry, cfx_event, cfx_host, cfx_pm, cfx_ip, cfx_date, cfx_q, cfx_av, cfx_dev, cfx_version, cfx_ref, cfx_filename, cfx_index, cfx_min, cfx_max, cfx_end, cfx_alias }; char *CFRX[][2] = { {"<entry>\n","\n</entry>\n"}, {"<event>\n","\n</event>\n"}, {"<hostname>\n","\n</hostname>\n"}, {"<pm>\n","\n</pm>\n"}, {"<ip>\n","\n</ip>\n"}, {"<date>\n","\n</date>\n"}, {"<q>\n","\n</q>\n"}, {"<expect>\n","\n</expect>\n"}, {"<sigma>\n","\n</sigma>\n"}, {"<version>\n","\n</version>\n"}, {"<ref>\n","\n</ref>\n"}, {"<filename>\n","\n</filename>\n"}, {"<index>\n","\n</index>\n"}, {"<min>\n","\n</min>\n"}, {"<max>\n","\n</max>\n"}, {"<end>\n","\n</end>\n"}, {"<alias>\n","\n</alias>\n"}, {NULL,NULL} }; char *CFRH[][2] = { {"<tr>","</tr>\n\n"}, {"<td>","</td>\n"}, {"<td>","</td>\n"}, {"<td bgcolor=#add8e6>","</td>\n"}, {"<td bgcolor=#e0ffff>","</td>\n"}, {"<td bgcolor=#f0f8ff>","</td>\n"}, {"<td bgcolor=#fafafa>","</td>\n"}, {"<td bgcolor=#ededed>","</td>\n"}, {"<td bgcolor=#e0e0e0>","</td>\n"}, {"<td bgcolor=#add8e6>","</td>\n"}, {"<td bgcolor=#e0ffff>","</td>\n"}, {"<td bgcolor=#fafafa><small>","</small></td>\n"}, {"<td bgcolor=#fafafa><small>","</small></td>\n"}, {"<td>","</td>\n"}, {"<td>","</td>\n"}, {"<td>","</td>\n"}, {"<td>","</td>\n"}, {NULL,NULL} }; /*****************************************************************************/ int main(int argc,char *argv[]) { CheckOpts(argc,argv); GenericInitialize(argc,argv,"reporter"); ThisAgentInit(); KeepReportsControlPromises(); KeepReportsPromises(); GenericDeInitialize(); return 0; } /*****************************************************************************/ /* Level 1 */ /*****************************************************************************/ void CheckOpts(int argc,char **argv) { extern char *optarg; int optindex = 0; int c; while ((c=getopt_long(argc,argv,"Cghd:vVf:st:ar:PXHLMIRSKE:x:i:q:1:p:k:c:",OPTIONS,&optindex)) != EOF) { switch ((char) c) { case 'f': strncpy(VINPUTFILE,optarg,CF_BUFSIZE-1); MINUSF = true; break; case 'd': switch ((optarg==NULL) ? '3' : *optarg) { case '1': D1 = true; DEBUG = true; break; case '2': D2 = true; DEBUG = true; break; default: DEBUG = true; break; } break; case 'S': SyntaxTree(); exit(0); break; case 's': SyntaxExport(); exit(0); break; case'K': IGNORELOCK = true; break; case 'v': VERBOSE = true; break; case 'I': INFORM = true; break; case 'V': PrintVersionBanner("cf-report"); exit(0); case 'h': Syntax("cf-report - cfengine's reporting agent",OPTIONS,HINTS,ID); exit(0); case 'M': ManPage("cf-report - cfengine's reporting agent",OPTIONS,HINTS,ID); exit(0); case 'E': strncpy(ERASE,optarg,CF_BUFSIZE-1); break; case 't': TITLES = true; break; case 'o': strcpy(OUTPUTDIR,optarg); CfOut(cf_inform,"","Setting output directory to s\n",OUTPUTDIR); break; case 'T': TIMESTAMPS = true; break; case 'R': HIRES = true; break; case 'r': if(snprintf(REMOVEHOSTS, sizeof(REMOVEHOSTS), "%s", optarg) >= sizeof(REMOVEHOSTS)) { CfOut(cf_error, "", "List of hosts to remove is too long"); exit(1); } break; case 'e': ERRORBARS = false; break; case 'n': NOSCALING = true; break; case 'N': NOWOPT = true; break; case 'X': XML = true; break; case 'H': HTML = true; break; case 'C': CSV = true; break; case 'P': PURGE = 'y'; break; case 'x': if((String2Menu(optarg) != cfd_menu_delta) && (String2Menu(optarg) != cfd_menu_full)) { Syntax("Wrong argument to export: should be delta or full",OPTIONS,HINTS,ID); exit(1); } snprintf(NOVA_EXPORT_TYPE, sizeof(NOVA_EXPORT_TYPE), "%s", optarg); break; case 'i': snprintf(NOVA_IMPORT_FILE, sizeof(NOVA_IMPORT_FILE), "%s", optarg); break; /* Some options for querying hub data - only on commercial hubs */ case 'q': HUBQUERY = true; if (optarg) { strcpy(NAME,optarg); } break; case '1': strcpy(LSDATA,optarg); break; case 'p': strcpy(PROMISEHANDLE,optarg); break; case 'k': strcpy(HOSTKEY,optarg); break; case 'c': strcpy(CLASSREGEX,optarg); break; default: Syntax("cf-report - cfengine's reporting agent",OPTIONS,HINTS,ID); exit(1); } } if (argv[optind] != NULL) { CfOut(cf_error,"","Unexpected argument with no preceding option: %s\n",argv[optind]); } } /*****************************************************************************/ void ThisAgentInit() { time_t now; if (strlen(OUTPUTDIR) == 0) { if (TIMESTAMPS) { if ((now = time((time_t *)NULL)) == -1) { CfOut(cf_verbose,"","Couldn't read system clock\n"); } sprintf(OUTPUTDIR,"cf-reports-%s-%s",CanonifyName(VFQNAME),cf_ctime(&now)); } else { sprintf(OUTPUTDIR,"cf-reports-%s",CanonifyName(VFQNAME)); } } XML = false; HTML = false; umask(077); strcpy(ERASE,""); strcpy(STYLESHEET,""); strcpy(WEBDRIVER,"#"); strcpy(BANNER,""); strcpy(FOOTER,""); snprintf(VINPUTFILE,CF_MAXVARSIZE,"%s/state/%s",CFWORKDIR,CF_AVDB_FILE); MapName(VINPUTFILE); if (!EMPTY(REMOVEHOSTS)) { RemoveHostSeen(REMOVEHOSTS); GenericDeInitialize(); exit(0); } #ifdef HAVE_NOVA if (HUBQUERY) { int count = 0; if (strlen(PROMISEHANDLE) > 0) { count++; } if (strlen(HOSTKEY) > 0) { count++; } if (strlen(CLASSREGEX) > 0) { count++; } if (count > 1) { CfOut(cf_error,""," !! You can only specify one of the following at a time: --promise"); FatalError("Aborted"); } Nova_CommandAPI(LSDATA,NAME,PROMISEHANDLE,HOSTKEY,CLASSREGEX); exit(0); } #endif #ifdef HAVE_NOVA if (!EMPTY(NOVA_EXPORT_TYPE)) { if(Nova_ExportReports(NOVA_EXPORT_TYPE)) { GenericDeInitialize(); exit(0); } else { GenericDeInitialize(); exit(1); } } if (!EMPTY(NOVA_IMPORT_FILE)) { if (IsDefinedClass("am_policy_hub")) { if(Nova_ImportHostReports(NOVA_IMPORT_FILE)) { GenericDeInitialize(); exit(0); } else { GenericDeInitialize(); exit(1); } } else { CfOut(cf_error, "", "Importing reports is only possible on Nova policy hubs"); } } #endif } /*****************************************************************************/ void KeepReportsControlPromises() { struct Constraint *cp; struct Rlist *rp; char rettype; void *retval; for (cp = ControlBodyConstraints(cf_report); cp != NULL; cp=cp->next) { if (IsExcluded(cp->classes)) { continue; } if (GetVariable("control_reporter",cp->lval,&retval,&rettype) == cf_notype) { CfOut(cf_error,"","Unknown lval %s in report agent control body",cp->lval); continue; } if (strcmp(cp->lval,CFRE_CONTROLBODY[cfre_builddir].lval) == 0) { strncpy(OUTPUTDIR,retval,CF_BUFSIZE); CfOut(cf_verbose,"","SET outputdir = %s\n",OUTPUTDIR); if (cf_mkdir(OUTPUTDIR,0755) == -1) { CfOut(cf_verbose,"","Writing to existing directory\n"); } if (chdir(OUTPUTDIR)) { CfOut(cf_error,"chdir","Could not set the working directory to %s",OUTPUTDIR); exit(0); } continue; } if (strcmp(cp->lval,CFRE_CONTROLBODY[cfre_autoscale].lval) == 0) { NOSCALING = !GetBoolean(retval); CfOut(cf_verbose,"","SET autoscale = %d\n",NOSCALING); continue; } if (strcmp(cp->lval,CFRE_CONTROLBODY[cfre_html_embed].lval) == 0) { EMBEDDED = GetBoolean(retval); CfOut(cf_verbose,"","SET html_embedding = %d\n",EMBEDDED); continue; } if (strcmp(cp->lval,CFRE_CONTROLBODY[cfre_timestamps].lval) == 0) { TIMESTAMPS = GetBoolean(retval); CfOut(cf_verbose,"","SET timestamps = %d\n",TIMESTAMPS); continue; } if (strcmp(cp->lval,CFRE_CONTROLBODY[cfre_errorbars].lval) == 0) { ERRORBARS = GetBoolean(retval); CfOut(cf_verbose,"","SET errorbars = %d\n",ERRORBARS); continue; } if (strcmp(cp->lval,CFRE_CONTROLBODY[cfre_query_engine].lval) == 0) { strncpy(WEBDRIVER,retval,CF_MAXVARSIZE); continue; } if (strcmp(cp->lval,CFRE_CONTROLBODY[cfre_aggregation_point].lval) == 0) { /* Ignore for backward compatibility */ continue; } if (strcmp(cp->lval,CFRE_CONTROLBODY[cfre_htmlbanner].lval) == 0) { strncpy(BANNER,retval,CF_BUFSIZE-1); continue; } if (strcmp(cp->lval,CFRE_CONTROLBODY[cfre_htmlfooter].lval) == 0) { strncpy(FOOTER,retval,CF_BUFSIZE-1); continue; } if (strcmp(cp->lval,CFRE_CONTROLBODY[cfre_report_output].lval) == 0) { if (strcmp("html",retval) == 0) { HTML = true; } else if (strcmp("xml",retval) == 0) { XML = true; } else if (strcmp("csv",retval) == 0) { CSV = true; } continue; } if (strcmp(cp->lval,CFRE_CONTROLBODY[cfre_stylesheet].lval) == 0) { strncpy(STYLESHEET,retval,CF_MAXVARSIZE); continue; } if (strcmp(cp->lval,CFRE_CONTROLBODY[cfre_reports].lval) == 0) { for (rp = (struct Rlist *)retval; rp != NULL; rp = rp->next) { IdempPrependRScalar(&REPORTS,rp->item,CF_SCALAR); CfOut(cf_inform,"","Adding %s to the reports...\n",rp->item); } continue; } if (strcmp(cp->lval,CFRE_CONTROLBODY[cfre_csv].lval) == 0) { for (rp = (struct Rlist *)retval; rp != NULL; rp = rp->next) { IdempPrependRScalar(&CSVLIST,rp->item,CF_SCALAR); CfOut(cf_inform,"","Adding %s to the csv2xml list...\n",rp->item); } continue; } } if (GetVariable("control_common",CFG_CONTROLBODY[cfg_lastseenexpireafter].lval,&retval,&rettype) != cf_notype) { LASTSEENEXPIREAFTER = Str2Int(retval); } } /*****************************************************************************/ void KeepReportsPromises() { struct Rlist *rp; int all = false; if (REPORTS == NULL) { CfOut(cf_error,""," !! Nothing to report - nothing selected\n"); exit(0); } CfOut(cf_verbose,""," -> Creating sub-directory %s\n",OUTPUTDIR); if (cf_mkdir(OUTPUTDIR,0755) == -1) { CfOut(cf_verbose,""," -> Writing to existing directory\n"); } if (chdir(OUTPUTDIR)) { CfOut(cf_error,"chdir"," !! Could not set the working directory"); exit(0); } ReadAverages(); for (rp = REPORTS; rp != NULL; rp = rp->next) { Banner(rp->item); if (strcmp("all",rp->item) == 0) { if (RlistLen(REPORTS) > 1) { CfOut(cf_error,""," !! \"all\" should be the only item in the list, if it exists"); continue; } all = true; } if (all || strcmp("last_seen",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating last-seen report...\n"); ShowLastSeen(); } if (strcmp("all_locks",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating lock report...\n"); ShowLocks(CF_INACTIVE); } if (strcmp("active_locks",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating active lock report...\n"); ShowLocks(CF_ACTIVE); } if (strcmp("hashes",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating file-hash report...\n"); ShowChecksums(); } if (all || strcmp("performance",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating performance report...\n"); ShowPerformance(); } if (strcmp("audit",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating audit report...\n"); ShowCurrentAudit(); } if (all || strcmp("classes",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating classes report...\n"); ShowClasses(); } if (all || strcmp("monitor_now",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating monitor recent-history report...\n"); MagnifyNow(); } if (all || strcmp("monitor_summary",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating monitor history summary...\n"); SummarizeAverages(); } if (all || strcmp("monitor_history",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating monitor full history report...\n"); WriteGraphFiles(); WriteHistograms(); DiskArrivals(); PeerIntermittency(); LongHaul(); } if (all || strcmp("compliance",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating compliance summary (Cfengine Nova and above)...\n"); SummarizeCompliance(XML,HTML,CSV,EMBEDDED,STYLESHEET,BANNER,FOOTER,WEBDRIVER); CfOut(cf_verbose,""," -> Creating per-promise compliance summary (Cfengine Nova and above)...\n"); SummarizePerPromiseCompliance(XML,HTML,CSV,EMBEDDED,STYLESHEET,BANNER,FOOTER,WEBDRIVER); CfOut(cf_verbose,""," -> Creating promise repair summary (Cfengine Nova and above)...\n"); SummarizePromiseRepaired(XML,HTML,CSV,EMBEDDED,STYLESHEET,BANNER,FOOTER,WEBDRIVER); CfOut(cf_verbose,""," -> Creating promise non-kept summary (Cfengine Nova and above)...\n"); SummarizePromiseNotKept(XML,HTML,CSV,EMBEDDED,STYLESHEET,BANNER,FOOTER,WEBDRIVER); } if (all || strcmp("file_changes",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating file change summary (Cfengine Nova and above)...\n"); SummarizeFileChanges(XML,HTML,CSV,EMBEDDED,STYLESHEET,BANNER,FOOTER,WEBDRIVER); } if (all || strcmp("installed_software",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating software version summary (Cfengine Nova and above)...\n"); SummarizeSoftware(XML,HTML,CSV,EMBEDDED,STYLESHEET,BANNER,FOOTER,WEBDRIVER); } if (all || strcmp("software_patches",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating software update version summary (Cfengine Nova and above)...\n"); SummarizeUpdates(XML,HTML,CSV,EMBEDDED,STYLESHEET,BANNER,FOOTER,WEBDRIVER); } if (all || strcmp("setuid",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating setuid report (Cfengine Nova and above)...\n"); SummarizeSetuid(XML,HTML,CSV,EMBEDDED,STYLESHEET,BANNER,FOOTER,WEBDRIVER); } if (all || strcmp("variables",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating variables report (Cfengine Nova and above)...\n"); SummarizeVariables(XML,HTML,CSV,EMBEDDED,STYLESHEET,BANNER,FOOTER,WEBDRIVER); } if (all || strcmp("value",rp->item) == 0) { CfOut(cf_verbose,""," -> Creating value report (Cfengine Nova and above)...\n"); SummarizeValue(XML,HTML,CSV,EMBEDDED,STYLESHEET,BANNER,FOOTER,WEBDRIVER); } } if (CSVLIST) { CSV2XML(CSVLIST); } if (strlen(ERASE) > 0) { EraseAverages(); exit(0); } /* Compute summaries */ GrandSummary(); } /*********************************************************************/ /* Level 2 */ /*********************************************************************/ void RemoveHostSeen(char *hosts) { CF_DB *dbp; char name[CF_MAXVARSIZE]; struct Item *ip,*list = SplitStringAsItemList(hosts,','); snprintf(name,sizeof(name),"%s/%s",CFWORKDIR,CF_LASTDB_FILE); MapName(name); if (!OpenDB(name,&dbp)) { CfOut(cf_error, "", "!! Could not open hosts-seen database for removal of hosts"); return; } for (ip = list; ip != NULL; ip=ip->next) { snprintf(name,sizeof(name),"+%s",ip->name); CfOut(cf_inform,""," -> Deleting requested host-seen entry for %s\n",name); if(!DeleteDB(dbp,name)) { CfOut(cf_inform, "", " !! Entry %s not found - skipping", name); } snprintf(name,sizeof(name),"-%s",ip->name); CfOut(cf_inform,""," -> Deleting requested host-seen entry for %s\n",name); if(!DeleteDB(dbp,name)) { CfOut(cf_inform, "", " !! Entry %s not found - skipping", name); } } CloseDB(dbp); DeleteItemList(list); } /*********************************************************************/ void ShowLastSeen() { CF_DB *dbp; CF_DBC *dbcp; char *key; void *value; FILE *fout; time_t tid = time(NULL); double now = (double)tid,average = 0, var = 0; double ticksperhr = (double)SECONDS_PER_HOUR; char name[CF_BUFSIZE],hostname[CF_BUFSIZE],address[CF_MAXVARSIZE]; struct CfKeyHostSeen entry; int ksize,vsize; snprintf(name,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,CF_LASTDB_FILE); MapName(name); if (!OpenDB(name,&dbp)) { return; } if (HTML) { snprintf(name,CF_BUFSIZE,"lastseen.html"); } else if (XML) { snprintf(name,CF_BUFSIZE,"lastseen.xml"); } else if (CSV) { snprintf(name,CF_BUFSIZE,"lastseen.csv"); } else { snprintf(name,CF_BUFSIZE,"lastseen.txt"); } if ((fout = fopen(name,"w")) == NULL) { CfOut(cf_error,"fopen"," !! Unable to write to %s/lastseen.html\n",OUTPUTDIR); exit(1); } if (HTML && !EMBEDDED) { snprintf(name,CF_BUFSIZE,"Peers as last seen by %s",VFQNAME); CfHtmlHeader(fout,name,STYLESHEET,WEBDRIVER,BANNER); fprintf(fout,"<div id=\"reporttext\">\n"); fprintf(fout,"<h4>This report was last updated at %s</h4>",cf_ctime(&tid)); fprintf(fout,"<table class=border cellpadding=5>\n"); } else if (XML) { fprintf(fout,"<?xml version=\"1.0\"?>\n<output>\n"); } /* Acquire a cursor for the database. */ if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan last-seen database"); CloseDB(dbp); return; } /* Initialize the key/data return pair. */ memset(&entry, 0, sizeof(entry)); /* Walk through the database and print out the key/data pairs. */ while(NextDB(dbp,dbcp,&key,&ksize,&value,&vsize)) { double then; time_t fthen; char tbuf[CF_BUFSIZE],addr[CF_BUFSIZE]; memcpy(&then,value,sizeof(then)); if (value != NULL) { memcpy(&entry,value,sizeof(entry)); strncpy(hostname,(char *)key,ksize); strncpy(address,(char *)entry.address,ksize); then = entry.Q.q; average = (double)entry.Q.expect; var = (double)entry.Q.var; strncpy(addr,entry.address,CF_MAXVARSIZE); } else { continue; } if (now - then > (double)LASTSEENEXPIREAFTER) { DeleteDB(dbp,key); CfOut(cf_inform,""," -> Deleting expired entry for %s\n",hostname); continue; } fthen = (time_t)then; /* format date */ snprintf(tbuf,CF_BUFSIZE-1,"%s",cf_ctime(&fthen)); tbuf[strlen(tbuf)-9] = '\0'; /* Chop off second and year */ CfOut(cf_verbose,""," -> Reporting on %s",hostname); if (XML) { fprintf(fout,"%s",CFRX[cfx_entry][cfb]); fprintf(fout,"%s%c%s",CFRX[cfx_pm][cfb],*hostname,CFRX[cfx_pm][cfe]); fprintf(fout,"%s%s%s",CFRX[cfx_host][cfb],hostname+1,CFRX[cfx_host][cfe]); fprintf(fout,"%s%s%s",CFRX[cfx_alias][cfb],IPString2Hostname(address),CFRX[cfx_ip][cfe]); fprintf(fout,"%s%s%s",CFRX[cfx_ip][cfb],address,CFRX[cfx_ip][cfe]); fprintf(fout,"%s%s%s",CFRX[cfx_date][cfb],tbuf,CFRX[cfx_date][cfe]); fprintf(fout,"%s%.2lf%s",CFRX[cfx_q][cfb],((double)(now-then))/ticksperhr,CFRX[cfx_q][cfe]); fprintf(fout,"%s%.2lf%s",CFRX[cfx_av][cfb],average/ticksperhr,CFRX[cfx_av][cfe]); fprintf(fout,"%s%.2lf%s",CFRX[cfx_dev][cfb],sqrt(var)/ticksperhr,CFRX[cfx_dev][cfe]); fprintf(fout,"%s",CFRX[cfx_entry][cfe]); } else if (HTML) { fprintf(fout,"%s",CFRH[cfx_entry][cfb]); if (*hostname == '+') { fprintf(fout,"%s out (%c)%s",CFRH[cfx_pm][cfb],*hostname,CFRH[cfx_pm][cfe]); } else { fprintf(fout,"%s in (%c)%s",CFRH[cfx_pm][cfb],*hostname,CFRH[cfx_pm][cfe]); } fprintf(fout,"%s%s%s",CFRH[cfx_host][cfb],hostname+1,CFRH[cfx_host][cfe]); fprintf(fout,"%s%s%s",CFRH[cfx_ip][cfb],address,CFRH[cfx_ip][cfe]); fprintf(fout,"%s%s%s",CFRH[cfx_alias][cfb],IPString2Hostname(address),CFRH[cfx_ip][cfe]); fprintf(fout,"%s Last seen at %s%s",CFRH[cfx_date][cfb],tbuf,CFRH[cfx_date][cfe]); fprintf(fout,"%s %.2lf hrs ago %s",CFRH[cfx_q][cfb],((double)(now-then))/ticksperhr,CFRH[cfx_q][cfe]); fprintf(fout,"%s Av %.2lf hrs %s",CFRH[cfx_av][cfb],average/ticksperhr,CFRH[cfx_av][cfe]); fprintf(fout,"%s ± %.2lf hrs %s",CFRH[cfx_dev][cfb],sqrt(var)/ticksperhr,CFRH[cfx_dev][cfe]); fprintf(fout,"%s",CFRH[cfx_entry][cfe]); } else if (CSV) { fprintf(fout,"%c,%25.25s,%25.25s,%15.15s,%s,%.2lf,%.2lf,%.2lf hrs\n", *hostname, hostname+1, IPString2Hostname(address), addr, tbuf, ((double)(now-then))/ticksperhr, average/ticksperhr, sqrt(var)/ticksperhr); } else { fprintf(fout,"IP %c %25.25s %25.25s %15.15s @ [%s] not seen for (%.2lf) hrs, Av %.2lf +/- %.2lf hrs\n", *hostname, hostname+1, IPString2Hostname(address), addr, tbuf, ((double)(now-then))/ticksperhr, average/ticksperhr, sqrt(var)/ticksperhr); } } if (HTML && !EMBEDDED) { fprintf(fout,"</table></div>\n"); CfHtmlFooter(fout,FOOTER); } if (XML) { fprintf(fout,"</output>\n"); } DeleteDBCursor(dbp,dbcp); CloseDB(dbp); fclose(fout); } /*******************************************************************/ void ShowPerformance() { CF_DB *dbp; CF_DBC *dbcp; char *key; void *value; FILE *fout; double now = (double)time(NULL),average = 0, var = 0; double ticksperminute = 60.0; char name[CF_BUFSIZE],eventname[CF_BUFSIZE]; struct Event entry; int ksize,vsize; snprintf(name,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,CF_PERFORMANCE); if (!OpenDB(name,&dbp)) { return; } /* Acquire a cursor for the database. */ if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan hash database"); return; } if (HTML) { snprintf(name,CF_BUFSIZE,"performance.html"); } else if (XML) { snprintf(name,CF_BUFSIZE,"performance.xml"); } else if (CSV) { snprintf(name,CF_BUFSIZE,"performance.csv"); } else { snprintf(name,CF_BUFSIZE,"performance.txt"); } if ((fout = fopen(name,"w")) == NULL) { CfOut(cf_error,"fopen"," !! Unable to write to %s/%s\n",OUTPUTDIR,name); exit(1); } /* Initialize the key/data return pair. */ memset(&key, 0, sizeof(key)); memset(&value, 0, sizeof(value)); memset(&entry, 0, sizeof(entry)); if (HTML && !EMBEDDED) { snprintf(name,CF_BUFSIZE,"Promises last kept by %s",VFQNAME); CfHtmlHeader(fout,name,STYLESHEET,WEBDRIVER,BANNER); fprintf(fout,"<div id=\"reporttext\">\n"); fprintf(fout,"<table class=border cellpadding=5>\n"); } if (XML) { fprintf(fout,"<?xml version=\"1.0\"?>\n<output>\n"); } /* Walk through the database and print out the key/data pairs. */ while(NextDB(dbp,dbcp,&key,&ksize,&value,&vsize)) { double measure; time_t then; char tbuf[CF_BUFSIZE]; memcpy(&then,value,sizeof(then)); strncpy(eventname,(char *)key,ksize); if (value != NULL) { memcpy(&entry,value,sizeof(entry)); then = entry.t; measure = entry.Q.q/ticksperminute; average = entry.Q.expect/ticksperminute; var = entry.Q.var; snprintf(tbuf,CF_BUFSIZE-1,"%s",cf_ctime(&then)); tbuf[strlen(tbuf)-9] = '\0'; /* Chop off second and year */ if (PURGE == 'y') { if (now - then > CF_WEEK) { DeleteDB(dbp,key); } CfOut(cf_inform,"","Deleting expired entry for %s\n",eventname); if (measure < 0 || average < 0 || measure > 4*CF_WEEK) { DeleteDB(dbp,key); } CfOut(cf_inform,""," -> Deleting entry for %s because it seems to take longer than 4 weeks to complete\n",eventname); continue; } if (XML) { fprintf(fout,"%s",CFRX[cfx_entry][cfb]); fprintf(fout,"%s%s%s",CFRX[cfx_event][cfb],eventname,CFRX[cfx_event][cfe]); fprintf(fout,"%s%s%s",CFRX[cfx_date][cfb],tbuf,CFRX[cfx_date][cfe]); fprintf(fout,"%s%.4lf%s",CFRX[cfx_q][cfb],measure,CFRX[cfx_q][cfe]); fprintf(fout,"%s%.4lf%s",CFRX[cfx_av][cfb],average,CFRX[cfx_av][cfe]); fprintf(fout,"%s%.4lf%s",CFRX[cfx_dev][cfb],sqrt(var)/ticksperminute,CFRX[cfx_dev][cfe]); fprintf(fout,"%s",CFRX[cfx_entry][cfe]); } else if (HTML) { fprintf(fout,"%s",CFRH[cfx_entry][cfb]); fprintf(fout,"%s%s%s",CFRH[cfx_event][cfb],eventname,CFRH[cfx_event][cfe]); fprintf(fout,"%s last performed at %s%s",CFRH[cfx_date][cfb],tbuf,CFRH[cfx_date][cfe]); fprintf(fout,"%s completed in %.4lf mins %s",CFRH[cfx_q][cfb],measure,CFRH[cfx_q][cfe]); fprintf(fout,"%s Av %.4lf mins %s",CFRH[cfx_av][cfb],average,CFRH[cfx_av][cfe]); fprintf(fout,"%s ± %.4lf mins %s",CFRH[cfx_dev][cfb],sqrt(var)/ticksperminute,CFRH[cfx_dev][cfe]); fprintf(fout,"%s",CFRH[cfx_entry][cfe]); } else if (CSV) { fprintf(fout,"%7.4lf,%s,%7.4lf,%7.4lf,%s \n",measure,tbuf,average,sqrt(var)/ticksperminute,eventname); } else { fprintf(fout,"(%7.4lf mins @ %s) Av %7.4lf +/- %7.4lf for %s \n",measure,tbuf,average,sqrt(var)/ticksperminute,eventname); } } else { continue; } } if (HTML && !EMBEDDED) { fprintf(fout,"</table>"); fprintf(fout,"</div>\n"); CfHtmlFooter(fout,FOOTER); } if (XML) { fprintf(fout,"</output>\n"); } DeleteDBCursor(dbp,dbcp); CloseDB(dbp); fclose(fout); } /*******************************************************************/ void ShowClasses() { CF_DB *dbp; CF_DBC *dbcp; char *key; void *value; FILE *fout,*fnotes; struct Item *already = NULL,*ip; double now = (double)time(NULL),average = 0, var = 0; char name[CF_BUFSIZE],eventname[CF_BUFSIZE]; struct Event entry; struct CEnt array[1024]; int i,ksize,vsize; snprintf(name,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,CF_CLASSUSAGE); MapName(name); if (!OpenDB(name,&dbp)) { return; } /* Acquire a cursor for the database. */ if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan class db"); return; } if (HTML) { snprintf(name,CF_BUFSIZE,"classes.html"); } else if (XML) { snprintf(name,CF_BUFSIZE,"classes.xml"); } else if (CSV) { snprintf(name,CF_BUFSIZE,"classes.csv"); } else { snprintf(name,CF_BUFSIZE,"classes.txt"); } if ((fout = fopen(name,"w")) == NULL) { CfOut(cf_error,"fopen"," !! Unable to write to %s/%s\n",OUTPUTDIR,name); exit(1); } /* Initialize the key/data return pair. */ memset(&entry, 0, sizeof(entry)); if (HTML && !EMBEDDED) { time_t now = time(NULL); snprintf(name,CF_BUFSIZE,"Classes last observed on %s at %s",VFQNAME,cf_ctime(&now)); CfHtmlHeader(fout,name,STYLESHEET,WEBDRIVER,BANNER); fprintf(fout,"<div id=\"reporttext\">\n"); fprintf(fout,"<h4>Soft classes</h4>"); fprintf(fout,"<table class=\"border\" cellpadding=\"5\">\n"); } if (XML) { fprintf(fout,"<?xml version=\"1.0\"?>\n<output>\n"); } /* Walk through the database and print out the key/data pairs. */ for (i = 0; i < 1024; i++) { *(array[i].name) = '\0'; array[i].q = -1; } i = 0; while(NextDB(dbp,dbcp,&key,&ksize,&value,&vsize)) { double measure; time_t then; char tbuf[CF_BUFSIZE]; memcpy(&then,value,sizeof(then)); strncpy(eventname,(char *)key,CF_BUFSIZE-1); if (value != NULL) { memcpy(&entry,value,sizeof(entry)); then = entry.t; measure = entry.Q.q; average = entry.Q.expect; var = entry.Q.var; snprintf(tbuf,CF_BUFSIZE-1,"%s",cf_ctime(&then)); tbuf[strlen(tbuf)-9] = '\0'; /* Chop off second and year */ if (PURGE == 'y') { if (now - then > CF_WEEK*52) { DeleteDB(dbp,key); } CfOut(cf_error,""," -> Deleting expired entry for %s\n",eventname); continue; } if (i++ < 1024) { strncpy(array[i].date,tbuf,31); strncpy(array[i].name,eventname,254); array[i].q = average; array[i].d = var; } else { break; } } } #ifdef HAVE_QSORT qsort(array,1024,sizeof(struct CEnt),CompareClasses); #endif if ((fnotes = fopen("class_notes","w")) == NULL) { CfOut(cf_error,"fopen"," !! Unable to write to %s/class_notes\n",OUTPUTDIR); exit(1); } for (i = 0; i < 1024; i++) { if (array[i].q <= 0.00001) { continue; } fprintf(fnotes,"%s %.4lf\n",array[i].name,array[i].q); PrependItem(&already,array[i].name,NULL); if (XML) { fprintf(fout,"%s",CFRX[cfx_entry][cfb]); fprintf(fout,"%s%s%s",CFRX[cfx_event][cfb],array[i].name,CFRX[cfx_event][cfe]); fprintf(fout,"%s%s%s",CFRX[cfx_date][cfb],array[i].date,CFRX[cfx_date][cfe]); fprintf(fout,"%s%.4lf%s",CFRX[cfx_av][cfb],array[i].q,CFRX[cfx_av][cfe]); fprintf(fout,"%s%.4lf%s",CFRX[cfx_dev][cfb],sqrt(array[i].d),CFRX[cfx_dev][cfe]); fprintf(fout,"%s",CFRX[cfx_entry][cfe]); } else if (HTML) { fprintf(fout,"%s",CFRH[cfx_entry][cfb]); fprintf(fout,"%s%s%s",CFRH[cfx_event][cfb],array[i].name,CFRH[cfx_event][cfe]); fprintf(fout,"%s last occured at %s%s",CFRH[cfx_date][cfb],array[i].date,CFRH[cfx_date][cfe]); fprintf(fout,"%s Probability %.4lf %s",CFRH[cfx_av][cfb],array[i].q,CFRH[cfx_av][cfe]); fprintf(fout,"%s ± %.4lf %s",CFRH[cfx_dev][cfb],sqrt(array[i].d),CFRH[cfx_dev][cfe]); fprintf(fout,"%s",CFRH[cfx_entry][cfe]); } else if (CSV) { fprintf(fout,"%7.4lf,%7.4lf,%s,%s\n",array[i].q,sqrt(array[i].d),array[i].name,array[i].date); } else { fprintf(fout,"Probability %7.4lf +/- %7.4lf for %s (last observed @ %s)\n",array[i].q,sqrt(array[i].d),array[i].name,array[i].date); } } if (HTML && !EMBEDDED) { fprintf(fout,"</table>"); fprintf(fout,"<h4>All classes</h4>\n"); fprintf(fout,"<table class=\"border\" cellpadding=\"5\">\n"); } for (i = 0; i < CF_ALPHABETSIZE; i++) { for (ip = VHEAP.list[i]; ip != NULL; ip=ip->next) { if (IsItemIn(already,ip->name)) { continue; } if (strncmp(ip->name,"Min",3) == 0 || strncmp(ip->name,"Hr",2) == 0 || strncmp(ip->name,"Q",1) == 0 || strncmp(ip->name,"Yr",1) == 0 || strncmp(ip->name,"Day",1) == 0 || strncmp(ip->name,"Morning",1) == 0 || strncmp(ip->name,"Afternoon",1) == 0 || strncmp(ip->name,"Evening",1) == 0 || strncmp(ip->name,"Night",1) == 0) { continue; } if (XML) { fprintf(fout,"%s",CFRX[cfx_entry][cfb]); fprintf(fout,"%s%s%s",CFRX[cfx_event][cfb],ip->name,CFRX[cfx_event][cfe]); fprintf(fout,"%s%s%s",CFRX[cfx_date][cfb],"often",CFRX[cfx_date][cfe]); fprintf(fout,"%s%.4lf%s",CFRX[cfx_av][cfb],1.0,CFRX[cfx_av][cfe]); fprintf(fout,"%s%.4lf%s",CFRX[cfx_dev][cfb],0.0,CFRX[cfx_dev][cfe]); fprintf(fout,"%s",CFRX[cfx_entry][cfe]); } else if (HTML) { fprintf(fout,"%s",CFRH[cfx_entry][cfb]); fprintf(fout,"%s%s%s",CFRH[cfx_event][cfb],ip->name,CFRH[cfx_event][cfe]); fprintf(fout,"%s occurred %s%s",CFRH[cfx_date][cfb],"often",CFRH[cfx_date][cfe]); fprintf(fout,"%s Probability %.4lf %s",CFRH[cfx_av][cfb],1.0,CFRH[cfx_av][cfe]); fprintf(fout,"%s ± %.4lf %s",CFRH[cfx_dev][cfb],0.0,CFRH[cfx_dev][cfe]); fprintf(fout,"%s",CFRH[cfx_entry][cfe]); } else if (CSV) { fprintf(fout,"%7.4lf,%7.4lf,%s,%s\n",1.0,0.0,ip->name,"often"); } } } if (HTML && !EMBEDDED) { fprintf(fout,"</table>"); fprintf(fout,"</div>\n"); CfHtmlFooter(fout,FOOTER); } if (XML) { fprintf(fout,"</output>\n"); } DeleteDBCursor(dbp,dbcp); CloseDB(dbp); fclose(fout); fclose(fnotes); DeleteItemList(already); } /*******************************************************************/ void ShowChecksums() { CF_DB *dbp; CF_DBC *dbcp; char *key; void *value; int ksize,vsize; FILE *fout; char checksumdb[CF_BUFSIZE],name[CF_BUFSIZE]; snprintf(checksumdb,CF_BUFSIZE,"%s/%s",CFWORKDIR,CF_CHKDB); if (!OpenDB(checksumdb,&dbp)) { return; } if (HTML) { snprintf(name,CF_BUFSIZE,"hashes.html"); } else if (XML) { snprintf(name,CF_BUFSIZE,"hashes.xml"); } else if (CSV) { snprintf(name,CF_BUFSIZE,"hashes.csv"); } else { snprintf(name,CF_BUFSIZE,"hashes.txt"); } if ((fout = fopen(name,"w")) == NULL) { CfOut(cf_error,"fopen"," !! Unable to write to %s/%s\n",OUTPUTDIR,name); exit(1); } if (HTML && !EMBEDDED) { CfHtmlHeader(fout,"File hashes",STYLESHEET,WEBDRIVER,BANNER); fprintf(fout,"<div id=\"reporttext\">\n"); fprintf(fout,"<table class=border cellpadding=5>\n"); } if (XML) { fprintf(fout,"<?xml version=\"1.0\"?>\n<output>\n"); } /* Acquire a cursor for the database. */ if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan checksum db"); CloseDB(dbp); return; } while(NextDB(dbp,dbcp,&key,&ksize,&value,&vsize)) { enum cfhashes type; char strtype[CF_MAXVARSIZE]; char name[CF_BUFSIZE]; struct Checksum_Value chk_val; unsigned char digest[EVP_MAX_MD_SIZE+1]; memcpy(&chk_val,value,sizeof(chk_val)); memcpy(digest,chk_val.mess_digest,EVP_MAX_MD_SIZE+1); strncpy(strtype,key,CF_INDEX_FIELD_LEN); strncpy(name,(char *)key+CF_INDEX_OFFSET,CF_BUFSIZE-1); type = String2HashType(strtype); if (XML) { fprintf(fout,"%s",CFRX[cfx_entry][cfb]); fprintf(fout,"%s%s%s",CFRX[cfx_event][cfb],name,CFRX[cfx_event][cfe]); fprintf(fout,"%s%s%s",CFRX[cfx_q][cfb],HashPrint(type,digest),CFRX[cfx_q][cfe]); fprintf(fout,"%s",CFRX[cfx_entry][cfe]); } else if (HTML) { fprintf(fout,"%s",CFRH[cfx_entry][cfb]); fprintf(fout,"%s%s%s",CFRH[cfx_filename][cfb],name,CFRH[cfx_filename][cfe]); fprintf(fout,"%s%s%s",CFRH[cfx_q][cfb],HashPrint(type,digest),CFRH[cfx_q][cfe]); fprintf(fout,"%s",CFRH[cfx_entry][cfe]); } else if (CSV) { fprintf(fout,"%s,",name); fprintf(fout,"%s\n",HashPrint(type,digest)); } else { fprintf(fout,"%s = ",name); fprintf(fout,"%s\n",HashPrint(type,digest)); } memset(&key,0,sizeof(key)); memset(&value,0,sizeof(value)); } if (HTML && !EMBEDDED) { fprintf(fout,"</table>"); fprintf(fout,"</div>\n"); CfHtmlFooter(fout,FOOTER); } if (XML) { fprintf(fout,"</output>\n"); } DeleteDBCursor(dbp,dbcp); CloseDB(dbp); fclose(fout); } /*********************************************************************/ void ShowLocks (int active) { CF_DB *dbp; CF_DBC *dbcp; char *key; void *value; FILE *fout; int ksize,vsize; char lockdb[CF_BUFSIZE],name[CF_BUFSIZE]; struct LockData entry; snprintf(lockdb,CF_BUFSIZE,"%s/state/%s",CFWORKDIR, CF_LOCKDB_FILE); MapName(lockdb); if (!OpenDB(lockdb,&dbp)) { return; } if (active) { snprintf(lockdb,CF_MAXVARSIZE,"active"); } else { snprintf(lockdb,CF_MAXVARSIZE,"all"); } if (HTML) { snprintf(name,CF_BUFSIZE,"%s_locks.html",lockdb); } else if (XML) { snprintf(name,CF_BUFSIZE,"%s_locks.xml",lockdb); } else if (CSV) { snprintf(name,CF_BUFSIZE,"%s_locks.csv",lockdb); } else { snprintf(name,CF_BUFSIZE,"%s_locks.txt",lockdb); } if ((fout = fopen(name,"w")) == NULL) { CfOut(cf_error,"fopen"," !! Unable to write to %s/%s\n",OUTPUTDIR,name); CloseDB(dbp); return; } if (HTML && !EMBEDDED) { time_t now = time(NULL); snprintf(name,CF_BUFSIZE,"%s lock data observed on %s at %s",lockdb,VFQNAME,cf_ctime(&now)); CfHtmlHeader(fout,name,STYLESHEET,WEBDRIVER,BANNER); fprintf(fout,"<div id=\"reporttext\">\n"); fprintf(fout,"<table class=border cellpadding=5>\n"); } if (XML) { fprintf(fout,"<?xml version=\"1.0\"?>\n<output>\n"); } /* Acquire a cursor for the database. */ if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan last-seen db"); CloseDB(dbp); fclose(fout); return; } while(NextDB(dbp,dbcp,&key,&ksize,&value,&vsize)) { if (active) { if (value != NULL) { memcpy(&entry,value,sizeof(entry)); } if (strncmp("lock",(char *)key,4) == 0) { if (XML) { fprintf(fout,"%s",CFRX[cfx_entry][cfb]); fprintf(fout,"%s%s%s",CFRX[cfx_filename][cfb],(char *)key,CFRX[cfx_filename][cfe]); fprintf(fout,"%s%s%s",CFRX[cfx_date][cfb],cf_ctime(&entry.time),CFRX[cfx_date][cfe]); fprintf(fout,"%s",CFRX[cfx_entry][cfe]); } else if (HTML) { fprintf(fout,"%s",CFRH[cfx_entry][cfb]); fprintf(fout,"%s%s%s",CFRH[cfx_filename][cfb],(char *)key,CFRH[cfx_filename][cfe]); fprintf(fout,"%s%s%s",CFRH[cfx_date][cfb],cf_ctime(&entry.time),CFRH[cfx_date][cfe]); fprintf(fout,"%s",CFRH[cfx_entry][cfe]); } else { fprintf(fout,"%s = ",(char *)key); fprintf(fout,"%s\n",cf_ctime(&entry.time)); } CfOut(cf_inform,"","Active lock %s = ",(char *)key); } } else { if (strncmp("last",(char *)key,4) == 0) { if (XML) { fprintf(fout,"%s",CFRX[cfx_entry][cfb]); fprintf(fout,"%s%s%s",CFRX[cfx_filename][cfb],(char *)key,CFRX[cfx_filename][cfe]); fprintf(fout,"%s%s%s",CFRX[cfx_date][cfb],cf_ctime(&entry.time),CFRX[cfx_date][cfe]); fprintf(fout,"%s",CFRX[cfx_entry][cfe]); } else if (HTML) { fprintf(fout,"%s",CFRH[cfx_entry][cfb]); fprintf(fout,"%s%s%s",CFRH[cfx_filename][cfb],(char *)key,CFRH[cfx_filename][cfe]); fprintf(fout,"%s%s%s",CFRH[cfx_date][cfb],cf_ctime(&entry.time),CFRH[cfx_date][cfe]); fprintf(fout,"%s",CFRH[cfx_entry][cfe]); } else if (CSV) { fprintf(fout,"%s",(char *)key); fprintf(fout,",%s\n",cf_ctime(&entry.time)); } else { fprintf(fout,"%s = ",(char *)key); fprintf(fout,"%s\n",cf_ctime(&entry.time)); } } } } if (HTML && !EMBEDDED) { fprintf(fout,"</table>"); fprintf(fout,"</div>\n"); CfHtmlFooter(fout,FOOTER); } if (XML) { fprintf(fout,"</output>\n"); } DeleteDBCursor(dbp,dbcp); CloseDB(dbp); fclose(fout); } /*******************************************************************/ void ShowCurrentAudit() { char operation[CF_BUFSIZE],name[CF_BUFSIZE]; struct AuditLog entry; FILE *fout; char *key; void *value; CF_DB *dbp; CF_DBC *dbcp; int ksize,vsize; snprintf(name,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,CF_AUDITDB_FILE); MapName(name); if (!OpenDB(name,&dbp)) { return; } /* Acquire a cursor for the database. */ if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan last-seen db"); return; } memset(&entry, 0, sizeof(entry)); if (HTML) { snprintf(name,CF_BUFSIZE,"audit.html"); } else if (XML) { snprintf(name,CF_BUFSIZE,"audit.xml"); } else if (CSV) { snprintf(name,CF_BUFSIZE,"audit.csv"); } else { snprintf(name,CF_BUFSIZE,"audit.txt"); } if ((fout = fopen(name,"w")) == NULL) { CfOut(cf_error,"fopen","Unable to write to %s/%s\n",OUTPUTDIR,name); return; } if (HTML && !EMBEDDED) { time_t now = time(NULL); snprintf(name,CF_BUFSIZE,"Audit collected on %s at %s",VFQNAME,cf_ctime(&now)); CfHtmlHeader(fout,name,STYLESHEET,WEBDRIVER,BANNER); fprintf(fout,"<table class=border cellpadding=5>\n"); /* fprintf(fout,"<th> t-index </th>");*/ fprintf(fout,"<th> Scan convergence </th>"); fprintf(fout,"<th> Observed </th>"); fprintf(fout,"<th> Promise made </th>"); fprintf(fout,"<th> Promise originates in </th>"); fprintf(fout,"<th> Promise version </th>"); fprintf(fout,"<th> line </th>"); } if (XML) { fprintf(fout,"<?xml version=\"1.0\"?>\n<output>\n"); } /* Walk through the database and print out the key/data pairs. */ while(NextDB(dbp,dbcp,&key,&ksize,&value,&vsize)) { strncpy(operation,(char *)key,CF_BUFSIZE-1); if (value != NULL) { memcpy(&entry,value,sizeof(entry)); if (XML) { fprintf(fout,"%s",CFRX[cfx_entry][cfb]); fprintf(fout,"%s %s %s",CFRX[cfx_index][cfb],operation,CFRX[cfx_index][cfe]); fprintf(fout,"%s %s, ",CFRX[cfx_event][cfb],entry.operator); AuditStatusMessage(fout,entry.status); fprintf(fout,"%s",CFRX[cfx_event][cfe]); fprintf(fout,"%s %s %s",CFRX[cfx_q][cfb],entry.comment,CFRX[cfx_q][cfe]); fprintf(fout,"%s %s %s",CFRX[cfx_date][cfb],entry.date,CFRX[cfx_date][cfe]); fprintf(fout,"%s %s %s",CFRX[cfx_av][cfb],entry.filename,CFRX[cfx_av][cfe]); fprintf(fout,"%s %s %s",CFRX[cfx_version][cfb],entry.version,CFRX[cfx_version][cfe]); fprintf(fout,"%s %d %s",CFRX[cfx_ref][cfb],entry.lineno,CFRX[cfx_ref][cfe]); fprintf(fout,"%s",CFRX[cfx_entry][cfe]); } else if (HTML) { fprintf(fout,"%s",CFRH[cfx_entry][cfb]); /* fprintf(fout,"%s %s %s",CFRH[cfx_index][cfb],operation,CFRH[cfx_index][cfe]);*/ fprintf(fout,"%s %s, ",CFRH[cfx_event][cfb],Format(entry.operator,40)); AuditStatusMessage(fout,entry.status); fprintf(fout,"%s",CFRH[cfx_event][cfe]); fprintf(fout,"%s %s %s",CFRH[cfx_q][cfb],Format(entry.comment,40),CFRH[cfx_q][cfe]); fprintf(fout,"%s %s %s",CFRH[cfx_date][cfb],entry.date,CFRH[cfx_date][cfe]); fprintf(fout,"%s %s %s",CFRH[cfx_av][cfb],entry.filename,CFRH[cfx_av][cfe]); fprintf(fout,"%s %s %s",CFRH[cfx_version][cfb],entry.version,CFRH[cfx_version][cfe]); fprintf(fout,"%s %d %s",CFRH[cfx_ref][cfb],entry.lineno,CFRH[cfx_ref][cfe]); fprintf(fout,"%s",CFRH[cfx_entry][cfe]); if (strstr(entry.comment,"closing")) { fprintf(fout,"<th></th>"); fprintf(fout,"<th></th>"); fprintf(fout,"<th></th>"); fprintf(fout,"<th></th>"); fprintf(fout,"<th></th>"); fprintf(fout,"<th></th>"); fprintf(fout,"<th></th>"); } } else if (CSV) { fprintf(fout,"%s,",operation); fprintf(fout,"%s,",entry.operator); AuditStatusMessage(fout,entry.status); /* Reminder */ if (strlen(entry.comment) > 0) { fprintf(fout,",%s\n",entry.comment); } if (strcmp(entry.filename,"Terminal") == 0) { } else { if (strlen(entry.version) == 0) { fprintf(fout,",%s,,%s,%d\n",entry.filename,entry.date,entry.lineno); } else { fprintf(fout,",%s,%s,%s,%d\n",entry.filename,entry.version,entry.date,entry.lineno); } } } else { fprintf(fout,". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n"); fprintf(fout,"Operation index: \'%s\'\n",operation); fprintf(fout,"Converge \'%s\' ",entry.operator); AuditStatusMessage(fout,entry.status); /* Reminder */ if (strlen(entry.comment) > 0) { fprintf(fout,"Comment: %s\n",entry.comment); } if (strcmp(entry.filename,"Terminal") == 0) { if (strstr(entry.comment,"closing")) { fprintf(fout,"\n===============================================================================================\n\n"); } } else { if (strlen(entry.version) == 0) { fprintf(fout,"Promised in %s (unamed version last edited at %s) at/before line %d\n",entry.filename,entry.date,entry.lineno); } else { fprintf(fout,"Promised in %s (version %s last edited at %s) at/before line %d\n",entry.filename,entry.version,entry.date,entry.lineno); } } } } else { continue; } } if (HTML && !EMBEDDED) { fprintf(fout,"</table>"); CfHtmlFooter(fout,FOOTER); } if (XML) { fprintf(fout,"</output>\n"); } DeleteDBCursor(dbp,dbcp); CloseDB(dbp); fclose(fout); } /*********************************************************************/ /* Level 3 */ /*********************************************************************/ char *Format(char *s,int width) { static char buffer[CF_BUFSIZE]; char *sp; int i = 0, count = 0; for (sp = s; *sp != '\0'; sp++) { buffer[i++] = *sp; buffer[i] = '\0'; count++; if ((count > width - 5) && ispunct(*sp)) { strcat(buffer,"<br>"); i += strlen("<br>"); count = 0; } } return buffer; } /*************************************************************/ int CompareClasses(const void *a, const void *b) { struct CEnt *da = (struct CEnt *) a; struct CEnt *db = (struct CEnt *) b; return (da->q < db->q) - (da->q > db->q); } /****************************************************************************/ void ReadAverages() { struct Averages entry; char timekey[CF_MAXVARSIZE]; time_t now; CF_DB *dbp; int i; CfOut(cf_verbose,"","\nLooking for database %s\n",VINPUTFILE); CfOut(cf_verbose,"","\nFinding MAXimum values...\n\n"); CfOut(cf_verbose,"","N.B. socket values are numbers in CLOSE_WAIT. See documentation.\n"); if (!OpenDB(VINPUTFILE,&dbp)) { CfOut(cf_verbose,"","Couldn't open average database %s\n",VINPUTFILE); return; } for (i = 0; i < CF_OBSERVABLES; i++) { MAX.Q[i].var = MAX.Q[i].expect = MAX.Q[i].q = 0.01; MIN.Q[i].var = MIN.Q[i].expect = MIN.Q[i].q = 9999.0; FPE[i] = FPQ[i] = NULL; } for (now = CF_MONDAY_MORNING; now < CF_MONDAY_MORNING+CF_WEEK; now += CF_MEASURE_INTERVAL) { strcpy(timekey,GenTimeKey(now)); if (ReadDB(dbp,timekey,&entry,sizeof(struct Averages))) { for (i = 0; i < CF_OBSERVABLES; i++) { if (fabs(entry.Q[i].expect) > MAX.Q[i].expect) { MAX.Q[i].expect = fabs(entry.Q[i].expect); } if (fabs(entry.Q[i].q) > MAX.Q[i].q) { MAX.Q[i].q = fabs(entry.Q[i].q); } if (fabs(entry.Q[i].expect) < MIN.Q[i].expect) { MIN.Q[i].expect = fabs(entry.Q[i].expect); } if (fabs(entry.Q[i].q) < MIN.Q[i].q) { MIN.Q[i].q = fabs(entry.Q[i].q); } } } } CloseDB(dbp); } /****************************************************************************/ void EraseAverages() { int i; char timekey[CF_MAXVARSIZE],name[CF_MAXVARSIZE]; struct Item *list = NULL; struct Averages entry; time_t now; CF_DB *dbp; CfOut(cf_verbose,"","\nLooking through current database %s\n",VINPUTFILE); list = SplitStringAsItemList(ERASE,','); if (!OpenDB(VINPUTFILE,&dbp)) { CfOut(cf_verbose,"","Couldn't open average database %s\n",VINPUTFILE); return; } for (i = 0; i < CF_OBSERVABLES; i++) { FPE[i] = FPQ[i] = NULL; } for (now = CF_MONDAY_MORNING; now < CF_MONDAY_MORNING+CF_WEEK; now += CF_MEASURE_INTERVAL) { strcpy(timekey,GenTimeKey(now)); if (ReadDB(dbp,timekey,&entry,sizeof(struct Averages))) { for (i = 0; i < CF_OBSERVABLES; i++) { LookUpClassName(i,name); if (IsItemIn(list,name)) { /* Set history but not most recent to zero */ entry.Q[i].expect = 0; entry.Q[i].var = 0; entry.Q[i].q = 0; } } WriteDB(dbp,timekey,&entry,sizeof(struct Averages)); } } CloseDB(dbp); } /*****************************************************************************/ void SummarizeAverages() { int i; FILE *fout; char name[CF_BUFSIZE]; CF_DB *dbp; Banner("Summarizing monitor averages"); if (HTML) { snprintf(name,CF_BUFSIZE,"monitor_summary.html"); } else if (XML) { snprintf(name,CF_BUFSIZE,"monitor_summary.xml"); } else if (CSV) { snprintf(name,CF_BUFSIZE,"monitor_summary.csv"); } else { snprintf(name,CF_BUFSIZE,"monitor_summary.txt"); } if ((fout = fopen(name,"w")) == NULL) { CfOut(cf_error,"fopen","Unable to write to %s/%s\n",OUTPUTDIR,name); return; } if (HTML && !EMBEDDED) { snprintf(name,CF_BUFSIZE,"Monitor summary for %s",VFQNAME); CfHtmlHeader(fout,name,STYLESHEET,WEBDRIVER,BANNER); fprintf(fout,"<table class=border cellpadding=5>\n"); } else if (XML) { fprintf(fout,"<?xml version=\"1.0\"?>\n<output>\n"); } CfOut(cf_inform,"","Writing report to %s\n",name); for (i = 0; i < CF_OBSERVABLES; i++) { LookUpClassName(i,name); if (XML) { fprintf(fout,"%s",CFRX[cfx_entry][cfb]); fprintf(fout,"%s %s %s",CFRX[cfx_event][cfb],name,CFRX[cfx_event][cfe]); fprintf(fout,"%s %.4lf %s",CFRX[cfx_min][cfb],MIN.Q[i].expect,CFRX[cfx_min][cfe]); fprintf(fout,"%s %.4lf %s",CFRX[cfx_max][cfb],MAX.Q[i].expect,CFRX[cfx_max][cfe]); fprintf(fout,"%s %.4lf %s",CFRX[cfx_dev][cfb],sqrt(MAX.Q[i].var),CFRX[cfx_dev][cfe]); fprintf(fout,"%s",CFRX[cfx_entry][cfe]); } else if (HTML) { fprintf(fout,"%s\n",CFRH[cfx_entry][cfb]); fprintf(fout,"%s %s %s\n",CFRH[cfx_event][cfb],name,CFRH[cfx_event][cfe]); fprintf(fout,"%s Min %.4lf %s\n",CFRH[cfx_min][cfb],MIN.Q[i].expect,CFRH[cfx_min][cfe]); fprintf(fout,"%s Max %.4lf %s\n",CFRH[cfx_max][cfb],MAX.Q[i].expect,CFRH[cfx_max][cfe]); fprintf(fout,"%s %.4lf %s\n",CFRH[cfx_dev][cfb],sqrt(MAX.Q[i].var),CFRH[cfx_dev][cfe]); fprintf(fout,"%s\n",CFRH[cfx_entry][cfe]); } else if (CSV) { fprintf(fout,"%2d,%-10s,%10lf,%10lf,%10lf\n",i,name,MIN.Q[i].expect,MAX.Q[i].expect,sqrt(MAX.Q[i].var)); } else { fprintf(fout,"%2d. MAX <%-10s-in> = %10lf - %10lf u %10lf\n",i,name,MIN.Q[i].expect,MAX.Q[i].expect,sqrt(MAX.Q[i].var)); } } if (!OpenDB(VINPUTFILE,&dbp)) { CfOut(cf_error,"","Could not open %s",VINPUTFILE); return; } if (ReadDB(dbp,"DATABASE_AGE",&AGE,sizeof(double))) { CfOut(cf_inform,""," ?? Database age is %.1f (weeks)\n\n",AGE/CF_WEEK*CF_MEASURE_INTERVAL); } CloseDB(dbp); if (HTML && !EMBEDDED) { fprintf(fout,"</table>"); CfHtmlFooter(fout,FOOTER); } if (XML) { fprintf(fout,"</output>\n"); } fclose(fout); } /*****************************************************************************/ void WriteGraphFiles() { int its,i,j,count = 0; double kept = 0, not_kept = 0, repaired = 0; struct Averages entry,det; char timekey[CF_MAXVARSIZE]; time_t now; CF_DB *dbp; CfOut(cf_verbose,""," -> Retrieving data from %s",VINPUTFILE); if (!OpenDB(VINPUTFILE,&dbp)) { CfOut(cf_verbose,"","Couldn't open average database %s\n",VINPUTFILE); return; } OpenFiles(); if (TITLES) { char name[CF_MAXVARSIZE]; for (i = 0; i < CF_OBSERVABLES; i+=2) { LookUpClassName(i,name); fprintf(FPAV,"# Column %d: %s\n",i,name); fprintf(FPVAR,"# Column %d: %s\n",i,name); fprintf(FPNOW,"# Column %d: %s\n",i,name); } fprintf(FPAV,"##############################################\n"); fprintf(FPVAR,"##############################################\n"); fprintf(FPNOW,"##############################################\n"); } if (HIRES) { its = 1; } else { its = 12; } now = CF_MONDAY_MORNING; while (now < CF_MONDAY_MORNING + CF_WEEK) { memset(&entry,0,sizeof(entry)); for (j = 0; j < its; j++) { strcpy(timekey,GenTimeKey(now)); if (ReadDB(dbp,timekey,&det,sizeof(struct Averages))) { for (i = 0; i < CF_OBSERVABLES; i++) { entry.Q[i].expect += det.Q[i].expect/(double)its; entry.Q[i].var += det.Q[i].var/(double)its; entry.Q[i].q += det.Q[i].q/(double)its; } if (NOSCALING) { for (i = 1; i < CF_OBSERVABLES; i++) { MAX.Q[i].expect = 1; MAX.Q[i].q = 1; } } } now += CF_MEASURE_INTERVAL; count++; } /* Output the data in a plethora of files */ fprintf(FPAV,"%d ",count); fprintf(FPVAR,"%d ",count); fprintf(FPNOW,"%d ",count); for (i = 0; i < CF_OBSERVABLES; i++) { fprintf(FPAV,"%.4lf ",entry.Q[i].expect/MAX.Q[i].expect); fprintf(FPVAR,"%.4lf ",entry.Q[i].var/MAX.Q[i].var); fprintf(FPNOW,"%.4lf ",entry.Q[i].q/MAX.Q[i].q); if (entry.Q[i].q > entry.Q[i].expect + 2.0*sqrt(entry.Q[i].var)) { not_kept++; continue; } if (entry.Q[i].q > entry.Q[i].expect + sqrt(entry.Q[i].var)) { repaired++; continue; } if (entry.Q[i].q < entry.Q[i].expect - 2.0*sqrt(entry.Q[i].var)) { not_kept++; continue; } if (entry.Q[i].q < entry.Q[i].expect - sqrt(entry.Q[i].var)) { repaired++; continue; } kept++; } fprintf(FPAV,"\n"); fprintf(FPVAR,"\n"); fprintf(FPNOW,"\n"); for (i = 0; i < CF_OBSERVABLES; i++) { fprintf(FPE[i],"%d %.4lf %.4lf\n",count, entry.Q[i].expect, sqrt(entry.Q[i].var)); /* Use same scaling for Q so graphs can be merged */ fprintf(FPQ[i],"%d %.4lf 0.0\n",count, entry.Q[i].q); } } METER_KEPT[meter_anomalies_day] = 100.0*kept/(kept+repaired+not_kept); METER_REPAIRED[meter_anomalies_day] = 100.0*repaired/(kept+repaired+not_kept); CloseDB(dbp); CloseFiles(); } /*****************************************************************************/ void MagnifyNow() { int its,i,j,count = 0; struct Averages entry,det; time_t now,here_and_now; char timekey[CF_MAXVARSIZE]; CF_DB *dbp; if (!OpenDB(VINPUTFILE,&dbp)) { CfOut(cf_verbose,"","Couldn't open average database %s\n",VINPUTFILE); return; } OpenMagnifyFiles(); its = 1; /* detailed view */ now = time(NULL); here_and_now = now - (time_t)(4 * SECONDS_PER_HOUR); while (here_and_now < now) { memset(&entry,0,sizeof(entry)); for (j = 0; j < its; j++) { strcpy(timekey,GenTimeKey(here_and_now)); if (ReadDB(dbp,timekey,&det,sizeof(struct Averages))) { for (i = 0; i < CF_OBSERVABLES; i++) { entry.Q[i].expect += det.Q[i].expect/(double)its; entry.Q[i].var += det.Q[i].var/(double)its; entry.Q[i].q += det.Q[i].q/(double)its; } if (NOSCALING) { for (i = 1; i < CF_OBSERVABLES; i++) { MAX.Q[i].expect = 1; MAX.Q[i].q = 1; } } } else { CfOut(cf_verbose,""," !! Read failed for "); } here_and_now += CF_MEASURE_INTERVAL; count++; } /* Output q and E/sig data in a plethora of files */ for (i = 0; i < CF_OBSERVABLES; i++) { fprintf(FPM[i],"%d %.4lf %.4lf %.4lf\n",count, entry.Q[i].expect, sqrt(entry.Q[i].var),entry.Q[i].q); } } CloseDB(dbp); CloseMagnifyFiles(); } /*****************************************************************************/ void WriteHistograms() { int i,j,k; int position,day; int weekly[CF_OBSERVABLES][CF_GRAINS]; char filename[CF_BUFSIZE],name[CF_MAXVARSIZE]; FILE *fp; for (i = 0; i < 7; i++) { for (j = 0; j < CF_OBSERVABLES; j++) { for (k = 0; k < CF_GRAINS; k++) { HISTOGRAM[j][i][k] = 0; } } } snprintf(filename,CF_BUFSIZE,"%s/state/histograms",CFWORKDIR); if ((fp = fopen(filename,"r")) == NULL) { CfOut(cf_verbose,"","Unable to load histogram data\n"); return; } for (position = 0; position < CF_GRAINS; position++) { fscanf(fp,"%d ",&position); for (i = 0; i < CF_OBSERVABLES; i++) { for (day = 0; day < 7; day++) { fscanf(fp,"%d ",&(HISTOGRAM[i][day][position])); } weekly[i][position] = 0; } } fclose(fp); if (!HIRES) { /* Smooth daily and weekly histograms */ for (k = 1; k < CF_GRAINS-1; k++) { for (j = 0; j < CF_OBSERVABLES; j++) { for (i = 0; i < 7; i++) { SMOOTHHISTOGRAM[j][i][k] = ((double)(HISTOGRAM[j][i][k-1] + HISTOGRAM[j][i][k] + HISTOGRAM[j][i][k+1]))/3.0; } } } } else { for (k = 1; k < CF_GRAINS-1; k++) { for (j = 0; j < CF_OBSERVABLES; j++) { for (i = 0; i < 7; i++) { SMOOTHHISTOGRAM[j][i][k] = (double) HISTOGRAM[j][i][k]; } } } } for (i = 0; i < CF_OBSERVABLES; i++) { LookUpClassName(i,name); sprintf(filename,"%s.distr",name); if ((FPQ[i] = fopen(filename,"w")) == NULL) { CfOut(cf_inform,"fopen","Couldn't write %s",name); return; } } /* Plot daily and weekly histograms */ for (k = 0; k < CF_GRAINS; k++) { int a; for (j = 0; j < CF_OBSERVABLES; j++) { for (i = 0; i < 7; i++) { weekly[j][k] += (int) (SMOOTHHISTOGRAM[j][i][k]+0.5); } } for (a = 0; a < CF_OBSERVABLES; a++) { fprintf(FPQ[a],"%d %d\n",k,weekly[a][k]); } } for (i = 0; i < CF_OBSERVABLES; i++) { fclose(FPQ[i]); } } /*****************************************************************************/ void DiskArrivals(void) { CFDIR *dirh; FILE *fp; int count = 0, index = 0, i; char filename[CF_BUFSIZE],database[CF_BUFSIZE],timekey[CF_MAXVARSIZE]; double val, maxval = 1.0, *array, grain = 0.0; time_t now; void *value; CF_DB *dbp = NULL; const struct dirent *dirp; if ((array = (double *)malloc((int)CF_WEEK)) == NULL) { CfOut(cf_error,"MALLOC","Memory error"); return; } if ((dirh = OpenDirLocal(CFWORKDIR)) == NULL) { CfOut(cf_error,"opendir","Can't open directory %s\n",CFWORKDIR); free(array); return; } CfOut(cf_verbose,"","\n\nLooking for filesystem arrival process data in %s\n",CFWORKDIR); for (dirp = ReadDir(dirh); dirp != NULL; dirp = ReadDir(dirh)) { if (strncmp(dirp->d_name,"scan:",5) == 0) { CfOut(cf_verbose,"","Found %s - generating X,Y plot\n",dirp->d_name); snprintf(database,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,dirp->d_name); if (!OpenDB(database,&dbp)) { continue; } maxval = 1.0; grain = 0.0; count = 0.0; index = 0; for (now = CF_MONDAY_MORNING; now < CF_MONDAY_MORNING+CF_WEEK; now += CF_MEASURE_INTERVAL) { strcpy(timekey,GenTimeKey(now)); if (ReadDB(dbp,timekey,&value,sizeof(struct Averages))) { grain += (double)*(double *)(value); } else { grain = 0; } if (HIRES) { if (grain > maxval) { maxval = grain; } array[index] = grain; grain = 0.0; index++; } else { if (count % 12 == 0) { if (grain > maxval) { maxval = grain; } array[index] = grain; index++; grain = 0.0; } } count++; } CloseDB(dbp); snprintf(filename,CF_BUFSIZE-1,"%s.cfenv",dirp->d_name); if ((fp = fopen(filename,"w")) == NULL) { CfOut(cf_verbose,"fopen","Unable to open %s for writing\n",filename); CloseDir(dirh); free(array); return; } CfOut(cf_verbose,"","Data points = %d\n",index); for (i = 0; i < index; i++) { if (i > 1 && i < index-1) { val = (array[i-1]+array[i]+array[i+1])/3.0; /* Smoothing */ } else { val = array[i]; } fprintf(fp,"%d %.4lf\n",i,val/maxval*50.0); } fclose(fp); } } if (errno != 0) { CfOut(cf_error, "ReadDir", "Unable to traverse workdir"); } CloseDir(dirh); free(array); } /***************************************************************/ void PeerIntermittency() { CF_DB *dbp; CF_DBC *dbcp; char *key; void *value; int ksize,vsize; FILE *fp1,*fp2; char name[CF_BUFSIZE],hostname[CF_BUFSIZE],timekey[CF_MAXVARSIZE]; char out1[CF_BUFSIZE],out2[CF_BUFSIZE]; struct QPoint entry; struct Item *ip, *hostlist = NULL; double average,var; time_t now = time(NULL), then, lastseen = CF_WEEK; snprintf(name,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,CF_LASTDB_FILE); MapName(name); average = (double) CF_HOUR; /* It will take a week for a host to be deemed reliable */ var = 0; if (!OpenDB(name,&dbp)) { return; } if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan last-seen db"); return; } CfOut(cf_verbose,"","Examining known peers...\n"); while(NextDB(dbp,dbcp,&key,&ksize,&value,&vsize)) { strcpy(hostname,(char *)key+1); if (!IsItemIn(hostlist,hostname)) { /* Check hostname not recorded twice with +/- */ AppendItem(&hostlist,hostname,NULL); CfOut(cf_verbose,"","Examining intermittent host %s\n",hostname); } } DeleteDBCursor(dbp,dbcp); CloseDB(dbp); /* Now go through each host and recompute entropy */ for (ip = hostlist; ip != NULL; ip=ip->next) { snprintf(out1,CF_BUFSIZE,"lastseen-%s.q",ip->name); CfOut(cf_verbose,"","Opening %s\n",out1); if ((fp1 = fopen(out1,"w")) == NULL) { CfOut(cf_verbose,"","Unable to open %s\n",out1); continue; } snprintf(out2,CF_BUFSIZE,"lastseen-%s.E-sigma",hostname); if ((fp2 = fopen(out2,"w")) == NULL) { CfOut(cf_verbose,"","Unable to open %s\n",out1); continue; } snprintf(name,CF_BUFSIZE-1,"%s/lastseen/%s.%s",CFWORKDIR,CF_LASTDB_FILE,ip->name); MapName(name); CfOut(cf_verbose,"","Consulting profile %s\n",name); if (!OpenDB(name,&dbp)) { return; } for (now = CF_MONDAY_MORNING; now < CF_MONDAY_MORNING+CF_WEEK; now += CF_MEASURE_INTERVAL) { memset(&key,0,sizeof(key)); memset(&value,0,sizeof(value)); strcpy(timekey,GenTimeKey(now)); if (ReadDB(dbp,timekey,&value,sizeof(entry))) { memcpy(&entry,value,sizeof(entry)); then = (time_t)entry.q; lastseen = now - then; if (lastseen < 0) { lastseen = 0; /* Never seen before, so pretend */ } average = (double)entry.expect; var = (double)entry.var; fprintf(fp2,"%d %lf %lf\n",now,average,sqrt(var)); } else { /* If we have no data, it means no contact for whatever reason. It could be unable to respond unwilling to respond, policy etc. Assume for argument that we expect regular responses ... */ lastseen += CF_MEASURE_INTERVAL; /* infer based on no data */ } fprintf(fp1,"%d %d\n",now,lastseen); } fclose(fp1); fclose(fp2); CloseDB(dbp); } DeleteItemList(hostlist); } /*********************************************************************/ void OpenFiles() { int i; char filename[CF_BUFSIZE],name[CF_MAXVARSIZE]; sprintf(filename,"cfenv-average"); if ((FPAV = fopen(filename,"w")) == NULL) { CfOut(cf_error,"fopen"," !! File %s could not be opened for writing\n",filename); return; } sprintf(filename,"cfenv-stddev"); if ((FPVAR = fopen(filename,"w")) == NULL) { CfOut(cf_error,"fopen"," !! File %s could not be opened for writing\n",filename); return; } sprintf(filename,"cfenv-now"); if ((FPNOW = fopen(filename,"w")) == NULL) { CfOut(cf_error,"fopen"," !! File %s could not be opened for writing\n",filename); return; } for (i = 0; i < CF_OBSERVABLES; i++) { LookUpClassName(i,name); CfOut(cf_inform,""," -> Reporting on \"%s\"\n",name); sprintf(filename,"%s.E-sigma",name); if ((FPE[i] = fopen(filename,"w")) == NULL) { CfOut(cf_error,"fopen"," !! File %s could not be opened for writing\n",filename); return; } sprintf(filename,"%s.q",name); if ((FPQ[i] = fopen(filename,"w")) == NULL) { CfOut(cf_error,"fopen"," !! File %s could not be opened for writing\n",filename); return; } } } /*********************************************************************/ void CloseFiles() { int i; fclose(FPAV); fclose(FPVAR); fclose(FPNOW); for (i = 0; i < CF_OBSERVABLES; i++) { fclose(FPE[i]); fclose(FPQ[i]); } } /*********************************************************************/ void OpenMagnifyFiles() { int i; char filename[CF_BUFSIZE],name[CF_MAXVARSIZE]; for (i = 0; i < CF_OBSERVABLES; i++) { LookUpClassName(i,name); sprintf(filename,"%s.mag",name); CfOut(cf_inform,""," -> Magnifying \"%s\"\n",name); if ((FPM[i] = fopen(filename,"w")) == NULL) { perror("fopen"); return; } } } /*********************************************************************/ void CloseMagnifyFiles() { int i; for (i = 0; i < CF_OBSERVABLES; i++) { fclose(FPM[i]); } } /* EOF */ ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/verify_databases.c���������������������������������������������������������������0000644�0001750�0001750�00000013431�11715232734�014474� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: verify_databases.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void VerifySQLPromise(struct Attributes a,struct Promise *pp); /*****************************************************************************/ void VerifyDatabasePromises(struct Promise *pp) { struct Attributes a = {{0}}; if (pp->done) { return; } PromiseBanner(pp); a = GetDatabaseAttributes(pp); if (!CheckDatabaseSanity(a,pp)) { return; } if (strcmp(a.database.type,"sql") == 0) { VerifySQLPromise(a,pp); return; } if (strcmp(a.database.type,"ms_registry") == 0) { VerifyRegistryPromise(a,pp); return; } } /*****************************************************************************/ /* Level */ /*****************************************************************************/ static void VerifySQLPromise(struct Attributes a,struct Promise *pp) { char database[CF_MAXVARSIZE],table[CF_MAXVARSIZE],query[CF_BUFSIZE]; char *sp,sep = 'x'; int count = 0; CfdbConn cfdb; struct CfLock thislock; char lockname[CF_BUFSIZE]; snprintf(lockname,CF_BUFSIZE-1,"db-%s",pp->promiser); thislock = AcquireLock(lockname,VUQNAME,CFSTARTTIME,a,pp,false); if (thislock.lock == NULL) { return; } database[0] = '\0'; table[0] = '\0'; for (sp = pp->promiser; *sp != '\0'; sp++) { if (strchr("./\\", *sp)) { count++; sep = *sp; strncpy(table,sp+1,CF_MAXVARSIZE-1); sscanf(pp->promiser,"%[^.\\/]",database); if (strlen(database) == 0) { cfPS(cf_error,CF_FAIL,"",pp,a,"SQL database promiser syntax should be of the form \"database.table\""); PromiseRef(cf_error,pp); YieldCurrentLock(thislock); return; } } } if (count > 1) { cfPS(cf_error,CF_FAIL,"",pp,a,"SQL database promiser syntax should be of the form \"database.table\""); PromiseRef(cf_error,pp); } if (strlen(database) == 0) { strncpy(database,pp->promiser,CF_MAXVARSIZE-1); } if (strcmp(a.database.operation,"delete") == 0) { /* Just deal with one */ strcpy(a.database.operation,"drop"); } /* Connect to the server */ CfConnectDB(&cfdb,a.database.db_server_type,a.database.db_server_host,a.database.db_server_owner,a.database.db_server_password,database); if (!cfdb.connected) { /* If we haven't said create then db should already exist */ if (a.database.operation && strcmp(a.database.operation,"create") != 0) { CfOut(cf_error,"","Could not connect an existing database %s - check server configuration?\n",database); PromiseRef(cf_error,pp); CfCloseDB(&cfdb); YieldCurrentLock(thislock); return; } } /* Check change of existential constraints */ if (a.database.operation && strcmp(a.database.operation,"create") == 0) { CfConnectDB(&cfdb,a.database.db_server_type,a.database.db_server_host,a.database.db_server_owner,a.database.db_server_password,a.database.db_connect_db); if (!cfdb.connected) { CfOut(cf_error,"","Could not connect to the sql_db server for %s\n",database); return; } /* Don't drop the db if we really want to drop a table */ if (strlen(table) == 0 || (strlen(table) > 0 && strcmp(a.database.operation,"drop") != 0)) { VerifyDatabasePromise(&cfdb,database,a,pp); } /* Close the database here to commit the change - might have to reopen */ CfCloseDB(&cfdb); } /* Now check the structure of the named table, if any */ if (strlen(table) == 0) { YieldCurrentLock(thislock); return; } CfConnectDB(&cfdb,a.database.db_server_type,a.database.db_server_host,a.database.db_server_owner,a.database.db_server_password,database); if (!cfdb.connected) { CfOut(cf_inform,"","Database %s is not connected\n",database); } else { snprintf(query,CF_MAXVARSIZE-1,"%s.%s",database,table); if (CfVerifyTablePromise(&cfdb,query,a.database.columns,a,pp)) { cfPS(cf_inform,CF_NOP,"",pp,a," -> Table \"%s\" is as promised",query); } else { cfPS(cf_inform,CF_FAIL,"",pp,a," -> Table \"%s\" is not as promised",query); } /* Finally check any row constraints on this table */ if (a.database.rows) { CfOut(cf_inform,""," !! Database row operations are not currently supported. Please contact cfengine with suggestions."); } CfCloseDB(&cfdb); } YieldCurrentLock(thislock); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/interfaces.c���������������������������������������������������������������������0000644�0001750�0001750�00000041441�11715232734�013306� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /* STUBs from cf2 - should this be rewritten? */ /*******************************************************************/ /* */ /* INET checking for cfengine */ /* */ /* This is based on the action of "ifconfig" for IP protocols */ /* It assumes that we are on the internet and uses ioctl to get */ /* the necessary info from the device. Sanity checking is done... */ /* */ /* Sockets are very poorly documented. The basic socket adress */ /* struct sockaddr is a generic type. Specific socket addresses */ /* must be specified depending on the family or protocol being */ /* used. e.g. if you're using the internet inet protocol, then */ /* the fmaily is AF_INT and the socket address type is sockadr_in */ /* Although it is not obvious, the documentation assures us that */ /* we can cast a pointer of one type into a pointer of the other: */ /* */ /* Here's an example */ /* */ /* #include <netinet/in.h> */ /* */ /* struct in_addr adr; */ /* e.g. adr.s_addr = inet_addr("129.240.22.34"); */ /* printf("addr is %s\n",inet_ntoa(adr)); */ /* */ /* */ /* We have to do the following in order to convert */ /* a sockaddr struct into a sockaddr_in struct required by the */ /* ifreq struct!! These calls have no right to work, but somehow */ /* they do! */ /* */ /* struct sockaddr_in sin; */ /* sin.sin_addr.s_addr = inet_addr("129.240.22.34"); */ /* */ /* IFR.ifr_addr = *((struct sockaddr *) &sin); */ /* */ /* sin = *(struct sockaddr_in *) &IFR.ifr_addr; */ /* */ /* printf("IP address: %s\n",inet_ntoa(sin.sin_addr)); */ /* */ /*******************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void SetPromisedDefaultRoute(void); static int GetPromisedIfStatus(int sk,char *vifdev,char *vaddress,char *vnetmask,char *vbroadcast); static void SetPromisedIfStatus(int sk,char *vifdev,char *vaddress,char *vnetmask,char *vbroadcast); static void GetDefaultBroadcastAddr(char *ipaddr,char *vifdev,char *vnetmask,char *vbroadcast); /*******************************************************************/ #ifndef INET_ADDRSTRLEN #define INET_ADDRSTRLEN sizeof("255.255.255.255") #endif #if !defined(NT) && !defined(IRIX) /* IRIX makes the routing stuff obsolete unless we do this */ # undef sgi struct ifreq IFR; char VNUMBROADCAST[256]; # define cfproto 0 # ifndef IPPROTO_IP /* Old boxes, hpux 7 etc */ # define IPPROTO_IP 0 # endif # ifndef SIOCSIFBRDADDR # define SIOCSIFBRDADDR SIOCGIFBRDADDR # endif /*******************************************************************/ void VerifyInterfacePromise(char *vifdev,char *vaddress,char *vnetmask,char *vbroadcast) { int sk, flags, metric, isnotsane = false; CfOut(cf_verbose,"","Assumed interface name: %s %s %s\n",vifdev,vnetmask,vbroadcast); if (!IsPrivileged()) { CfOut(cf_error,"","Only root can configure network interfaces.\n"); return; } if (vnetmask && strlen(vnetmask)) { CfOut(cf_error,"","No netmask is promised for interface %s\n",vifdev); return; } if (vbroadcast && strlen(vbroadcast)) { CfOut(cf_error,"","No broadcast address is promised for the interface - calculating default\n"); return; } strcpy(IFR.ifr_name,vifdev); IFR.ifr_addr.sa_family = AF_INET; if ((sk = socket(AF_INET,SOCK_DGRAM,IPPROTO_IP)) == -1) { CfOut(cf_error,"socket","Unable to open a socket to examine interface %s\n",vifdev); return; } if (ioctl(sk,SIOCGIFFLAGS, (caddr_t) &IFR) == -1) /* Get the device status flags */ { CfOut(cf_error,"ioctl","Promised network device was not found\n"); return; } flags = IFR.ifr_flags; strcpy(IFR.ifr_name,vifdev); /* copy this each time */ if (ioctl(sk,SIOCGIFMETRIC, (caddr_t) &IFR) == -1) /* Get the routing priority */ { CfOut(cf_error,"ioctl","Error examining the routing metric\n"); return; } metric = IFR.ifr_metric; isnotsane = GetPromisedIfStatus(sk,vifdev,vaddress,vnetmask,vbroadcast); if (!DONTDO && isnotsane) { SetPromisedIfStatus(sk,vifdev,vaddress,vnetmask,vbroadcast); GetPromisedIfStatus(sk,vifdev,vaddress,vnetmask,vbroadcast); } cf_closesocket(sk); } /*******************************************************************/ static int GetPromisedIfStatus(int sk,char *vifdev,char *vaddress,char *vnetmask,char *vbroadcast) { struct sockaddr_in *sin; struct sockaddr_in netmask; int insane = false; struct hostent *hp; struct in_addr inaddr; char vbuff[CF_BUFSIZE]; CfOut(cf_verbose,""," -> Checking interface promises on %s\n",vifdev); if ((hp = gethostbyname(VSYSNAME.nodename)) == NULL) { CfOut(cf_error,"gethostbyname","Error looking up host"); return false; } else { memcpy(&inaddr,hp->h_addr,hp->h_length); CfOut(cf_verbose,""," -> Address reported by nameserver: %s\n",inet_ntoa(inaddr)); } strcpy(IFR.ifr_name,vifdev); if (ioctl(sk,SIOCGIFADDR, (caddr_t) &IFR) == -1) /* Get the device status flags */ { return false; } sin = (struct sockaddr_in *) &IFR.ifr_addr; if (strlen(vaddress) > 0) { if (strcmp(vaddress,(char *)inet_ntoa(sin->sin_addr)) != 0) { CfOut(cf_error,"","Interface %s is configured with an address which differs from that promised\n",vifdev); insane = true; } } if (strcmp((char *)inet_ntoa(*(struct in_addr *)(hp->h_addr)),(char *)inet_ntoa(sin->sin_addr)) != 0) { CfOut(cf_error,"","Interface %s is configured with an address which differs from that promised\n",vifdev); insane = true; } if (ioctl(sk,SIOCGIFNETMASK, (caddr_t) &IFR) == -1) { return false; } netmask.sin_addr = ((struct sockaddr_in *) &IFR.ifr_addr)->sin_addr; CfOut(cf_verbose,""," -> Found netmask: %s\n",inet_ntoa(netmask.sin_addr)); strcpy(vbuff,inet_ntoa(netmask.sin_addr)); if (strcmp(vbuff,vnetmask)) { CfOut(cf_error,"","Interface %s is configured with a netmask which differs from that promised\n",vifdev); insane = true; } if (ioctl(sk,SIOCGIFBRDADDR, (caddr_t) &IFR) == -1) { return false; } sin = (struct sockaddr_in *) &IFR.ifr_addr; strcpy(vbuff,inet_ntoa(sin->sin_addr)); CfOut(cf_verbose,""," -> Found broadcast address: %s\n",inet_ntoa(sin->sin_addr)); GetDefaultBroadcastAddr(inet_ntoa(inaddr),vifdev,vnetmask,vbroadcast); if (strcmp(vbuff,VNUMBROADCAST) != 0) { CfOut(cf_error,"","Interface %s is configured with a broadcast address which differs from that promised\n",vifdev); insane = true; } return(insane); } /*******************************************************************/ static void SetPromisedIfStatus(int sk,char *vifdev,char *vaddress,char *vnetmask,char *vbroadcast) { struct sockaddr_in *sin; struct sockaddr_in netmask, broadcast; /********************************* Don't try to set the address yet... if (ioctl(sk,SIOCSIFADDR, (caddr_t) &IFR) == -1) { perror ("Can't set IP address"); return; } REWRITE THIS TO USE ifconfig / ipconfig **********************************/ /* set netmask */ CfOut(cf_verbose,""," -> Resetting interface...\n"); memset(&IFR, 0, sizeof(IFR)); strncpy(IFR.ifr_name,vifdev,sizeof(IFR.ifr_name)); netmask.sin_addr.s_addr = inet_network(vnetmask); netmask.sin_family = AF_INET; IFR.ifr_addr = *((struct sockaddr *) &netmask); sin = (struct sockaddr_in *) &IFR.ifr_addr; if (ioctl(sk,SIOCSIFNETMASK, (caddr_t) &IFR) < 0) { //cfPS(cf_error,CF_FAIL,"ioctl",pp,a,"Failed to set netmask to %s\n",inet_ntoa(netmask.sin_addr)); } else { //cfPS(cf_inform,CF_CHG,"",pp,a,"Setting netmask to %s\n",inet_ntoa(netmask.sin_addr)); } /* broadcast addr */ strcpy(IFR.ifr_name,vifdev); broadcast.sin_addr.s_addr = inet_addr(VNUMBROADCAST); IFR.ifr_addr = *((struct sockaddr *) &broadcast); sin = (struct sockaddr_in *) &IFR.ifr_addr; CfOut(cf_verbose,"","Trying to set broad to %s = %s\n",VNUMBROADCAST,inet_ntoa(sin->sin_addr)); if (ioctl(sk,SIOCSIFBRDADDR, (caddr_t) &IFR) == -1) { //cfPS(cf_error,CF_FAIL,"ioctl",pp,a,"Failed to set broadcast address\n"); return; } /* if ((void *)(sin->sin_addr.s_addr) == (void *)NULL) { cfPS(cf_inform,CF_FAIL,"ioctl",pp,a,"Set broadcast address failed\n"); } else { cfPS(cf_inform,CF_CHG,"ioctl",pp,a,"Set broadcast address\n"); } */ } /*****************************************************/ static void GetDefaultBroadcastAddr(char *ipaddr,char *vifdev,char *vnetmask,char *vbroadcast) { unsigned int na,nb,nc,nd; unsigned int ia,ib,ic,id; unsigned int ba,bb,bc,bd; unsigned netmask,ip,broadcast; sscanf(vnetmask,"%u.%u.%u.%u",&na,&nb,&nc,&nd); netmask = nd + 256*nc + 256*256*nb + 256*256*256*na; sscanf(ipaddr,"%u.%u.%u.%u",&ia,&ib,&ic,&id); ip = id + 256*ic + 256*256*ib + 256*256*256*ia; if (strcmp(vbroadcast,"zero") == 0) { broadcast = ip & netmask; } else if (strcmp(vbroadcast,"one") == 0) { broadcast = ip | (~netmask); } else { return; } ba = broadcast / (256 * 256 * 256); bb = (broadcast / (256 * 256)) % 256; bc = broadcast / (256) % 256; bd = broadcast % 256; sprintf(VNUMBROADCAST,"%u.%u.%u.%u",ba,bb,bc,bd); } /****************************************************************/ /* */ /* Routing Tables: */ /* */ /* To check that we have at least one static route entry to */ /* the nearest gateway -- i.e. the wildcard entry for "default" */ /* we need some way of accessing the routing tables. There is */ /* no elegant way of doing this, alas. */ /* */ /****************************************************************/ static void SetPromisedDefaultRoute() { int sk, defaultokay = 1; struct sockaddr_in sindst,singw; char oldroute[INET_ADDRSTRLEN]; char routefmt[CF_MAXVARSIZE]; char vbuff[CF_BUFSIZE]; /* These OSes have these structs defined but use the route command */ # if defined DARWIN || defined FREEBSD || defined OPENBSD || defined SOLARIS # undef HAVE_RTENTRY # undef HAVE_ORTENTRY # endif # ifdef HAVE_ORTENTRY struct ortentry route; # else # if HAVE_RTENTRY struct rtentry route; # endif # endif FILE *pp; CfOut(cf_verbose,"","Looking for a default route...\n"); if (!IsPrivileged()) { CfOut(cf_inform,"","Only root can set a default route."); return; } if (VDEFAULTROUTE == NULL) { CfOut(cf_verbose,"","cfengine: No default route is defined. Ignoring the routing tables.\n"); return; } if ((pp = cf_popen(VNETSTAT[VSYSTEMHARDCLASS],"r")) == NULL) { CfOut(cf_error,"cf_popen","Failed to open pipe from %s\n",VNETSTAT[VSYSTEMHARDCLASS]); return; } while (!feof(pp)) { CfReadLine(vbuff,CF_BUFSIZE,pp); Debug("LINE: %s = %s?\n",vbuff,VDEFAULTROUTE->name); if ((strncmp(vbuff,"default",7) == 0)||(strncmp(vbuff,"0.0.0.0",7) == 0)) { /* extract the default route */ /* format: default|0.0.0.0 <whitespace> route <whitespace> etc */ if ((sscanf(vbuff, "%*[default0. ]%s%*[ ]", oldroute)) == 1) { if ((strncmp(VDEFAULTROUTE->name, oldroute, INET_ADDRSTRLEN)) == 0) { CfOut(cf_verbose,"","cfengine: default route is already set to %s\n",VDEFAULTROUTE->name); defaultokay = 1; break; } else { CfOut(cf_verbose,"","cfengine: default route is set to %s, but should be %s.\n",oldroute,VDEFAULTROUTE->name); defaultokay = 2; break; } } } else { Debug("No default route is yet registered\n"); defaultokay = 0; } } cf_pclose(pp); if (defaultokay == 1) { CfOut(cf_verbose,"","Default route is set and agrees with conditional policy\n"); return; } if (defaultokay == 0) { NewClass("no_default_route"); } if (IsExcluded(VDEFAULTROUTE->classes)) { CfOut(cf_verbose,"","cfengine: No default route is applicable. Ignoring the routing tables.\n"); return; } CfOut(cf_error,"","The default route is incorrect, trying to correct\n"); if (strcmp(VROUTE[VSYSTEMHARDCLASS], "-") != 0) { Debug ("Using route shell commands to set default route\n"); if (defaultokay == 2) { if (! DONTDO) { /* get the route command and the format for the delete argument */ snprintf(routefmt,CF_MAXVARSIZE,"%s %s",VROUTE[VSYSTEMHARDCLASS],VROUTEDELFMT[VSYSTEMHARDCLASS]); snprintf(vbuff,CF_MAXVARSIZE,routefmt,"default",VDEFAULTROUTE->name); if (ShellCommandReturnsZero(vbuff,false)) { CfOut(cf_inform,"Removing old default route %s",vbuff); } else { CfOut(cf_error,"","Error removing route"); } } } if (! DONTDO) { snprintf(routefmt,CF_MAXVARSIZE,"%s %s",VROUTE[VSYSTEMHARDCLASS],VROUTEADDFMT[VSYSTEMHARDCLASS]); snprintf(vbuff,CF_MAXVARSIZE,routefmt,"default",VDEFAULTROUTE->name); if (ShellCommandReturnsZero(vbuff,false)) { CfOut(cf_inform,"","Setting default route %s",vbuff); } else { CfOut(cf_error,"","Error setting route"); } } return; } else { #if defined HAVE_RTENTRY || defined HAVE_ORTENTRY Debug ("Using route ioctl to set default route\n"); if ((sk = socket(AF_INET,SOCK_RAW,0)) == -1) { CfOut(cf_error,"socket","System class: ", CLASSTEXT[VSYSTEMHARDCLASS]); } else { sindst.sin_family = AF_INET; singw.sin_family = AF_INET; sindst.sin_addr.s_addr = INADDR_ANY; singw.sin_addr.s_addr = inet_addr(VDEFAULTROUTE->name); route.rt_dst = *(struct sockaddr *)&sindst; /* This disgusting method is necessary */ route.rt_gateway = *(struct sockaddr *)&singw; route.rt_flags = RTF_GATEWAY; if (! DONTDO) { if (ioctl(sk,SIOCADDRT, (caddr_t) &route) == -1) /* Get the device status flags */ { CfOut(cf_error,"ioctly SIOCADDRT","Error setting route"); } else { CfOut(cf_error,"","Setting default route to %s\n",VDEFAULTROUTE->name); } } } #else /* Socket routing - don't really know how to do this yet */ CfOut(cf_verbose,"","Sorry don't know how to do routing on this platform\n"); #endif } } #else /* NT or IRIX */ void VerifyInterfacePromise(vifdev,vaddress,vnetmask,vbroadcast) char *vifdev,*vaddress,*vnetmask, *vbroadcast; { CfOut(cf_verbose,"","Network configuration is not implemented on this OS\n"); } void SetPromisedDefaultRoute() { CfOut(cf_verbose,"","Setting default route is not implemented on this OS\n"); } #endif �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/mod_databases.c������������������������������������������������������������������0000644�0001750�0001750�00000010164�11715232734�013747� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_databases.c */ /* */ /*****************************************************************************/ /* This file can act as a template for adding functionality to cfengine 3. All functionality can be added by extending the main array CF_MOD_SUBTYPES[CF3_MODULES] and its array dimension, in mod_common, in the manner shown here. */ #define CF3_MOD_DATABASES #include "cf3.defs.h" #include "cf3.extern.h" /***********************************************************/ /* Read this module file backwards, as dependencies have */ /* to be defined first - these arrays declare pairs of */ /* constraints */ /* */ /* lval => rval */ /* */ /* in the form (lval,type,range) */ /* */ /* If the type is cf_body then the range is a pointer */ /* to another array of pairs, like in a body "sub-routine" */ /* */ /***********************************************************/ struct BodySyntax CF_SQLSERVER_BODY[] = { {"db_server_owner",cf_str,"","User name for database connection"}, {"db_server_password",cf_str,"","Clear text password for database connection"}, {"db_server_host",cf_str,"","Hostname or address for connection to database, blank means localhost"}, {"db_server_type",cf_opts,"postgres,mysql","The dialect of the database server"}, {"db_server_connection_db",cf_str,"","The name of an existing database to connect to in order to create/manage other databases"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ struct BodySyntax CF_DATABASES_BODIES[] = { {"database_server",cf_body,CF_SQLSERVER_BODY,"Credentials for connecting to a local/remote database server"}, {"database_type",cf_opts,"sql,ms_registry","The type of database that is to be manipulated"}, {"database_operation",cf_opts,"create,delete,drop,cache,verify,restore","The nature of the promise - to be or not to be"}, {"database_columns",cf_slist,".*","A list of column definitions to be promised by SQL databases"}, {"database_rows",cf_slist,".*,.*","An ordered list of row values to be promised by SQL databases"}, {"registry_exclude",cf_slist,"","A list of regular expressions to ignore in key/value verification"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_DATABASES_SUBTYPES[] = { {"agent","databases",CF_DATABASES_BODIES}, {NULL,NULL,NULL}, }; ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/logic_expressions.h��������������������������������������������������������������0000644�0001750�0001750�00000006435�11715232734�014733� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifndef CFENIGNE_LOGIC_EXPRESSIONS_H #define CFENGINE_LOGIC_EXPRESSIONS_H #include "bool.h" #include "string_expressions.h" /* Logic expressions grammar: <expr> ::= <or-expr> <or-expr> ::= <and-expr> <and-expr> | <and-expr> <and-expr> || <and-expr> <and-expr> ::= <not-expr> <not-expr> . <not-expr> <not-expr> & <not-expr> <not-expr> ::= ! <primary> <primary> <primary> ::= ( <expr> ) <name> Basis of logic evaluation is <name> values which are provided by StringExpression and suitable string->bool evaluator. */ typedef enum LogicalOp { OR, AND, NOT, EVAL, } LogicalOp; typedef struct Expression { LogicalOp op; union { struct AndOrExpression { struct Expression *lhs; struct Expression *rhs; } andor; struct NotExpression { struct Expression *arg; } not; struct EvalExpression { StringExpression *name; } eval; } val; } Expression; /* Parsing and evaluation */ /* * Result of parsing. * * if succeeded, then result is the result of parsing and position is last * character consumed. * * if not succeded, then result is NULL and position is last character consumed * before the error. */ typedef struct ParseResult { Expression *result; int position; } ParseResult; ParseResult ParseExpression(const char *expr, int start, int end); typedef enum ExpressionValue { EXP_ERROR = -1, EXP_FALSE = false, EXP_TRUE = true, } ExpressionValue; /* * Evaluator should return FALSE, TRUE or ERROR if unable to parse result. In * later case evaluation will be aborted and ERROR will be returned from * EvalExpression. */ typedef ExpressionValue (*NameEvaluator)(const char *name, void *param); /* * Result is heap-allocated. In case evalfn() returns ERROR whole * EvalExpression returns ERROR as well. */ ExpressionValue EvalExpression(const Expression *expr, NameEvaluator nameevalfn, VarRefEvaluator varrefevalfn, void *param); /* * Frees Expression produced by ParseExpression. NULL-safe. */ void FreeExpression(Expression *expr); #endif �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/assoc.c��������������������������������������������������������������������������0000644�0001750�0001750�00000005656�11715232734�012303� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: assoc.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void ShowAssoc (struct CfAssoc *cp); /*******************************************************************/ struct CfAssoc *NewAssoc(const char *lval,void *rval,char rtype,enum cfdatatype dt) { struct CfAssoc *ap; if ((ap= malloc(sizeof(struct CfAssoc))) == NULL) { FatalError("malloc failure in NewAssoc\n"); } /* Make a private copy because promises are ephemeral in expansion phase */ ap->lval = strdup(lval); ap->rval = CopyRvalItem(rval,rtype); ap->dtype = dt; ap->rtype = rtype; if (ap->rval == NULL) { free(ap->lval); free(ap); return NULL; } if (lval == NULL) { FatalError("Bad association in NewAssoc\n"); } return ap; } /*******************************************************************/ void DeleteAssoc(struct CfAssoc *ap) { if (ap == NULL) { return; } Debug(" ----> Delete variable association %s\n",ap->lval); if (ap->lval) { free(ap->lval); } if (ap->rval) { DeleteRvalItem(ap->rval,ap->rtype); } free((char *)ap); } /*******************************************************************/ struct CfAssoc *CopyAssoc(struct CfAssoc *old) { if (old == NULL) { return NULL; } return NewAssoc(old->lval,old->rval,old->rtype,old->dtype); } /*******************************************************************/ static void ShowAssoc (struct CfAssoc *cp) { printf("ShowAssoc: lval = %s\n",cp->lval); printf("ShowAssoc: rval = "); ShowRval(stdout,cp->rval,cp->rtype); printf("\nShowAssoc: dtype = %s\n",CF_DATATYPES[cp->dtype]); } ����������������������������������������������������������������������������������cfengine-3.2.4/src/enterprise_stubs.c���������������������������������������������������������������0000644�0001750�0001750�00000070557�11715232734�014575� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ /* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: enterprise_stubs.c */ /* */ /*****************************************************************************/ /* This file is a stub for generating cfengine's commerical enterprise level versions. We appreciate your respect of our commercial offerings, which go to accelerate future developments of both free and commercial versions. If you have a good reason why a particular feature of the commercial version should be free, please let us know and we will consider this carefully. */ #include "cf3.defs.h" #include "cf3.extern.h" #ifdef HAVE_CFLIBNOVA # include <cf.nova.h> #endif #ifdef HAVE_ZONE_H # include <zone.h> #endif void *Nova_LDAPValue(char *uri,char *basedn,char *filter,char *name,char *scope,char *sec); void *Nova_LDAPList(char *uri,char *dn,char *filter,char *name,char *scope,char *sec); void *Nova_LDAPArray(char *array,char *uri,char *dn,char *filter,char *scope,char *sec); void *Nova_RegLDAP(char *uri,char *dn,char *filter,char *name,char *scope,char *regex,char *sec); struct Averages SHIFT_VALUE; char CURRENT_SHIFT[CF_MAXVARSIZE]; /*****************************************************************************/ int IsEnterprise() { #if defined HAVE_NOVA || defined HAVE_CONSTELLATION || defined HAVE_LIBCFGALAXY return true; #else return false; #endif } /*****************************************************************************/ void EnterpriseModuleTrick() { #if defined HAVE_NOVA Nova_EnterpriseModuleTrick(); #endif #if defined HAVE_CONSTELLATION Constellation_EnterpriseModuleTrick(); #endif } /*****************************************************************************/ void EnterpriseContext() { #ifdef HAVE_NOVA Nova_EnterpriseContext(); #endif } /*****************************************************************************/ int CfSessionKeySize(char c) { #ifdef HAVE_NOVA return Nova_CfSessionKeySize(c); #else return CF_BLOWFISHSIZE; #endif } /*****************************************************************************/ char CfEnterpriseOptions() { #ifdef HAVE_NOVA return Nova_CfEnterpriseOptions(); #else return 'c'; #endif } /*****************************************************************************/ const EVP_CIPHER *Nova_CfengineCipher(char type); const EVP_CIPHER *CfengineCipher(char type) { #ifdef HAVE_NOVA return Nova_CfengineCipher(type); #else return EVP_bf_cbc(); #endif } /*****************************************************************************/ int EnterpriseExpiry(void) { #ifdef HAVE_NOVA return Nova_EnterpriseExpiry(); #else return false; #endif } /*****************************************************************************/ #ifdef HAVE_NOVA void CheckLicenses() { Nova_CheckLicensePromise(); } #else void CheckLicenses() { struct stat sb; char name[CF_BUFSIZE]; snprintf(name,sizeof(name),"%s/state/am_policy_hub",CFWORKDIR); MapName(name); if (stat(name,&sb) != -1) { NewClass("am_policy_hub"); CfOut(cf_verbose,""," -> Additional class defined: am_policy_hub"); } return; } #endif /*****************************************************************************/ char *GetConsolePrefix() { #ifdef HAVE_CONSTELLATION return "constellation"; #elif defined HAVE_NOVA return "nova"; #else return "cf3"; #endif } /*****************************************************************************/ char *MailSubject() { static char buffer[CF_BUFSIZE]; #ifdef HAVE_NOVA if (LICENSES) { strcpy(buffer,"Nova"); } else { strcpy(buffer,"NO LICENSE"); } #else strcpy(buffer,"community"); #endif return buffer; } /*****************************************************************************/ void LogFileChange(char *file,int change,struct Attributes a,struct Promise *pp) { #ifdef HAVE_NOVA Nova_LogFileChange(file,change,a,pp); #else CfOut(cf_verbose,"","Logging file differences requires version Nova or above"); #endif } /*****************************************************************************/ void RemoteSyslog(struct Attributes a,struct Promise *pp) { #ifdef HAVE_NOVA Nova_RemoteSyslog(a,pp); #else CfOut(cf_verbose,"","Remote logging requires version Nova or above"); #endif } /*****************************************************************************/ #if !defined(HAVE_NOVA) void WebCache(char *s,char *t) { } #endif /*****************************************************************************/ /* Knowledge */ /*****************************************************************************/ char *Nova_PromiseID(struct Promise *pp); char *PromiseID(struct Promise *pp) { #ifdef HAVE_NOVA return Nova_PromiseID(pp); #else return ""; #endif } /*****************************************************************************/ void NotePromiseCompliance(struct Promise *pp,double val,enum cf_status status,char *reason) { #ifdef HAVE_NOVA Nova_NotePromiseCompliance(pp,val,status,reason); #else #endif } /*****************************************************************************/ void PreSanitizePromise(struct Promise *pp) { #ifdef HAVE_NOVA Nova_PreSanitizePromise(pp); #else #endif } /*****************************************************************************/ void TrackValue(char *date,double kept,double repaired, double notkept) { #ifdef HAVE_NOVA Nova_TrackValue(date,kept,repaired,notkept); #else #endif } /*****************************************************************************/ time_t GetPromiseCompliance(struct Promise *pp,double *value,double *average,double *var,time_t *lastseen) { #ifdef HAVE_NOVA return Nova_GetPromiseCompliance(pp,value,average,var,lastseen); #else return time(NULL); #endif } /*****************************************************************************/ void MapPromiseToTopic(FILE *fp,struct Promise *pp,const char *version) { #ifdef HAVE_NOVA Nova_MapPromiseToTopic(fp,pp,version); #endif } /*****************************************************************************/ void ShowTopicRepresentation(FILE *fp) { #ifdef HAVE_NOVA Nova_ShowTopicRepresentation(fp); #else CfOut(cf_verbose,"","# Knowledge map reporting feature is only available in version Nova and above\n"); #endif } /*****************************************************************************/ void NewPromiser(struct Promise *pp) { #ifdef HAVE_NOVA Nova_NewPromiser(pp); #else #endif } /*****************************************************************************/ void AnalyzePromiseConflicts() { #ifdef HAVE_NOVA Nova_AnalyzePromiseConflicts(); #else #endif } /*****************************************************************************/ void RegisterBundleDependence(char *name,struct Promise *pp) { #ifdef HAVE_NOVA Nova_RegisterBundleDepedence(name,pp); #else #endif } /*****************************************************************************/ void SyntaxCompletion(char *s) { #ifdef HAVE_NOVA Nova_SyntaxCompletion(s); #else printf("Syntax completion is available in cfengine Nova,Constellation or Galaxy\n\n"); #endif } /*****************************************************************************/ void SyntaxExport() { #ifdef HAVE_NOVA Nova_SyntaxTree2JavaScript(); #else printf("Syntax export is available in cfengine Nova,Constellation or Galaxy\n\n"); #endif } /*****************************************************************************/ void VerifyOutputsPromise(struct Promise *pp) { #ifdef HAVE_NOVA Nova_VerifyOutputsPromise(pp); #else printf(" !! Outputs promises are not available in the community edition of Cfengine\n"); #endif } /*****************************************************************************/ void SetPromiseOutputs(struct Promise *pp) { #ifdef HAVE_NOVA Nova_SetPromiseOutputs(pp); #endif } /*****************************************************************************/ void LastSawBundle(char *name) { #ifdef HAVE_NOVA Nova_LastSawBundle(name); #endif } /*****************************************************************************/ void SetBundleOutputs(char *name) { #ifdef HAVE_NOVA Nova_SetBundleOutputs(name); #endif } /*****************************************************************************/ void ResetBundleOutputs(char *name) { #ifdef HAVE_NOVA Nova_ResetBundleOutputs(name); #endif } /*****************************************************************************/ void SpecialQuote(char *topic,char *type) { #ifdef HAVE_NOVA Nova_SpecialQuote(topic,type); #endif } /*****************************************************************************/ /* Monitord */ /*****************************************************************************/ void HistoryUpdate(struct Averages newvals) { #ifdef HAVE_NOVA struct Promise *pp = NewPromise("history_db","the long term memory"); struct Attributes dummyattr = {{0}}; struct CfLock thislock; time_t now = time(NULL); /* We do this only once per hour - this should not be changed */ Banner("Update long-term history"); if (strlen(CURRENT_SHIFT) == 0) { // initialize Nova_ResetShiftAverage(&SHIFT_VALUE); } memset(&dummyattr,0,sizeof(dummyattr)); dummyattr.transaction.ifelapsed = 59; thislock = AcquireLock(pp->promiser,VUQNAME,now,dummyattr,pp,false); if (thislock.lock == NULL) { Nova_UpdateShiftAverage(&SHIFT_VALUE,&newvals); DeletePromise(pp); return; } /* Refresh the class context of the agent */ DeletePrivateClassContext(); DeleteEntireHeap(); DeleteAllScope(); NewScope("sys"); NewScope("const"); NewScope("match"); NewScope("mon"); NewScope("control_monitor"); NewScope("control_common"); GetNameInfo3(); CfGetInterfaceInfo(cf_monitor); Get3Environment(); BuiltinClasses(); OSClasses(); SetReferenceTime(true); LoadPersistentContext(); LoadSystemConstants(); YieldCurrentLock(thislock); DeletePromise(pp); Nova_HistoryUpdate(CFSTARTTIME, &newvals); if (strcmp(CURRENT_SHIFT,VSHIFT) != 0) { strcpy(CURRENT_SHIFT,VSHIFT); Nova_ResetShiftAverage(&SHIFT_VALUE); } Nova_DumpSlowlyVaryingObservations(); #else #endif } /*****************************************************************************/ void CfGetClassName(int i,char *name) { #ifdef HAVE_NOVA char desc[CF_BUFSIZE]; Nova_GetClassName(i,name,desc); #else strcpy(name,OBS[i][0]); #endif } /*****************************************************************************/ void LookUpClassName(int i,char *name) { #ifdef HAVE_NOVA char desc[CF_BUFSIZE]; Nova_LookupClassName(i,name,desc); #else strcpy(name,OBS[i][0]); #endif } /*****************************************************************************/ void LoadSlowlyVaryingObservations() { #ifdef HAVE_NOVA Nova_LoadSlowlyVaryingObservations(); #else CfOut(cf_verbose,"","# Extended system discovery is only available in version Nova and above\n"); #endif } /*****************************************************************************/ /* Server */ /*****************************************************************************/ void RegisterLiteralServerData(char *handle,struct Promise *pp) { #ifdef HAVE_NOVA Nova_RegisterLiteralServerData(handle,pp); #else CfOut(cf_verbose,"","# Access to server literals is only available in version Nova and above\n"); #endif } /*****************************************************************************/ int ReturnLiteralData(char *handle,char *ret) { #ifdef HAVE_NOVA return Nova_ReturnLiteralData(handle,ret); #else CfOut(cf_verbose,"","# Access to server literals is only available in version Nova and above\n"); return 0; #endif } /*****************************************************************************/ char *Nova_GetRemoteScalar(char *proto,char *handle,char *server,int encrypted,char *rcv); char *GetRemoteScalar(char *proto,char *handle,char *server,int encrypted,char *rcv) { #ifdef HAVE_NOVA return Nova_GetRemoteScalar(proto,handle,server,encrypted,rcv); #else CfOut(cf_verbose,"","# Access to server literals is only available in version Nova and above\n"); return ""; #endif } /*****************************************************************************/ void CacheUnreliableValue(char *caller,char *handle,char *buffer) { #ifdef HAVE_NOVA Nova_CacheUnreliableValue(caller,handle,buffer); #else CfOut(cf_verbose,"","# Value fault-tolerance in version Nova and above\n"); return; #endif } /*****************************************************************************/ int RetrieveUnreliableValue(char *caller,char *handle,char *buffer) { #ifdef HAVE_NOVA return Nova_RetrieveUnreliableValue(caller,handle,buffer); #else CfOut(cf_verbose,"","# Value fault-tolerance in version Nova and above\n"); return false; #endif } /*****************************************************************************/ void TranslatePath(char *new, const char *old) { #ifdef HAVE_NOVA Nova_TranslatePath(new,old); #else strncpy(new,old,CF_BUFSIZE-1); #endif } /*****************************************************************************/ /* Reporting */ /*****************************************************************************/ void SummarizeCompliance(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web) { #ifdef HAVE_NOVA Nova_SummarizeCompliance(xml,html,csv,embed,stylesheet,head,foot,web); #else CfOut(cf_verbose,"","# Compliance reporting feature is only available in version Nova and above\n"); #endif } /*****************************************************************************/ void SummarizeValue(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web) { #ifdef HAVE_NOVA Nova_SummarizeValue(xml,html,csv,embed,stylesheet,head,foot,web); #else CfOut(cf_verbose,"","# Value reporting feature is only available in version Nova and above - use the state/cf_value.log\n"); #endif } /*****************************************************************************/ void SummarizePromiseRepaired(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web) { #ifdef HAVE_NOVA Nova_SummarizePromiseRepaired(xml,html,csv,embed,stylesheet,head,foot,web); #else CfOut(cf_verbose,"","# Compliance reporting feature is only available in version Nova and above\n"); #endif } /*****************************************************************************/ void SummarizePromiseNotKept(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web) { #ifdef HAVE_NOVA Nova_SummarizePromiseNotKept(xml,html,csv,embed,stylesheet,head,foot,web); #else CfOut(cf_verbose,"","# Compliance reporting feature is only available in version Nova and above\n"); #endif } /*****************************************************************************/ void GrandSummary() { #ifdef HAVE_NOVA Nova_GrandSummary(); #else CfOut(cf_verbose,"","# Reporting feature is only available in version Nova and above\n"); #endif } /*****************************************************************************/ void CSV2XML(struct Rlist *list) { #ifdef HAVE_NOVA Nova_CSV2XML(list); #else CfOut(cf_verbose,"","# Format conversion feature is only available in version Nova and above\n"); #endif } /*****************************************************************************/ void SummarizeVariables(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web) { #ifdef HAVE_NOVA Nova_SummarizeVariables(xml,html,csv,embed,stylesheet,head,foot,web); #else CfOut(cf_verbose,"","# Variable reporting feature is only available in version Nova and above\n"); #endif } /*****************************************************************************/ void SummarizePerPromiseCompliance(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web) { #ifdef HAVE_NOVA Nova_SummarizePerPromiseCompliance(xml,html,csv,embed,stylesheet,head,foot,web); #else CfOut(cf_verbose,"","# Compliance reporting feature is only available in version Nova and above\n"); #endif } /*****************************************************************************/ void SummarizeFileChanges(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web) { #ifdef HAVE_NOVA Nova_SummarizeFileChanges(xml,html,csv,embed,stylesheet,head,foot,web); #else CfOut(cf_verbose,"","# File change reporting feature is only available in version Nova and above\n"); #endif } /*****************************************************************************/ void SummarizeSetuid(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web) { #ifdef HAVE_NOVA Nova_SummarizeSetuid(xml,html,csv,embed,stylesheet,head,foot,web); #else CfOut(cf_verbose,"","# Setuid reporting feature is only available in version Nova and above\n"); #endif } /*****************************************************************************/ void ReportPatches(struct CfPackageManager *list) { #ifdef HAVE_NOVA Nova_ReportPatches(list); #else CfOut(cf_verbose,"","# Patch reporting feature is only available in version Nova and above\n"); #endif } /*****************************************************************************/ void SummarizeSoftware(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web) { #ifdef HAVE_NOVA Nova_SummarizeSoftware(xml,html,csv,embed,stylesheet,head,foot,web); #else CfOut(cf_verbose,"","# Software summary reporting feature is only available in version Nova and above\n"); #endif } /*****************************************************************************/ void SummarizeUpdates(int xml,int html,int csv,int embed,char *stylesheet,char *head,char *foot,char *web) { #ifdef HAVE_NOVA Nova_SummarizeUpdates(xml,html,csv,embed,stylesheet,head,foot,web); #else CfOut(cf_verbose,"","# Software summary reporting feature is only available in version Nova and above\n"); #endif } /*****************************************************************************/ void VerifyServices(struct Attributes a,struct Promise *pp) { #ifdef HAVE_NOVA Nova_VerifyServices(a,pp); #else CfOut(cf_verbose,"","# Services promises are only available in Cfengine Nova and above"); #endif } /*****************************************************************************/ /* Montoring */ /*****************************************************************************/ void VerifyMeasurement(double *this,struct Attributes a,struct Promise *pp) { #ifdef HAVE_NOVA Nova_VerifyMeasurement(this,a,pp); #else CfOut(cf_verbose,"","# Custom monitoring feature is only available in version Nova and above\n"); #endif } /*****************************************************************************/ void LongHaul() { #ifdef HAVE_NOVA Nova_LongHaul(CFSTARTTIME); #endif } /*****************************************************************************/ void SetMeasurementPromises(struct Item **classlist) { #ifdef HAVE_NOVA Nova_SetMeasurementPromises(classlist); #else #endif } /*****************************************************************************/ /* ACLs */ /*****************************************************************************/ void VerifyACL(char *file,struct Attributes a, struct Promise *pp) { #ifdef HAVE_NOVA Nova_VerifyACL(file,a,pp); #else CfOut(cf_verbose, "", "Verifying ACL promises is only available with Cfengine Nova or above"); #endif } /*****************************************************************************/ int CheckACLSyntax(char *file,struct CfACL acl,struct Promise *pp) { #ifdef HAVE_NOVA return Nova_CheckACLSyntax(file,acl,pp); #else return true; #endif } /*****************************************************************************/ /* Registry */ /*****************************************************************************/ void VerifyRegistryPromise(struct Attributes a,struct Promise *pp) { #ifdef HAVE_NOVA # ifdef NT Nova_VerifyRegistryPromise(a,pp); # endif #else #endif } /*****************************************************************************/ int GetRegistryValue(char *key,char *name,char *buf, int bufSz) { #ifdef HAVE_NOVA # ifdef NT return Nova_GetRegistryValueAsString(key, name, buf, bufSz); # endif return 0; #else return 0; #endif } /*****************************************************************************/ /* LDAP */ /*****************************************************************************/ #if !defined(HAVE_NOVA) void *CfLDAPValue(char *uri,char *dn,char *filter,char *name,char *scope,char *sec) { CfOut(cf_error, "", "LDAP support is available in Nova and above"); return NULL; } /*****************************************************************************/ void *CfLDAPList(char *uri,char *dn,char *filter,char *name,char *scope,char *sec) { CfOut(cf_error,"","LDAP support available in Nova and above"); return NULL; } /*****************************************************************************/ void *CfLDAPArray(char *array,char *uri,char *dn,char *filter,char *scope,char *sec) { CfOut(cf_error,"","LDAP support available in Nova and above"); return NULL; } /*****************************************************************************/ void *CfRegLDAP(char *uri,char *dn,char *filter,char *name,char *scope,char *regex,char *sec) { CfOut(cf_error,"","LDAP support available in Nova and above"); return NULL; } #endif /*****************************************************************************/ /* SQL */ /*****************************************************************************/ int CheckDatabaseSanity(struct Attributes a, struct Promise *pp) { #ifdef HAVE_NOVA return Nova_CheckDatabaseSanity(a,pp); #else return false; #endif } /*****************************************************************************/ int VerifyDatabasePromise(CfdbConn *cfdb,char *database,struct Attributes a,struct Promise *pp) { #ifdef HAVE_NOVA char query[CF_BUFSIZE],name[CF_MAXVARSIZE]; int found = false; CfOut(cf_verbose,""," -> Verifying promised database"); if (!cfdb->connected) { CfOut(cf_inform,"","Database %s is not connected\n",database); return false; } Nova_CreateDBQuery(cfdb->type,query); CfNewQueryDB(cfdb,query); if (cfdb->maxcolumns < 1) { CfOut(cf_error,""," !! The schema did not promise the expected number of fields - got %d expected >= %d\n",cfdb->maxcolumns,1); return false; } while(CfFetchRow(cfdb)) { strncpy(name,CfFetchColumn(cfdb,0),CF_MAXVARSIZE-1); CfOut(cf_verbose,""," ? ... discovered a database called \"%s\"",name); if (strcmp(name,database) == 0) { found = true; } } if (found) { CfOut(cf_verbose,""," -> Database \"%s\" exists on this connection",database); return true; } else { CfOut(cf_verbose,""," !! Database \"%s\" does not seem to exist on this connection",database); } if (a.database.operation && strcmp(a.database.operation,"drop") == 0) { if (a.transaction.action != cfa_warn && !DONTDO) { CfOut(cf_verbose,""," -> Attempting to delete the database %s",database); snprintf(query,CF_MAXVARSIZE-1,"drop database %s",database); CfVoidQueryDB(cfdb,query); return cfdb->result; } else { CfOut(cf_error,""," !! Need to delete the database %s but only a warning was promised\n",database); return false; } } if (a.database.operation && strcmp(a.database.operation,"create") == 0) { if (a.transaction.action != cfa_warn && !DONTDO) { CfOut(cf_verbose,""," -> Attempting to create the database %s",database); snprintf(query,CF_MAXVARSIZE-1,"create database %s",database); CfVoidQueryDB(cfdb,query); return cfdb->result; } else { CfOut(cf_error,""," !! Need to create the database %s but only a warning was promised\n",database); return false; } } return false; #else CfOut(cf_verbose,"","Verifying SQL database promises is only available with Cfengine Nova or above"); return false; #endif } /*****************************************************************************/ int CfVerifyTablePromise(CfdbConn *cfdb,char *name,struct Rlist *columns,struct Attributes a,struct Promise *pp) { #ifdef HAVE_NOVA return Nova_VerifyTablePromise(cfdb,name,columns,a,pp); #else CfOut(cf_verbose,"","Verifying SQL table promises is only available with Cfengine Nova or above"); return false; #endif } /*****************************************************************************/ /* Misc */ /*****************************************************************************/ void NoteEfficiency(double e) { #ifdef HAVE_NOVA struct Attributes a = {{0}}; struct Promise p = {0}; NovaNamedEvent("Configuration model efficiency",e,a,&p); CfOut(cf_verbose,""," -> Configuration model efficiency for %s = %.2lf%%",VUQNAME,e); #endif } /*****************************************************************************/ char *GetProcessOptions() { #ifdef HAVE_GETZONEID zoneid_t zid; char zone[ZONENAME_MAX]; static char psopts[CF_BUFSIZE]; zid = getzoneid(); getzonenamebyid(zid,zone,ZONENAME_MAX); if (cf_strcmp(zone,"global") == 0) { snprintf(psopts,CF_BUFSIZE,"%s,zone",VPSOPTS[VSYSTEMHARDCLASS]); return psopts; } #endif #ifdef LINUX if (strncmp(VSYSNAME.release,"2.4",3) == 0) { // No threads on 2.4 kernels return "-eo user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,stime,time,args"; } #endif return VPSOPTS[VSYSTEMHARDCLASS]; } /*****************************************************************************/ int ForeignZone(char *s) { // We want to keep the banner if (strstr(s,"%CPU")) { return false; } #ifdef HAVE_GETZONEID zoneid_t zid; char *sp,zone[ZONENAME_MAX]; static psopts[CF_BUFSIZE]; zid = getzoneid(); getzonenamebyid(zid,zone,ZONENAME_MAX); if (cf_strcmp(zone,"global") == 0) { if (cf_strcmp(s+strlen(s)-6,"global") == 0) { *(s+strlen(s)-6) = '\0'; for (sp = s+strlen(s)-1; isspace(*sp); sp--) { *sp = '\0'; } return false; } else { return true; } } #endif return false; } /*****************************************************************************/ int GetInstalledPkgsRpath(struct CfPackageItem **pkgList, struct Attributes a, struct Promise *pp) { #ifdef HAVE_NOVA return Nova_GetInstalledPkgsRpath(pkgList, a, pp); #else CfOut(cf_error, "", "!! rPath internal package listing only available in Nova or above"); return false; #endif } /*****************************************************************************/ int ExecPackageCommandRpath(char *command,int verify,int setCmdClasses,struct Attributes a,struct Promise *pp) { #ifdef HAVE_NOVA return Nova_ExecPackageCommandRpath(command,verify,setCmdClasses,a,pp); #else CfOut(cf_error, "", "!! rPath internal package commands only available in Nova or above"); return false; #endif } /*****************************************************************************/ void AddGoalsToDB(char *goal_patterns, char *goal_categories) { #ifdef HAVE_NOVA Nova_AddGoalsToDB(goal_patterns,goal_categories); #endif } /*****************************************************************************/ �������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/item-lib.c�����������������������������������������������������������������������0000644�0001750�0001750�00000074200�11715232734�012664� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ /* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: item-lib.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int OrderedListsMatch(struct Item *list1,struct Item *list2); static int IsClassedItemIn(struct Item *list,char *item); static int IsFuzzyItemIn(struct Item *list, char *item); static void IdempAppendItem(struct Item **liststart,char *itemstring,char *classes); static int ItemListsEqual(struct Item *list1, struct Item *list2,int report,struct Attributes a,struct Promise *pp); static struct Item *NextItem(struct Item *ip); /*********************************************************************/ int ItemListSize(struct Item *list) { int size = 0; struct Item *ip; for (ip = list; ip != NULL; ip=ip->next) { if (ip->name) { size += strlen(ip->name); } } return size; } /*********************************************************************/ void PurgeItemList(struct Item **list,char *name) { struct Item *ip,*copy = NULL; struct stat sb; CopyList(©,*list); for (ip = copy; ip != NULL; ip=ip->next) { if (cfstat(ip->name,&sb) == -1) { CfOut(cf_verbose,""," -> Purging file \"%s\" from %s list as it no longer exists",ip->name,name); DeleteItemLiteral(list,ip->name); } } DeleteItemList(copy); } /*********************************************************************/ struct Item *ReturnItemIn(struct Item *list,char *item) { struct Item *ptr; if ((item == NULL) || (strlen(item) == 0)) { return NULL; } for (ptr = list; ptr != NULL; ptr=ptr->next) { if (strcmp(ptr->name,item) == 0) { return ptr; } } return NULL; } /*********************************************************************/ struct Item *ReturnItemInClass(struct Item *list,char *item,char *classes) { struct Item *ptr; if ((item == NULL) || (strlen(item) == 0)) { return NULL; } for (ptr = list; ptr != NULL; ptr=ptr->next) { if (strcmp(ptr->name,item) == 0 && strcmp(ptr->classes,classes) == 0) { return ptr; } } return NULL; } /*********************************************************************/ struct Item *ReturnItemAtIndex(struct Item *list,int index) { struct Item *ptr; int i = 0; for (ptr = list; ptr != NULL; ptr=ptr->next) { if (i == index) { return ptr; } i++; } return NULL; } /*********************************************************************/ int GetItemIndex(struct Item *list,char *item) /* * Returns index of first occurence of item. */ { struct Item *ptr; int i = 0; if ((item == NULL) || (strlen(item) == 0)) { return -1; } for (ptr = list; ptr != NULL; ptr=ptr->next) { if (strcmp(ptr->name,item) == 0) { return i; } i++; } return -1; } /*********************************************************************/ int IsItemIn(struct Item *list,const char *item) { struct Item *ptr; if ((item == NULL) || (strlen(item) == 0)) { return true; } for (ptr = list; ptr != NULL; ptr=ptr->next) { if (strcmp(ptr->name,item) == 0) { return(true); } } return(false); } /*********************************************************************/ struct Item *EndOfList(struct Item *start) { struct Item *ip, *prev = CF_UNDEFINED_ITEM; for (ip = start; ip != NULL; ip=ip->next) { prev = ip; } return prev; } /*********************************************************************/ int IsItemInRegion(char *item,struct Item *begin_ptr,struct Item *end_ptr,struct Attributes a,struct Promise *pp) { struct Item *ip; for (ip = begin_ptr; (ip != end_ptr && ip != NULL); ip = ip->next) { if (MatchPolicy(item,ip->name,a,pp)) { return true; } } return false; } /*********************************************************************/ struct Item *IdempPrependItem(struct Item **liststart,char *itemstring,char *classes) { struct Item *ip; ip = ReturnItemIn(*liststart,itemstring); if (ip) { return ip; } PrependItem(liststart,itemstring,classes); return *liststart; } /*********************************************************************/ struct Item *IdempPrependItemClass(struct Item **liststart,char *itemstring,char *classes) { struct Item *ip; ip = ReturnItemInClass(*liststart,itemstring,classes); if (ip) // already exists { return ip; } PrependItem(liststart,itemstring,classes); return *liststart; } /*********************************************************************/ void IdempItemCount(struct Item **liststart,char *itemstring,char *classes) { struct Item *ip; if ((ip = ReturnItemIn(*liststart,itemstring))) { ip->counter++; } else { PrependItem(liststart,itemstring,classes); } // counter+1 is the histogram of occurrences } /*********************************************************************/ static void IdempAppendItem(struct Item **liststart,char *itemstring,char *classes) { if (!IsItemIn(*liststart,itemstring)) { AppendItem(liststart,itemstring,classes); } } /*********************************************************************/ struct Item *PrependItem(struct Item **liststart,const char *itemstring,const char *classes) { struct Item *ip; char *sp,*spe = NULL; if ((ip = (struct Item *)malloc(sizeof(struct Item))) == NULL) { FatalError("memory allocation in prepend item"); } if ((sp = malloc(strlen(itemstring)+2)) == NULL) { FatalError("memory allocation in prepend item"); } if ((classes != NULL) && (spe = malloc(strlen(classes)+2)) == NULL) { FatalError("Memory allocation in prepend item"); } strcpy(sp,itemstring); ip->name = sp; ip->next = *liststart; ip->counter = 0; ip->time = 0; *liststart = ip; if (classes != NULL) { strcpy(spe,classes); ip->classes = spe; } else { ip->classes = NULL; } return *liststart; } /*********************************************************************/ void PrependFullItem(struct Item **liststart,char *itemstring,char *classes,int counter,time_t t) { struct Item *ip; char *sp,*spe = NULL; if ((ip = (struct Item *)malloc(sizeof(struct Item))) == NULL) { FatalError("memory allocation in prepend item"); } if ((sp = malloc(strlen(itemstring)+2)) == NULL) { FatalError("memory allocation in prepend item"); } if ((classes != NULL) && (spe = malloc(strlen(classes)+2)) == NULL) { FatalError("Memory allocation in prepend item"); } strcpy(sp,itemstring); ip->name = sp; ip->next = *liststart; ip->counter = counter; ip->time = t; *liststart = ip; if (classes != NULL) { strcpy(spe,classes); ip->classes = spe; } else { ip->classes = NULL; } } /*********************************************************************/ void AppendItem(struct Item **liststart, const char *itemstring,char *classes) { struct Item *ip, *lp; if ((ip = (struct Item *)malloc(sizeof(struct Item))) == NULL) { CfOut(cf_error,"malloc","Failed to alloc in AppendItemList"); FatalError(""); } if ((ip->name = strdup(itemstring)) == NULL) { CfOut(cf_error,"strdup","Failed to alloc in AppendItemList"); FatalError(""); } if (*liststart == NULL) { *liststart = ip; } else { for (lp = *liststart; lp->next != NULL; lp=lp->next) { } lp->next = ip; } ip->next = NULL; ip->counter = 0; if (classes) { ip->classes = strdup(classes); /* unused now */ } else { ip->classes = NULL; } } /*********************************************************************/ void PrependItemList(struct Item **liststart,char *itemstring) { struct Item *ip; if ((ip = (struct Item *)malloc(sizeof(struct Item))) == NULL) { CfOut(cf_error,"malloc","Memory failure in Prepend"); FatalError(""); } if ((ip->name = strdup(itemstring)) == NULL) { CfOut(cf_error,"malloc","Memory failure in Prepend"); FatalError(""); } ip->next = *liststart; ip->counter = 0; *liststart = ip; ip->classes = NULL; /* unused */ } /*********************************************************************/ int ListLen(struct Item *list) { int count = 0; struct Item *ip; Debug("Check ListLen\n"); for (ip = list; ip != NULL; ip=ip->next) { count++; } return count; } /*********************************************************************/ int RawSaveItemList(struct Item *liststart,char *file) { struct Item *ip; char new[CF_BUFSIZE],backup[CF_BUFSIZE]; FILE *fp; time_t STAMPNOW; STAMPNOW = time((time_t *)NULL); strcpy(new,file); strcat(new,CF_EDITED); strcpy(backup,file); strcat(backup,CF_SAVED); unlink(new); /* Just in case of races */ if ((fp = fopen(new,"w")) == NULL) { CfOut(cf_error,"fopen","Couldn't write file %s\n",new); return false; } for (ip = liststart; ip != NULL; ip=ip->next) { fprintf(fp,"%s\n",ip->name); } if (fclose(fp) == -1) { CfOut(cf_error,"fclose","Unable to close file while writing"); return false; } if (cf_rename(new,file) == -1) { CfOut(cf_inform,"cf_rename","Error while renaming %s\n",file); return false; } return true; } /***************************************************************************/ void CopyList (struct Item **dest, struct Item *source) /* Copy or concat lists */ { struct Item *ip; if (*dest != NULL) { FatalError("CopyList - list not initialized"); } if (source == NULL) { return; } for (ip = source; ip != NULL; ip = ip ->next) { AppendItem(dest,ip->name,ip->classes); } } /*********************************************************************/ struct Item *ConcatLists (struct Item *list1,struct Item *list2) /* Notes: * Refrain from freeing list2 after using ConcatLists * list1 must have at least one element in it */ { struct Item *endOfList1; if (list1 == NULL) { FatalError("ConcatLists: first argument must have at least one element"); } for (endOfList1=list1; endOfList1->next!=NULL; endOfList1=endOfList1->next) { } endOfList1->next = list2; return list1; } /***************************************************************************/ /* Search */ /***************************************************************************/ int SelectItemMatching(struct Item *start,char *regex,struct Item *begin_ptr,struct Item *end_ptr,struct Item **match,struct Item **prev,char *fl) { struct Item *ip; int ret = false; *match = CF_UNDEFINED_ITEM; *prev = CF_UNDEFINED_ITEM; if (regex == NULL) { return false; } if (fl && (strcmp(fl,"first") == 0)) { if (SelectNextItemMatching(regex,begin_ptr,end_ptr,match,prev)) { ret = true; } } else { if (SelectLastItemMatching(regex,begin_ptr,end_ptr,match,prev)) { ret = true; } } if (*match != CF_UNDEFINED_ITEM && *prev == CF_UNDEFINED_ITEM) { for (ip = start; ip != NULL && ip != *match; ip = ip->next) { *prev = ip; } } return ret; } /*********************************************************************/ int SelectNextItemMatching(char *regexp,struct Item *begin,struct Item *end,struct Item **match,struct Item **prev) { struct Item *ip,*ip_prev = CF_UNDEFINED_ITEM; *match = CF_UNDEFINED_ITEM; *prev = CF_UNDEFINED_ITEM; for (ip = begin; ip != end; ip=ip->next) { if (ip->name == NULL) { continue; } if (FullTextMatch(regexp,ip->name)) { *match = ip; *prev = ip_prev; return true; } ip_prev = ip; } return false; } /*********************************************************************/ int SelectLastItemMatching(char *regexp,struct Item *begin,struct Item *end,struct Item **match,struct Item **prev) { struct Item *ip,*ip_last = NULL,*ip_prev = CF_UNDEFINED_ITEM; *match = CF_UNDEFINED_ITEM; *prev = CF_UNDEFINED_ITEM; for (ip = begin; ip != end; ip=ip->next) { if (ip->name == NULL) { continue; } if (FullTextMatch(regexp,ip->name)) { *prev = ip_prev; ip_last = ip; } ip_prev = ip; } if (ip_last) { *match = ip_last; return true; } return false; } /*********************************************************************/ int MatchRegion(char *chunk,struct Item *start,struct Item *begin,struct Item *end) /* Match a region in between the selection delimiters. It is called after SelectRegion. The end delimiter will be visible here so we have to check for it. */ { struct Item *ip = begin; char *sp,buf[CF_BUFSIZE]; int lines = 0; for (sp = chunk; sp <= chunk+strlen(chunk); sp++) { memset(buf,0,CF_BUFSIZE); sscanf(sp,"%[^\n]",buf); sp += strlen(buf); if (ip == NULL) { return false; } if (!FullTextMatch(buf,ip->name)) { return false; } lines++; // We have to manually exclude the marked terminator if (ip == end) { return false; } // Now see if there is more if (ip->next) { ip = ip->next; } else // if the region runs out before the end { if (++sp <= chunk+strlen(chunk)) { return false; } break; } } return lines; } /*********************************************************************/ /* Level */ /*********************************************************************/ void InsertAfter(struct Item **filestart,struct Item *ptr,char *string) { struct Item *ip; if (*filestart == NULL || ptr == CF_UNDEFINED_ITEM) { AppendItem(filestart,string,NULL); return; } if (ptr == NULL) { AppendItem(filestart,string,NULL); return; } if ((ip = (struct Item *)malloc(sizeof(struct Item))) == NULL) { CfOut(cf_error,"","Can't allocate memory in InsertAfter()"); FatalError(""); } ip->next = ptr->next; ptr->next = ip; ip->name = strdup(string); ip->classes = NULL; } /*********************************************************************/ int NeighbourItemMatches(struct Item *file_start,struct Item *location,char *string,enum cfeditorder pos,struct Attributes a,struct Promise *pp) { struct Item *ip; /* Look for a line matching proposed insert before or after location */ for (ip = file_start; ip != NULL; ip = ip->next) { if (pos == cfe_before) { if (ip->next && ip->next == location) { if (MatchPolicy(string,ip->name,a,pp)) { return true; } else { return false; } } } if (pos == cfe_after) { if (ip == location) { if (ip->next && MatchPolicy(string,ip->next->name,a,pp)) { return true; } else { return false; } } } } return false; } /*********************************************************************/ struct Item *SplitString(char *string,char sep) /* Splits a string containing a separator like : into a linked list of separate items, */ { struct Item *liststart = NULL; char *sp; char before[CF_BUFSIZE]; int i = 0; Debug("SplitString([%s],%c=%d)\n",string,sep,sep); for (sp = string; (*sp != '\0') ; sp++,i++) { before[i] = *sp; if (*sp == sep) { /* Check the listsep is not escaped*/ if ((sp > string) && (*(sp-1) != '\\')) { before[i] = '\0'; AppendItem(&liststart,before,NULL); i = -1; } else if ((sp > string) && (*(sp-1) == '\\')) { i--; before[i] = sep; } else { before[i] = '\0'; AppendItem(&liststart,before,NULL); i = -1; } } } before[i] = '\0'; AppendItem(&liststart,before,""); return liststart; } /*********************************************************************/ struct Item *SplitStringAsItemList(char *string,char sep) /* Splits a string containing a separator like : into a linked list of separate items, */ { struct Item *liststart = NULL; char format[9], *sp; char node[CF_MAXVARSIZE]; Debug("SplitStringAsItemList(%s,%c)\n",string,sep); sprintf(format,"%%255[^%c]",sep); /* set format string to search */ for (sp = string; *sp != '\0'; sp++) { memset(node,0,CF_MAXVARSIZE); sscanf(sp,format,node); if (strlen(node) == 0) { continue; } sp += strlen(node)-1; AppendItem(&liststart,node,NULL); if (*sp == '\0') { break; } } return liststart; } /*********************************************************************/ char *ItemList2CSV(struct Item *list) { struct Item *ip; int len = 0; char *s; for (ip = list; ip != NULL; ip=ip->next) { len += strlen(ip->name) + 1; } s = malloc(len+1); *s = '\0'; for (ip = list; ip != NULL; ip=ip->next) { strcat(s,ip->name); if (ip->next) { strcat(s,","); } } return s; } /*********************************************************************/ /* Basic operations */ /*********************************************************************/ void IncrementItemListCounter(struct Item *list,char *item) { struct Item *ptr; if ((item == NULL) || (strlen(item) == 0)) { return; } for (ptr = list; ptr != NULL; ptr=ptr->next) { if (strcmp(ptr->name,item) == 0) { ptr->counter++; return; } } } /*********************************************************************/ void SetItemListCounter(struct Item *list,char *item,int value) { struct Item *ptr; if ((item == NULL) || (strlen(item) == 0)) { return; } for (ptr = list; ptr != NULL; ptr=ptr->next) { if (strcmp(ptr->name,item) == 0) { ptr->counter = value; return; } } } /*********************************************************************/ int IsMatchItemIn(struct Item *list,char *item) /* Solve for possible regex/fuzzy models unified */ { struct Item *ptr; if ((item == NULL) || (strlen(item) == 0)) { return true; } for (ptr = list; ptr != NULL; ptr=ptr->next) { if (FuzzySetMatch(ptr->name,item) == 0) { return(true); } if (IsRegex(ptr->name)) { if (FullTextMatch(ptr->name,item)) { return(true); } } } return(false); } /*********************************************************************/ static int IsFuzzyItemIn(struct Item *list,char *item) /* This is for matching ranges of IP addresses, like CIDR e.g. Range1 = ( 128.39.89.250/24 ) Range2 = ( 128.39.89.100-101 ) */ { struct Item *ptr; Debug("\nFuzzyItemIn(LIST,%s)\n",item); if ((item == NULL) || (strlen(item) == 0)) { return true; } for (ptr = list; ptr != NULL; ptr=ptr->next) { Debug(" Try FuzzySetMatch(%s,%s)\n",ptr->name,item); if (FuzzySetMatch(ptr->name,item) == 0) { return(true); } } return(false); } /*********************************************************************/ void DeleteItemList(struct Item *item) /* delete starting from item */ { struct Item *ip, *next; for(ip = item; ip != NULL; ip = next) { next = ip->next; // save before free if (ip->name != NULL) { free (ip->name); } if (ip->classes != NULL) { free (ip->classes); } free((char *)ip); } } /*********************************************************************/ void DeleteItem(struct Item **liststart,struct Item *item) { struct Item *ip, *sp; if (item != NULL) { if (item->name != NULL) { free(item->name); } if (item->classes != NULL) { free(item->classes); } sp = item->next; if (item == *liststart) { *liststart = sp; } else { for (ip = *liststart; ip != NULL && ip->next != item && ip->next != NULL; ip=ip->next) { } if (ip != NULL) { ip->next = sp; } } free((char *)item); } } /*********************************************************************/ void DebugListItemList(struct Item *liststart) { struct Item *ptr; for (ptr = liststart; ptr != NULL; ptr=ptr->next) { if (ptr->classes) { printf("CFDEBUG: %s::[%s]\n",ptr->classes,ptr->name); } else { printf("CFDEBUG: [%s]\n",ptr->name); } } } /*********************************************************************/ static int ItemListsEqual(struct Item *list1,struct Item *list2,int warnings,struct Attributes a,struct Promise *pp) // Some complex logic here to enable warnings of diffs to be given { struct Item *ip1, *ip2; int retval = true; ip1 = list1; ip2 = list2; while (true) { if ((ip1 == NULL) && (ip2 == NULL)) { return retval; } if ((ip1 == NULL) || (ip2 == NULL)) { if (warnings) { if (ip1 == list1 || ip2 == list2) { cfPS(cf_error,CF_WARN,"",pp,a," ! File content wants to change from from/to full/empty but only a warning promised"); } else { if (ip1 != NULL) { cfPS(cf_error,CF_WARN,"",pp,a," ! edit_line change warning promised: (remove) %s",ip1->name); } if (ip2 != NULL) { cfPS(cf_error,CF_WARN,"",pp,a," ! edit_line change warning promised: (add) %s",ip2->name); } } } if (warnings) { if (ip1 || ip2) { retval = false; ip1 = NextItem(ip1); ip2 = NextItem(ip2); continue; } } return false; } if (strcmp(ip1->name,ip2->name) != 0) { if (!warnings) { // No need to wait return false; } else { // If we want to see warnings, we need to scan the whole file cfPS(cf_error,CF_WARN,"",pp,a," ! edit_line warning promised: - %s",ip1->name); cfPS(cf_error,CF_WARN,"",pp,a," ! edit_line warning promised: + %s",ip2->name); retval = false; } } ip1 = NextItem(ip1); ip2 = NextItem(ip2); } return retval; } /*********************************************************************/ static int OrderedListsMatch(struct Item *list1,struct Item *list2) { struct Item *ip1,*ip2; for (ip1 = list1,ip2 = list2; (ip1!=NULL)&&(ip2!=NULL); ip1=ip1->next,ip2=ip2->next) { if (strcmp(ip1->name,ip2->name) != 0) { Debug("OrderedListMatch failed on (%s,%s)\n",ip1->name,ip2->name); return false; } } if (ip1 != ip2) { return false; } return true; } /*********************************************************************/ static int IsClassedItemIn(struct Item *list,char *item) { struct Item *ptr; if ((item == NULL) || (strlen(item) == 0)) { return true; } for (ptr = list; ptr != NULL; ptr=ptr->next) { if (strcmp(ptr->name,item) == 0) { if (IsExcluded(ptr->classes)) { continue; } return(true); } } return(false); } /*********************************************************************/ /* DeleteItem* function notes: * -They all take an item list and an item specification ("string" argument.) * -Some of them treat the item spec as a literal string, while others * treat it as a regular expression. * -They all delete the first item meeting their criteria, as below. * function deletes item * ------------------------------------------------------------------------ * DeleteItemStarting start is literally equal to string item spec * DeleteItemLiteral literally equal to string item spec * DeleteItemMatching fully matched by regex item spec * DeleteItemContaining containing string item spec */ /*********************************************************************/ int DeleteItemGeneral(struct Item **list,char *string,enum matchtypes type) { struct Item *ip,*last = NULL; int match = 0, matchlen = 0; if (list == NULL) { return false; } switch (type) { case literalStart: matchlen = strlen(string); break; case regexComplete: case NOTregexComplete: break; } for (ip = *list; ip != NULL; ip=ip->next) { if (ip->name == NULL) { continue; } switch(type) { case NOTliteralStart: match = (strncmp(ip->name, string, matchlen) != 0); break; case literalStart: match = (strncmp(ip->name, string, matchlen) == 0); break; case NOTliteralComplete: match = (strcmp(ip->name, string) != 0); break; case literalComplete: match = (strcmp(ip->name, string) == 0); break; case NOTliteralSomewhere: match = (strstr(ip->name, string) == NULL); break; case literalSomewhere: match = (strstr(ip->name, string) != NULL); break; case NOTregexComplete: case regexComplete: /* To fix a bug on some implementations where rx gets emptied */ match = FullTextMatch(string,ip->name); if (type == NOTregexComplete) { match = !match; } break; } if (match) { if (ip == *list) { free((*list)->name); if (ip->classes != NULL) { free(ip->classes); } *list = ip->next; free((char *)ip); return true; } else { if (ip != NULL) { if (last != NULL) { last->next = ip->next; } free(ip->name); if (ip->classes != NULL) { free(ip->classes); } free((char *)ip); } return true; } } last = ip; } return false; } /*********************************************************************/ int DeleteItemStarting(struct Item **list,char *string) /* delete 1st item starting with string */ { return DeleteItemGeneral(list,string,literalStart); } /*********************************************************************/ int DeleteItemNotStarting(struct Item **list,char *string) /* delete 1st item starting with string */ { return DeleteItemGeneral(list,string,NOTliteralStart); } /*********************************************************************/ int DeleteItemLiteral(struct Item **list,char *string) /* delete 1st item which is string */ { return DeleteItemGeneral(list,string,literalComplete); } /*********************************************************************/ int DeleteItemMatching(struct Item **list,char *string) /* delete 1st item fully matching regex */ { return DeleteItemGeneral(list,string,regexComplete); } /*********************************************************************/ int DeleteItemNotMatching(struct Item **list,char *string) /* delete 1st item fully matching regex */ { return DeleteItemGeneral(list,string,NOTregexComplete); } /*********************************************************************/ int DeleteItemContaining(struct Item **list,char *string) /* delete first item containing string */ { return DeleteItemGeneral(list,string,literalSomewhere); } /*********************************************************************/ int DeleteItemNotContaining(struct Item **list,char *string) /* delete first item containing string */ { return DeleteItemGeneral(list,string,NOTliteralSomewhere); } /*********************************************************************/ int CompareToFile(struct Item *liststart,char *file,struct Attributes a,struct Promise *pp) /* returns true if file on disk is identical to file in memory */ { struct stat statbuf; struct Item *cmplist = NULL; Debug("CompareToFile(%s)\n",file); if (cfstat(file,&statbuf) == -1) { return false; } if (liststart == NULL && statbuf.st_size == 0) { return true; } if (liststart == NULL) { return false; } if (!LoadFileAsItemList(&cmplist,file,a,pp)) { return false; } if (!ItemListsEqual(cmplist,liststart,(a.transaction.action == cfa_warn),a,pp)) { DeleteItemList(cmplist); return false; } DeleteItemList(cmplist); return (true); } /*********************************************************************/ int ByteSizeList(const struct Item *list) { int count = 0; const struct Item *ip; for (ip = list; ip; ip = ip->next) { count += strlen(ip->name); } return count; } /*********************************************************************/ /* helpers */ /*********************************************************************/ struct Item *NextItem(struct Item *ip) { if (ip) { return ip->next; } else { return NULL; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/verify_files.c�������������������������������������������������������������������0000644�0001750�0001750�00000004737�11715232734�013660� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: verify_files.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void FindFilePromiserObjects(struct Promise *pp); /*****************************************************************************/ void *FindAndVerifyFilesPromises(struct Promise *pp) { PromiseBanner(pp); FindFilePromiserObjects(pp); if (AM_BACKGROUND_PROCESS && !pp->done) { CfOut(cf_verbose,"","Exiting backgrounded promise"); PromiseRef(cf_verbose,pp); exit(0); } return (void *)NULL; } /*****************************************************************************/ static void FindFilePromiserObjects(struct Promise *pp) { char *val = GetConstraint("pathtype",pp,CF_SCALAR); int literal = GetBooleanConstraint("copy_from",pp) || ((val != NULL) && (strcmp(val,"literal") == 0)); /* Check if we are searching over a regular expression */ if (literal) { // Prime the promiser temporarily, may override later NewScalar("this","promiser",pp->promiser,cf_str); VerifyFilePromise(pp->promiser,pp); } else // Default is to expand regex paths { LocateFilePromiserGroup(pp->promiser,pp,VerifyFilePromise); } } ���������������������������������cfengine-3.2.4/src/agentdiagnostic.c����������������������������������������������������������������0000644�0001750�0001750�00000177147�11715232734�014343� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: selfdiagnostic.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void TestSearchFilePromiser(); /*****************************************************************************/ /* new test suite */ /*****************************************************************************/ #ifdef BUILD_TESTSUITE #include "testoutput.h" #include "testinput.h" // types: 1-100 #define CF_FILE 1 #define CF_DIR 2 #define CF_POLICY 3 #define CF_PROCESS 4 #define CF_LINE 5 #define CF_LINES 6 #define CF_EXTERNAL 7 #define CF_FILE_TEXT "file" #define CF_DIR_TEXT "dir" #define CF_POLICY_TEXT "policy" #define CF_PROCESS_TEXT "process" #define CF_LINE_TEXT "line" #define CF_LINES_TEXT "lines" #define CF_EXTERNAL_TEXT "external" // actions: 101-200 #define CF_ACCESS 101 #define CF_BACKUP 102 #define CF_DELETE 103 #define CF_RESTORE 104 #define CF_EXISTS 105 #define CF_NOTEXISTS 106 #define CF_EXECUTE 107 #define CF_CREATE 108 // prepare actions (checks) // #define CF_LINEEXISTS 109 // TODO: or line("some text", filename, EXISTS) ?? // due to parser limitations, this cannot be distinguished as either a type or an action; Used as action for now // #define CF_LINEEXISTS_TEXT "line_exists" #define CF_ACCESS_TEXT "ACCESS" #define CF_BACKUP_TEXT "BACKUP" #define CF_DELETE_TEXT "DELETE" #define CF_RESTORE_TEXT "RESTORE" #define CF_EXISTS_TEXT "EXISTS" #define CF_NOTEXISTS_TEXT "NOTEXISTS" #define CF_EXECUTE_TEXT "EXECUTE" #define CF_CREATE_TEXT "CREATE" // sub sections: 201-220, #define CF_VARS 201 #define CF_PRE 202 #define CF_EXEC 203 #define CF_OUT 204 #define CF_CLEAN 205 #define CF_CLASS 206 #define CF_VARS_TEXT "vars" #define CF_PRE_TEXT "prepare" #define CF_EXEC_TEXT "execute" #define CF_OUT_TEXT "output" #define CF_CLEAN_TEXT "cleanup" #define CF_CLASS_TEXT "class" // CF TESTSUITE CONSTANTS #define CF_MAX_TESTS 100 #define CF_VARSIZE 20 // Output types: 501-600 #define CF_OUT_REPORT 501 #define CF_OUT_ADDLINE 502 //add line to a file #define CF_OUT_REMOVELINE 503 #define CF_OUT_KILLPROCESS 504 #define CF_OUT_STARTPROCESS 505 #define CF_OUT_STARTSERVICE 506 #define CF_OUT_STOPSERVICE 507 #define CF_OUT_INFO 508 // when running with -I option #define CF_OUT_ADDUSER 509 #define CF_OUT_REMOVEUSER 510 #define CF_OUT_ADDLINES 511 #define CF_OUT_REMOVELINES 512 #define CF_OUT_REPORTS 513 #define CF_OUT_USEREXISTS 514 #define CF_OUT_FILEPERMS 515 #define CF_OUT_OWNER 516 #define CF_OUT_ISLINK 517 #define CF_OUT_LINKEDTO 518 #define CF_REPORT_TEXT "report" #define CF_ADDLINE_TEXT "addline" #define CF_REMOVELINE_TEXT "removeline" #define CF_KILLPROCESS_TEXT "killprocess" #define CF_STARTPROCESS_TEXT "startprocess" #define CF_STARTSERVICE_TEXT "startservice" #define CF_STOPSERICE_TEXT "stopservice" #define CF_INFO_TEXT "info" // when running with -I option #define CF_ADDUSER_TEXT "adduser" #define CF_REMOVEUSER_TEXT "removeuser" #define CF_ADDLINES_TEXT "addlines" #define CF_REMOVELINES_TEXT "removelines" #define CF_REPORTS_TEXT "reports" #define CF_USEREXISTS_TEXT "userexists" #define CF_FILEPERMS_TEXT "checkfileperms" #define CF_OWNER_TEXT "checkowner" #define CF_ISLINK_TEXT "islink" #define CF_LINKEDTO_TEXT "linkedto" #define CF_ALL_TEXT "all" #define CF_REPORT_TEXT "report" #define CF_SLIST_TEXT "slist" #define CF_STRING_TEXT "string" #define CF_PROCESS_TEXT "process" #define CF_FILE_TEXT "file" #define CF_DIR_TEXT "dir" #define CF_CMD_TEXT "cmd" #define CF_OTHER_TEXT "other" #define CF_TOP10_TEXT "top10" // predefined operations #define BOOTSTRAP_TEXT "bootstrap" #define BOOTSTRAP 601 // Functions: 701 - + #define CF_FXN_APPENDLINE 701 #define CF_APPENDLINE_TEXT "appendLine" #define CF_FXN_CMPENV 702 #define CF_GETENV_TEXT "cmpEnv" #define CF_FXN_CLEARENV 703 #define CF_CLEARENV_TEXT "clearEnv" /*****************************************************************************/ struct vars { char name[CF_VARSIZE]; int value; // 0 = pass, 1 = fail int index; }; /*****************************************************************************/ struct line_data { int type; int action; char text[CF_BUFSIZE]; char buf[CF_SMALLBUF]; int var_index; }; /*****************************************************************************/ struct decision { int var_index; int value; }; /*****************************************************************************/ struct input { char id[CF_SMALLBUF]; int predefinedId; struct line_data PRE[10]; int nPre; char policy_file[CF_SMALLBUF]; char policy_opt[5]; struct line_data expected[10]; int nOutput; struct line_data POST[5]; int nPost; struct vars internal[10]; // just 10 variables for now struct decision PASS_IF[10]; int nVar; int test_class; }; /*****************************************************************************/ struct cfoutput { char id[CF_SMALLBUF]; char output[CF_EXPANDSIZE]; int exec_ok; int pass; struct decision results[10]; // variable results }; /*****************************************************************************/ /* new test suite */ /*****************************************************************************/ /*****************************************************************************/ /* Prototypes */ /*****************************************************************************/ void TestSuite(char *s); struct input DATA[CF_MAX_TESTS]; int nInput; int GetLineCount(char *file); int LoadInput(struct cfoutput*, char*); int RunPolicies(struct cfoutput*, int, struct input*, int); int CompareOutput(struct cfoutput*, int, struct input*, int); int Parse(struct input*, char *); int GetSubSection(char *); int GetExec(char *, char *, char *); int GetExpectedOutput(char *, struct line_data *, char *); int GetPrepareCleanup(char *, struct line_data *, char *); int GetVarIndex(char *test_id, char *var); int GetType1(char *); int GetClassType(char *s); int RemoveChars(char *, char *); int RemoveComment(char *); // at the end of line int IsDuplicate(char*, struct input*, int); // Before execution of test: Prepare int DoIt(struct line_data*); int GetAction(char *); int CheckExists(struct line_data*); int AppendTextToFile(char *, char *); // Verify Output Section int FindTextInFile(char *str, char *f); int FindProcess(char *); int MemGetExpectedOutput(char *buf, char *name); // Show the results void ShowResults(struct cfoutput* a, int n1); //Cleanup int Cleanup(struct cfoutput*,struct input*, int ); // Utility methods long fsize(char *); int ReplaceCharTS(char *str, char to, char frm); int FlattenText(char *str); int GetOptions(int argc, char *argv[]); int MyCreate(struct line_data *); int ReadLineInput(char *dst, char *frm ); //used only for internal testing void PrintChars(char *); // check if the operation is predefined int CheckPredefined(char *); int ExecutePreDefined(int id, char *); int PerformBootstrap(char *); int FileExists(char *file); char TEST_ROOT_DIR[CF_BUFSIZE]; #endif static void CheckInstalledLibraries(void); /*****************************************************************************/ void AgentDiagnostic(char *file) { if (VERBOSE || DEBUG) { FREPORT_TXT = stdout; FREPORT_HTML = fopen(NULLFILE,"w"); FKNOW = fopen(NULLFILE,"w"); } else { FREPORT_TXT= fopen(NULLFILE,"w"); FREPORT_HTML= fopen(NULLFILE,"w"); FKNOW = fopen(NULLFILE,"w"); } //getcwd(cwd,CF_BUFSIZE); printf("----------------------------------------------------------\n"); printf("Cfengine 3 - Performing level 2 self-diagnostic (dialogue)\n"); printf("----------------------------------------------------------\n\n"); TestVariableScan(); TestExpandPromise(); TestExpandVariables(); //TestSearchFilePromiser(); CheckInstalledLibraries(); #ifdef BUILD_TESTSUITE if(file != NULL) { printf("----------------------------------------------------------\n"); printf("Cfengine 3 - Performing test suite \n"); printf("----------------------------------------------------------\n\n"); InitializeGA(0,NULL); TestSuite(file); } #else printf("!! Extensive self-diagnostic capabilities not built in\n"); #endif } /******************************************************************/ static void TestSearchFilePromiser() { struct Promise pp; /* Still have diagnostic scope */ THIS_AGENT_TYPE = cf_agent; pp.promiser = "the originator"; pp.promisee = "the recipient with $(two)"; pp.classes = "proletariat"; pp.petype = CF_SCALAR; pp.lineno = 12; pp.audit = NULL; pp.conlist = NULL; pp.agentsubtype = "none"; pp.bundletype = "bundle_type"; pp.bundle = "test_bundle"; pp.ref = "commentary"; pp.agentsubtype = strdup("files"); pp.done = false; pp.next = NULL; pp.cache = NULL; pp.inode_cache = NULL; pp.this_server = NULL; pp.donep = &(pp.done); pp.conn = NULL; printf("\nTestSearchFilePromiser(%s)\n\n",pp.promiser); LocateFilePromiserGroup(pp.promiser,&pp,VerifyFilePromise); pp.promiser = "/var/[^/]*/[c|l].*"; printf("\nTestSearchFilePromiser(%s)\n\n",pp.promiser); LocateFilePromiserGroup(pp.promiser,&pp,VerifyFilePromise); pp.promiser = "/var/[c|l][A-Za-z0-9_ ]*"; printf("\nTestSearchFilePromiser(%s)\n\n",pp.promiser); LocateFilePromiserGroup(pp.promiser,&pp,VerifyFilePromise); AppendConstraint(&(pp.conlist),"path","literal",CF_SCALAR,NULL,false); pp.promiser = "/var/[^/]*/[c|l].*"; printf("\nTestSearchFilePromiser(%s)\n\n",pp.promiser); LocateFilePromiserGroup(pp.promiser,&pp,VerifyFilePromise); pp.promiser = "/var/.*/h.*"; printf("\nTestSearchFilePromiser(%s)\n\n",pp.promiser); LocateFilePromiserGroup(pp.promiser,&pp,VerifyFilePromise); } /*******************************************************************************/ #ifdef BUILD_TESTSUITE void TestSuite(char *s) { char output[CF_EXPANDSIZE],command[CF_BUFSIZE], c[CF_BUFSIZE]; int i = 0, j = 0, nMap = 0, nInput = 0; if(s == NULL) { snprintf(s,CF_BUFSIZE,"%s","input.in"); return; } if(FileExists(s) != 1) { printf("\tFatal Error: Couldn't find file \"%s\"\n",s); return; } printf("\tParsing Input file (%s)... ",s); int count = Parse(DATA,s); printf("\tDone\n\n"); printf("\tNumber of tests = %d\n", count); printf("\tPrepare and run ... \n"); struct cfoutput ACTUAL[200]; int nErr = RunPolicies(ACTUAL, count, DATA, count); printf("\tDone\n\n"); // TODO: what to do if some cases failed? printf("\tComparing Outputs..."); int nFailed = CompareOutput(ACTUAL, count, DATA, count); printf("\tDone\n\n"); printf("\tCleaning up ..."); Cleanup(ACTUAL, DATA, count); printf("Done\n\n"); ShowResults(ACTUAL, count); //printf("\nFailed Tests count = %d\n", nFailed); } /*********************************************************/ int Cleanup(struct cfoutput *out, struct input *in, int n) { int i, j; for(i = 0; i < n; i++) { for(j = 0; j < in[i].nPost; j++) { if (DoIt(&in[i].POST[j]) > 0) { //if(strlen( in[i].internal[in[i].POST[j].var_index].name) > 0) { //actual[k].results[map[i].POST[j].var_index].value = 1; // actual[k].results[map[i].PRE[j].var_index].var_index = m$ } } } } return 0; } /*********************************************************/ int GetLineCount(char *f) { char line[400]; int i=0; FILE *in = fopen(f,"rb"); if (in == NULL) { printf("GetLineCount(): Error opening file: %s\n", f); return -1; } while (fgets(line,400,in)) { i++; } fclose(in); return i; } /*********************************************************/ int LoadInput(struct cfoutput *i, char *f) { char line[CF_SMALLBUF]; int n = 0, j; FILE *in = fopen(f,"rb"); if (in == NULL) { printf("LoadInput(): Error opening file: %s\n", f); return -1; } while (fgets(line,CF_SMALLBUF,in)) { // replace \n by \0 for (j=0;j<CF_SMALLBUF;j++) { if (line[j] == '\n' || j == (CF_SMALLBUF - 1)) { line[j] = '\0'; } } snprintf(i[n].id,CF_SMALLBUF, "%s",line); n++; } fclose(in); return n; } /*********************************************************/ int MyCreate(struct line_data *p) { struct Attributes a = {{0}}; char buf[CF_BUFSIZE]; char file[CF_BUFSIZE]; a.transaction.report_level = cf_noreport; snprintf(file,CF_BUFSIZE,"/tmp/%s",p->buf); switch(p->type) { case CF_FILE: if (CfCreateFile(file,NULL,a)) { Debug("MyCreate(): Created file \"%s\n ",file); return 1; } break; case CF_DIR: memset(buf, 0, CF_BUFSIZE); snprintf(buf, CF_BUFSIZE, "%s", file); strcat(buf, "/a"); if(MakeParentDirectory(buf,true)) { Debug("MyCreate(): Created dir \"%s\n ",p->buf); return 1; } break; } return -1; } /*********************************************************/ int DoIt(struct line_data *p) { char buf[CF_EXPANDSIZE]; char *pBuf = buf; struct Attributes a = {{0}}; char file[CF_BUFSIZE]; switch(p->action) { case CF_ACCESS: //101 snprintf(file,CF_BUFSIZE,"/tmp/%s",p->buf); if (CfCreateFile(file,NULL,a)) { Debug("DoIt(): Created file \"%s\" ",file); } sleep(1); // this is just a workaround (for time difference for the touch operation) //TODO: find better method TouchFile(file,NULL,a,NULL); break; case CF_BACKUP: //102 break; case CF_DELETE: //103 snprintf(file,CF_BUFSIZE,"/tmp/%s",p->buf); if(remove(file) == 0) { return 1; } break; case CF_RESTORE: // 104 break; case CF_EXISTS: //105 if(CheckExists(p) > 0) { //printf("DoIt(): Hurray!!! The line exists\n"); return 1; } break; case CF_NOTEXISTS: //106 if (CheckExists(p) < 0) { return 1; } break; case CF_EXECUTE: //106 if (GetExecOutput(p->text,buf,false)) { Debug("DoIt(): Output of \"%s\": %s\n", p->text, buf); } break; case CF_CREATE: if (MyCreate(p)) { return 1; } break; default: switch(p->type) { case CF_EXTERNAL: if (GetExecOutput(p->text,buf,false)) { Debug("DoIt(): Output of \"%s\": %s\n", p->text, buf); } break; case CF_OUT_FILEPERMS: break; case CF_FXN_APPENDLINE: //if (cfstat(m[j].expected[k].text, &sb) != -1) snprintf(file,CF_BUFSIZE,"%s/tests/regression_test/tmp/%s",TEST_ROOT_DIR,p->buf); strcat(file, "\n"); if (AppendTextToFile(p->buf, p->text) != -1) { } else { printf("DoIt(): Error writing to file: %s\n", p->buf); } break; case CF_FXN_CMPENV: memset(buf,0,CF_EXPANDSIZE); if ((pBuf = getenv(p->buf)) != NULL) { //if(strcmp) Debug("######## ENV = %s\n", buf); return 1; } break; case CF_FXN_CLEARENV: break; } } return -1; } /*********************************************************/ int CheckExists(struct line_data *p) { char *text; struct stat sb; char file[CF_BUFSIZE]; switch(p->type) { case CF_DIR: case CF_FILE: snprintf(file,CF_BUFSIZE,"/tmp/%s",p->buf); if(cfstat(p->buf, &sb) == 0) { // printf("\"%s\" exists!!\n", p->buf); return 1; } // printf("\"%s\" doesn't exist or you don't have enough permissions!!\n", p->buf); break; case CF_PROCESS: break; case CF_OUT_REMOVELINE: case CF_OUT_ADDLINE: case CF_LINE: if ((strlen(p->buf) < 1) || (strlen(p->text) < 1)) { return -1; } snprintf(file,CF_BUFSIZE,"/tmp/%s",p->buf); if(FindTextInFile(p->text, p->buf) > 0) { return 1; } break; case CF_OUT_REMOVELINES: case CF_OUT_ADDLINES: case CF_LINES: if((strlen(p->buf) < 1) || (strlen(p->text) < 1)) { return -1; } text = (char *) malloc(CF_BUFSIZE * sizeof(char)); if(text == NULL) { printf("CheckExists(): Memory allocation error!!\n"); return -1; } if (MemGetExpectedOutput(text, p->text) != 0) { if (text == NULL) { printf("CheckExists(): Error reading Expected Output for \"%s\"!!\n",p->text); return -1; } } //text = (char *) CfReadFile(p->text, CF_BUFSIZE); FlattenText(text); Chop(text); if(FindTextInFile(text, p->buf) > 0) { free(text); return 1; } free(text); break; default: // Check: not necessary, parser handles this?? break; } return -1; } /*********************************************************/ int RunPolicies(struct cfoutput *actual, int nInput, struct input *map, int nMap) { int i = 0, j = 0, k = 0; char opts[] = " -"; char command[CF_BUFSIZE], c[CF_BUFSIZE], output[CF_EXPANDSIZE]; int failures = 0; char full_filepath[CF_BUFSIZE]; snprintf(c, CF_BUFSIZE, "%s%cbin%ccf-agent -f ",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); for (i = 0; i < nInput; i++) { // if ((map[i].test_class != CFTEST_CLASS) && (CFTEST_CLASS != 0)) // { // continue; // } // execute predefined // ExecutePreDefined snprintf(actual[k].id,CF_SMALLBUF,"%s", map[i].id); if(map[i].predefinedId > 0) { if(ExecutePreDefined(map[i].predefinedId, map[i].policy_file) == 1) //TODO: change policy_file to buf { actual[k].pass = 1; } else { actual[k].pass = 0; } } snprintf(command,CF_BUFSIZE, "%s",c); snprintf(full_filepath,CF_BUFSIZE,"%s/tests/units/%s",TEST_ROOT_DIR,map[i].policy_file); strcat(command, full_filepath); strcat(command, opts); strcat(command, map[i].policy_opt); // printf("RunPolicies: Command = %s\n",command); // prepare for (j = 0; j < map[i].nPre; j++) { if (DoIt(&map[i].PRE[j]) > 0) { if(strlen( map[i].internal[map[i].PRE[j].var_index].name) > 0) { actual[k].results[map[i].PRE[j].var_index].value = 1; actual[k].results[map[i].PRE[j].var_index].var_index = map[i].PRE[j].var_index; // TODO: this might not be necessary, instead of struct decision[], int [] will do in the srtuct defn } } } // execute policy if (GetExecOutput(command,output,false)) { snprintf(actual[k].output,CF_EXPANDSIZE, "%s",output); actual[k].exec_ok = 1; Debug("RunPolicies(%d): %s, %s\n%s\n", nInput,output, actual[k].id, command); } else { actual[k].exec_ok = 0; failures++; printf("RunPolicies(): Error running Cfengine Test Policy \"%s\"\n", actual[k].id); } k++; } return failures; } /*********************************************************/ void ShowResults(struct cfoutput* a, int n1)//, struct input *m, int n2) { int i, j, k; printf("\n \n------------------- Regression test Report -------------------\n"); for (i = 0; i < n1; i++) { printf("TEST ID = %s, ", a[i].id); printf(" Result = "); if(a[i].pass) { printf("PASS\n"); }else { printf("FAIL\n"); } } printf("\n"); } /*********************************************************/ int CompareOutput(struct cfoutput* a, int n1, struct input *m, int n2) { int i, j, count = 0/*num of FAILED tests*/, k; char r[] = "R: "; char any[] = ".*"; char expected[CF_EXPANDSIZE]; char *sp; char textToFind[CF_SMALLBUF],*filename, *user, *text; int pass = 0; // for file permission struct stat sb; int perm; char buf[CF_BUFSIZE]; int temp; char file[CF_BUFSIZE]; // snprintf(TMP_DIR,CF_BUFSIZE,"%s%s",CFWORKDIR,"/regression_test/tmp/"); for(i = 0; i < n1; i++) { for(j = 0; j < n2; j++) { // if((m[j].test_class != CFTEST_CLASS) && (CFTEST_CLASS != 0) ) // { // continue; // } if( strcmp(a[i].id, m[j].id) == 0) { if(strlen(a[i].id) > 0 && strlen(m[j].id)>0) { for(k = 0; k < m[j].nOutput;k++) { switch(m[j].expected[k].type) { case CF_OUT_REPORT: strcpy(expected, r); strcat(expected, m[j].expected[k].text); if(FullTextMatch(expected, a[i].output)) { a[i].pass = 1; }else { a[i].pass = 0; k = m[j].nOutput; // proceed to next ID count++; } break; case CF_OUT_ADDLINE: snprintf(file,CF_BUFSIZE,"/tmp/%s",m[j].expected[k].buf); if(FindTextInFile(m[j].expected[k].text,file) > 0) { a[i].pass = 1; }else { a[i].pass = 0; k = m[j].nOutput; // proceed to next ID count++; } break; case CF_OUT_REMOVELINE: snprintf(file,CF_BUFSIZE,"/tmp/%s",m[j].expected[k].buf); if((FindTextInFile(m[j].expected[k].text,file))<=0) { a[i].pass = 1; } else { a[i].pass = 0; k = m[j].nOutput; // proceed to next ID count++; } break; case CF_OUT_KILLPROCESS: // printf("Kill Process: %s\n", m[j].expected[k].text); if(FindProcess("apache2") > 0) { Debug("CompareOutput(): Found Process \"%s\"\n", "apache2"); } break; case CF_OUT_STARTPROCESS: // TODO: fill this space break; case CF_OUT_STARTSERVICE: break; case CF_OUT_STOPSERVICE: break; case CF_OUT_INFO: // flatten text FlattenText(a[i].output); if (FullTextMatch(m[j].expected[k].text, a[i].output)) { a[i].pass = 1; }else { a[i].pass = 0; k = m[j].nOutput; // proceed to next ID count++; } break; case CF_OUT_USEREXISTS: case CF_OUT_ADDUSER: user = m[j].expected[k].text; filename = m[j].expected[k].buf; // just checking in the passwd file, and not shadow and group snprintf(filename, CF_SMALLBUF, "%s", "passwd"); snprintf(file,CF_BUFSIZE,"/tmp/%s",filename); snprintf(textToFind, CF_SMALLBUF, "%s", "[ ]*"); strcat(textToFind, user); strcat(textToFind, ":"); strcat(textToFind, any); if((FindTextInFile(textToFind, file))>0) { a[i].pass = 1; }else { a[i].pass = 0; k = m[j].nOutput; // proceed to next ID count++; } break; case CF_OUT_REMOVEUSER: break; case CF_FILE: case CF_LINE: if(DoIt(&m[j].expected[k]) > 0) { a[i].pass = 1; }else { a[i].pass = 0; k = m[j].nOutput; // proceed to next ID count++; } break; case CF_OUT_REMOVELINES: case CF_OUT_ADDLINES: case CF_LINES: if(DoIt(&m[j].expected[k]) > 0) { a[i].pass = 1; }else { a[i].pass = 0; k = m[j].nOutput; // proceed to next ID count++; } break; case CF_OUT_REPORTS: if (MemGetExpectedOutput(buf, m[j].expected[k].text) == 0) { if(buf == NULL) { printf("CompareOutput(): Error Reading Expected Output for: %s", m[j].id); } else { FlattenText(a[i].output); FlattenText(buf); if(FullTextMatch(buf, a[i].output)) { a[i].pass = 1; break; } } } // The test failed a[i].pass = 0; k = m[j].nOutput; // proceed to next ID count++; break; case CF_OUT_FILEPERMS: if (cfstat(m[j].expected[k].text, &sb) != -1) { sb.st_mode & 0xFFFF; sscanf(m[j].expected[k].buf, "%o", &perm); if(perm == (sb.st_mode & 0777)) { a[i].pass = 1; break; } } //failure condition a[i].pass = 0; k = m[j].nOutput; // proceed to next ID count++; break; case CF_OUT_OWNER: temp = GetOwnerName( m[j].expected[k].text, &sb, buf, sizeof(buf)); if (temp && (strcmp(buf, m[j].expected[k].buf) == 0)) { a[i].pass = 1; } else { a[i].pass = 0; k = m[j].nOutput; // proceed to next ID count++; } break; case CF_OUT_ISLINK: if (lstat(m[j].expected[k].text, &sb) != -1) { if(S_ISLNK(sb.st_mode)) { a[i].pass = 1; break; } } //FAILURE a[i].pass = 0; k = m[j].nOutput; // proceed to next ID count++; break; case CF_OUT_LINKEDTO: /* INCOMPLETE TODO if (lstat(m[j].expected[k].text, &sb) != -1) { if(S_ISLNK(sb.st_mode)) { memset(buf,0,CF_BUFSIZE); readlink(m[j].expected[k].text,buf,CF_BUFSIZE-1); a[i].pass = 1; break; } } //FAILURE a[i].pass = 0; k = m[j].nOutput; // proceed to next ID count++; */ break; //case CF_LINES: // break; } } } } } } return count; // failed Count } /*********************************************************/ int MemGetExpectedOutput(char *buf, char *name) { if (strcmp(name, O_CHDIR_TEXT) == 0) { snprintf(buf, CF_BUFSIZE, "%s", O_CHDIR); return 0; } else if (strcmp(name, O_LISTS_TEXT) == 0) { snprintf(buf, CF_BUFSIZE, "%s", O_LISTS); return 0; } else if (strcmp(name, O_CLASSVAR_CONVERGENCE_TEXT) == 0) { snprintf(buf, CF_BUFSIZE, "%s", O_CLASSVAR_CONVERGENCE); return 0; } else if (strcmp(name, O_DOLLAR_TEXT) == 0) { snprintf(buf, CF_BUFSIZE, "%s", O_DOLLAR); return 0; } else if (strcmp(name, O_INSERT_LINES_TEXT) == 0) { snprintf(buf, CF_BUFSIZE, "%s", O_INSERT_LINES); return 0; } return -1; } /*********************************************************/ int AppendTextToFile(char *text, char *file) { FILE *f = fopen(file, "a"); if (f == NULL) { return -1; } fprintf(f,"%s", text); fclose(f); return 1; } /*********************************************************/ int Parse(struct input *data,char *inputfile) { char line[CF_SMALLBUF], temp[CF_SMALLBUF]; char f[CF_SMALLBUF]; int n = 0, j, i; int section = -1; int nLineCount = 0; int isDuplicate = 0; int nLineNum = 0, preDefinedType = -1; unsigned int nTemp; int blockStarted = 0; struct input *in = data; snprintf(f,CF_SMALLBUF,"%s",inputfile); FILE *inFile = fopen(f,"r"); /* Locals for reading line from test script in memory */ int nPointer = 0; int total_size; int size; char *frm; int global_var_found = 0; //if (CF_TEST_INPUT == NULL) // { // printf("Parse(): Error in input test script!\n"); // return -1; // } //total_size = strlen(CF_TEST_INPUT); //frm = CF_TEST_INPUT; THIS_AGENT_TYPE = cf_agent; while(fgets(line, CF_SMALLBUF, inFile)) //while(nPointer < total_size) { // size = ReadLineInput(line, frm + nPointer); // nPointer += size + 1; nLineNum++; if (n > CF_MAX_TESTS) { printf("Parse(): Number of tests exceeded maximum allowed (%d)!!\n", CF_MAX_TESTS); break; } // replace \n by \0 for (j=0;j<CF_SMALLBUF;j++) { if(line[j] == '\n' || j == (CF_SMALLBUF - 1)) { line[j] = '\0'; } } char rtype,*retval; if (FullTextMatch("^[ ]*#.*",line)) { // lINE IS A comment: ignore } else if (!blockStarted && FullTextMatch("^[ ]*([a-z0-9]+)(.*)[ ]*$",line)) { if (GetVariable("match","2",(void *)&retval,&rtype) != cf_notype) { if( RemoveChars(retval,"();")) { snprintf(in[n].policy_file,CF_SMALLBUF,"%s",retval); // TODO: rename policy_file to a more generic name (eg. buffer) } } if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) { if( RemoveChars(retval,"();")) { preDefinedType = CheckPredefined(retval); if(preDefinedType > 0) { snprintf(in[n].id, CF_SMALLBUF, "%s",retval); in[n].predefinedId = preDefinedType; n++; } } } } else if (!blockStarted && FullTextMatch("^[ ]*@([A-Z_]+)=(.*)[ ]*$",line)) { global_var_found = 0; if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) { if (strcmp(retval, "CF_DIR") == 0) { global_var_found = 1; } } if (GetVariable("match","2",(void *)&retval,&rtype) != cf_notype) { if(global_var_found == 1) { snprintf(TEST_ROOT_DIR,CF_BUFSIZE,"%s",retval); } } } else if (FullTextMatch("^[ \t]*$",line)) { // Line is empty: ignore }else { // trim spaces FullTextMatch("^[ \t]*(.+)[ \t]*$",line); if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) { if (strcmp(retval,"{") == 0) //start of block { blockStarted = 1; if(IsDuplicate(temp,in,n)) { isDuplicate = 1; }else { snprintf(in[n].id, CF_SMALLBUF, "%s",temp); Debug("Parse(%d): %s\n", n, temp); in[n].predefinedId = -1; } } else if(strcmp(retval,"}") == 0) //end of block of block { if(!isDuplicate) { n++; nInput = n; } isDuplicate = 0; section = -1; blockStarted = 0; } else if(!isDuplicate) // inside a block { snprintf(temp,CF_SMALLBUF, "%s",retval); // sub-section names must contain only characters, TODO: finalize this defn if (FullTextMatch("^[ \t]*([A-Za-z]+)[ \t]*:[ \t]*$",temp)) { if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) // get the sub-sections { section = GetSubSection(retval); Debug("Parse(%d): %s\n", section, retval); nLineCount = 0; // reset the count for commands in each sub-section continue; } } // inside a sub-section switch(section) { case CF_VARS: snprintf(in[n].internal[nLineCount].name, CF_VARSIZE, "%s", temp); in[n].internal[nLineCount].index = nLineCount; in[n].internal[nLineCount].value = -1; in[n].nVar = ++nLineCount; break; case CF_PRE: if(GetPrepareCleanup(in[n].id,&in[n].PRE[nLineCount], temp) > 0) { in[n].nPre = ++nLineCount; } break; case CF_EXEC: GetExec(in[n].policy_file,in[n].policy_opt, temp); break; case CF_OUT: if(GetExpectedOutput(in[n].id, &in[n].expected[nLineCount], temp)) { in[n].nOutput = ++nLineCount; } break; case CF_CLEAN: if (GetPrepareCleanup(in[n].id, &in[n].POST[nLineCount], temp) > 0) { in[n].nPost = ++nLineCount; } break; case CF_CLASS: if((nTemp = GetClassType(temp)) >= 0) { in[n].test_class = nTemp; } break; default: // TODO: not required?? Debug("Switch Default\n"); break; } /*switch*/ } /* if -> inside block*/ } /* if -> getvar*/ } /* if -> non-empty line */ // free(line); } /*while getline*/ fclose(inFile); // PRINT INPUT DATA /* for(i = 0; i<n; i++) { printf("\nParse(): ##### Test Policy %d #####\n\n", i); printf("Parse(): ID = %s\n",in[i].id); printf("Parse(): Policy File = %s\n",in[i].policy_file); printf("Parse(): Policy Option(s) = %s\n",in[i].policy_opt); printf("Parse(): Class Type = %d\n",in[i].test_class); for(j = 0; j < in[i].nVar; j++) { printf("\tParse(): Vars [%d] Index = %d\n", j, in[i].internal[j].index); printf("\tParse(): Vars [%d] Index = %s\n", j, in[i].internal[j].name); } for(j = 0; j < in[i].nPre; j++) { printf("\tParse(): Prepare [%d] Type = %d\n", j, in[i].PRE[j].type); if(strlen(in[i].PRE[j].text) > 0) { printf("\tParse(): Prepare [%d] Line = %s\n", j, in[i].PRE[j].text); } printf("\tParse(): Prepare [%d] Action = %d\n", j, in[i].PRE[j].action); printf("\tParse(): Prepare [%d] Name = %s\n", j, in[i].PRE[j].buf); if(strlen(in[i].internal[in[i].expected[j].var_index].name)) printf("\tParse(): Variable[%d] = %s\n", in[i].PRE[j].var_index, in[i].internal[in[i].PRE[j].var_index].name); } for(j = 0; j < in[i].nOutput; j++) { printf("\tParse(): Expected [%d] Type = %d\n", j, in[i].expected[j].type); printf("\tParse(): Expected [%d] Result = %s\n", j, in[i].expected[j].text); printf("\tParse(): Expected [%d] Action = %d\n", j, in[i].expected[j].action); if(strlen(in[i].expected[j].buf) > 0) printf("\tParse(): Expected [%d] Buffer(eg. filename) = %s\n", j, in[i].expected[j].buf); if(strlen(in[i].internal[in[i].expected[j].var_index].name) > 0) printf("\tParse(): Variable[%d] = %s\n", in[i].expected[j].var_index, in[i].internal[in[i].expected[j].var_index].name); } for(j = 0; j < in[i].nPost; j++) { printf("\tParse(): Cleanup [%d] Type = %d\n", j, in[i].POST[j].type); printf("\tParse(): Cleanup [%d] Action = %d\n", j, in[i].POST[j].action); printf("\tParse(): Cleanup [%d] Name = %s\n", j, in[i].POST[j].buf); } printf("### Counts ###\n"); printf("Parse(): nPre = %d\n", in[i].nPre); printf("Parse(): nPost = %d\n", in[i].nPost); printf("Parse(): nPre = %d\n", in[i].nOutput); printf("Parse(): nVar = %d\n", in[i].nVar); } */ return n; } /*********************************************************/ int GetClassType(char *s) { // TODO: make this function handle multiple class names separated by comma if(strlen(s) < 1) { return -1; } if(strcmp(s, CF_ALL_TEXT) == 0) { return CF_CLASS_ALL; } if(strcmp(s, CF_REPORT_TEXT) == 0) { return CF_CLASS_REPORT; } if(strcmp(s, CF_SLIST_TEXT) == 0) { return CF_CLASS_SLIST; } if(strcmp(s, CF_STRING_TEXT) == 0) { return CF_CLASS_STRING; } if(strcmp(s, CF_PROCESS_TEXT) == 0) { return CF_CLASS_PROCESS; } if(strcmp(s, CF_FILE_TEXT) == 0) { return CF_CLASS_FILE; } if(strcmp(s, CF_DIR_TEXT) == 0) { return CF_CLASS_DIR; } if(strcmp(s, CF_CMD_TEXT) == 0) { return CF_CLASS_CMD; } if(strcmp(s, CF_OTHER_TEXT) == 0) { return CF_CLASS_OTHER; } if(strcmp(s, CF_TOP10_TEXT) == 0) { return CF_CLASS_TOP10; } return CF_CLASS_ALL; } /*********************************************************/ int GetSubSection(char *s) { if(strlen(s) < 1) { return -1; } if(strcmp(s, CF_PRE_TEXT) == 0) { return CF_PRE; } if(strcmp(s, CF_EXEC_TEXT) == 0) { return CF_EXEC; } if(strcmp(s, CF_OUT_TEXT) == 0) { return CF_OUT; } if(strcmp(s, CF_CLEAN_TEXT) == 0) { return CF_CLEAN; } if(strcmp(s, CF_VARS_TEXT) == 0) { return CF_VARS; } if(strcmp(s, CF_CLASS_TEXT) == 0) { return CF_CLASS; } return -1; } /*********************************************************/ int GetExec(char *filename, char *opts, char *s) { char rtype,*retval; char unwanted[] = "();"; if(FullTextMatch("[ \t]*([A-Za-z0-9_]+)[ \t]*[^A-Za-z0-9_/\"]\"(.+)\"[ \t]*,[ \t]*\"(.+)\"[ \t]*[^A-Za-z0-9_/\"][ \t]*",s)) { if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) { if(strcmp(retval,CF_POLICY_TEXT) == 0) { if (GetVariable("match","2",(void *)&retval,&rtype) != cf_notype) { if( RemoveChars(retval,unwanted)) { snprintf(filename, CF_BUFSIZE, "%s", retval); } Debug("GetExec(): %s\n",retval); if (GetVariable("match","3",(void *)&retval,&rtype) != cf_notype) { snprintf(opts, 5, "%s", retval); // TODO: change 5 to some constant defn; opts = test options, eg. K, KF } Debug("GetExec(): Options = %s\n", opts); } } } } else { printf("GetExec(): Syntax Error\n"); // TODO: Display Line number return -1; } return 0; } /*********************************************************/ int GetExpectedOutput(char *id, struct line_data *o, char *s) { char rtype,*retval; char unwanted[] = ";\")"; int tmp; if (strcmp(s,"NA") == 0) // assign NULL to the output ?? { return -1; } o->var_index = -1; //TODO: Comments at the end of line not handled // eg. var = line("line","file","EXISTS")' // if(FullTextMatch("[ \t]*([A-Za-z0-9_]+)[ \t]*=[ \t]*(.+)[ \t]*[^A-Za-z0-9_/\"][ \t]*\"(.+)\"[ \t]*[,][ \t]*\"(.+)\"[ \t]*[,][ \t]*(.+)[^A-Za-z0-9_/\"]",s)) { if (GetVariable("match","2",(void *)&retval,&rtype) != cf_notype) { if( RemoveChars(retval,unwanted)) { if( (tmp = GetType1(retval)) > 0) { o->type = tmp; } // printf("Type = %s, %d\n", retval,tmp); } } if (GetVariable("match","3",(void *)&retval,&rtype) != cf_notype) { if( RemoveChars(retval,unwanted)) { snprintf(o->text, CF_BUFSIZE, "%s", retval); } } if (GetVariable("match","4",(void *)&retval,&rtype) != cf_notype) { snprintf(o->buf, CF_SMALLBUF, "%s", retval); } if (GetVariable("match","5",(void *)&retval,&rtype) != cf_notype) { RemoveComment(retval); if ( RemoveChars(retval,unwanted)) { o->action = GetAction(retval); } } if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) { if((tmp = GetVarIndex(id, retval)) < 0) { printf(" GetPrepareCleanup(): Error!! Variable %s is not defined in test \"%s\".",retval, id); o->var_index = -1; } else { o->var_index = tmp; } } return 1; } else // eg. var = addline("filename","text") if(FullTextMatch("[ \t]*([A-Za-z0-9_]+)[ \t]*=[ \t]*([A-Za-z0-9_]+)[ \t]*[^A-Za-z0-9_/\"]\"(.+)\"[ \t]*,[ \t]*\"(.+)\"[ \t]*[^A-Za-z0-9_/\"][ \t]*",s)) { if (GetVariable("match","3",(void *)&retval,&rtype) != cf_notype) { snprintf(o->text, CF_BUFSIZE, "%s", retval); if (GetVariable("match","2",(void *)&retval,&rtype) != cf_notype) { // Debug(" GetExpectedOutput(): type = %s\n", retval); o->type = GetType1(retval); } if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) { if((tmp = GetVarIndex(id, retval)) < 0) { Debug(" GetExpectedOutput(): Error!! Variable %s is not defined in test \"%s\"\n",retval, id); o->var_index = -1; }else { o->var_index = tmp; // printf(" GetExpectedOutput(): var_index = %d\n", o->var_index); } } if (GetVariable("match","4",(void *)&retval,&rtype) != cf_notype) { Debug(" GetExpectedOutput(): Buffer = %s\n", retval); snprintf(o->buf, CF_SMALLBUF,"%s",retval); } } // return 1; } else // eg. addline("line", "file") if(FullTextMatch("[ \t]*([A-Za-z0-9_]+)[ \t]*[^A-Za-z0-9_/\"]\"(.+)\"[ \t]*,[ \t]*\"(.+)\"[ \t]*[^A-Za-z0-9_/\"][ \t]*",s)) { if (GetVariable("match","2",(void *)&retval,&rtype) != cf_notype) { snprintf(o->text, CF_BUFSIZE, "%s", retval); if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) { // Debug(" GetExpectedOutput(): type = %s\n", retval); o->type = GetType1(retval); } if (GetVariable("match","3",(void *)&retval,&rtype) != cf_notype) { Debug(" GetExpectedOutput(): Buffer = %s\n", retval); snprintf(o->buf, CF_SMALLBUF,"%s",retval); } } // return 1; } else if(FullTextMatch("[ \t]*(.+)[ \t]*[^A-Za-z0-9_/\"][ \t]*\"(.+)\"[ \t]*[,][ \t]*(.+)",s)) { if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) { if( RemoveChars(retval,unwanted)) // snprintf(type, CF_SMALLBUF, "%s", retval); if( (tmp = GetType1(retval)) > 0) { o->type = tmp; } Debug("GetExpectedOutput(2): TYPE = %s; %d\n",retval,o->type); } if (GetVariable("match","2",(void *)&retval,&rtype) != cf_notype) { if (RemoveChars(retval,unwanted)) { snprintf(o->buf, CF_BUFSIZE, "%s", retval); } Debug("GetExpectedOutput(): NAME = %s\n", o->buf); } if (GetVariable("match","3",(void *)&retval,&rtype) != cf_notype) { RemoveComment(retval); if ( RemoveChars(retval,unwanted)) { // snprintf(action, CF_SMALLBUF, "%s", retval); o->action= GetAction(retval); } Debug("GetExpectedOutput(): ACTION = %s, %d\n",retval, o->action); } } // eg. insertuser("mark") else if(FullTextMatch("^([A-Za-z0-9_]+)[ \t]*[^A-Za-z0-9_/\"]\"(.+)\"[ \t]*[^A-Za-z0-9_/\"][ \t]*",s)) { if (GetVariable("match","2",(void *)&retval,&rtype) != cf_notype) { //if( RemoveChars(retval,unwanted)) { snprintf(o->text, CF_BUFSIZE, "%s", retval); if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) { // Debug(" GetExpectedOutput(): type = %s\n", retval); o->type = GetType1(retval); } } Debug("GetExpectedOutput(): %s\n",retval); // return 1; } } else { printf("GetExpectedOutput(): Syntax Error; %s\n",s); // display line number return -1; } switch(o->type) { case CF_OUT_ADDLINES: o->action = CF_EXISTS; break; case CF_OUT_REMOVELINES: o->action = CF_NOTEXISTS; break; case CF_OUT_ADDLINE: o->action = CF_EXISTS; break; case CF_OUT_REMOVELINE: o->action = CF_NOTEXISTS; break; } return 1; } /*********************************************************/ int GetType1(char *s) { if(strlen(s) < 0) { return -1; } // output types if(strcmp(CF_REPORT_TEXT, s) == 0) { return CF_OUT_REPORT; } if(strcmp(CF_ADDLINE_TEXT, s) == 0) { return CF_OUT_ADDLINE; } if(strcmp(CF_REMOVELINE_TEXT, s) == 0) { return CF_OUT_REMOVELINE; } if(strcmp(CF_KILLPROCESS_TEXT, s) == 0) { return CF_OUT_KILLPROCESS; } if(strcmp(CF_INFO_TEXT, s) == 0) { return CF_OUT_INFO; } if(strcmp(CF_ADDUSER_TEXT, s) == 0) { return CF_OUT_ADDUSER; } if(strcmp(CF_REMOVEUSER_TEXT, s) == 0) { return CF_OUT_REMOVEUSER; } if(strcmp(CF_ADDLINES_TEXT, s) == 0) { return CF_OUT_ADDLINES; } if(strcmp(CF_REMOVELINES_TEXT, s) == 0) { return CF_OUT_REMOVELINES; } if(strcmp(CF_REPORTS_TEXT, s) == 0) { return CF_OUT_REPORTS; } if(strcmp(CF_FILEPERMS_TEXT, s) == 0) { return CF_OUT_FILEPERMS; } if(strcmp(CF_OWNER_TEXT, s) == 0) { return CF_OUT_OWNER; } if(strcmp(CF_ISLINK_TEXT, s) == 0) { return CF_OUT_ISLINK; } if(strcmp(CF_LINKEDTO_TEXT, s) == 0) { return CF_OUT_LINKEDTO; } // if(strcmp(s,CF_FILE_TEXT) == 0) { return CF_FILE; } if(strcmp(s, CF_DIR_TEXT) == 0) { return CF_DIR; } if(strcmp(s, CF_POLICY_TEXT) == 0) { return CF_POLICY; } if(strcmp(s, CF_PROCESS_TEXT) == 0) { return CF_PROCESS; } if(strcmp(s, CF_LINE_TEXT) == 0) { return CF_LINE; } if(strcmp(s, CF_LINES_TEXT) == 0) { return CF_LINES; } if(strcmp(s, CF_EXTERNAL_TEXT) == 0) { return CF_EXTERNAL; } // functions if(strcmp(s, CF_APPENDLINE_TEXT) == 0) { return CF_FXN_APPENDLINE; } return -1; } /*********************************************************/ int GetPrepareCleanup(char *id, struct line_data *p, char *s) { char rtype,*retval; char unwanted[] = "() ;\""; char type[CF_SMALLBUF], name[CF_BUFSIZE], action[CF_SMALLBUF]; struct line_data *data = p; int ret = -1; void *tmp; if ((strcmp(s,"NA") == 0) || (strlen(s) < 1)) // assign NULL to the output ?? { return -1; } p->var_index = -1; if (FullTextMatch("[ \t]*([A-Za-z0-9_]+)[ \t]*=[ \t]*(.+)[ \t]*[^A-Za-z0-9_/\"][ \t]*\"(.+)\"[ \t]*[,][ \t]*\"(.+)\"[ \t]*[,][ \t]*(.+)[^A-Za-z0-9_/\"]",s)) { if (GetVariable("match","2",(void *)&retval,&rtype) != cf_notype) { if( RemoveChars(retval,unwanted)) { snprintf(type, CF_SMALLBUF, "%s", retval); } if ((ret = GetType1(type)) > 0) { p->type = ret; } // printf("GetPrepareCleanup(1): TYPE = %s; %d\n",type,p->type); } if (GetVariable("match","3",(void *)&retval,&rtype) != cf_notype) { // if( RemoveChars(retval,unwanted)) snprintf(p->text, CF_BUFSIZE, "%s", retval); // printf("GetPrepareCleanup(1): LINE = %s; %s\n",type,p->text); } if (GetVariable("match","4",(void *)&retval,&rtype) != cf_notype) { // if( RemoveChars(retval,unwanted)) snprintf(p->buf, CF_SMALLBUF, "%s", retval); // printf("GetPrepareCleanup(1): NAME = %s; %s\n",type,p->buf); } if (GetVariable("match","5",(void *)&retval,&rtype) != cf_notype) { RemoveComment(retval); if( RemoveChars(retval,unwanted)) { snprintf(action, CF_SMALLBUF, "%s", retval); } p->action = GetAction(action); // printf("GetPrepareCleanup(1): ACTION = %s; %d\n",action, p->action); } if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) { if((ret = GetVarIndex(id, retval)) < 0) { printf(" GetPrepareCleanup(): Error!! Variable %s is not defined in test \"%s\"\n",retval, id); p->var_index = -1; } else { p->var_index = ret; // printf(" GetPrepareCleanup(1): var_index = %d\n", p->var_index); } } return 1; } else if(FullTextMatch("[ \t]*([A-Za-z0-9_]+)[ \t]*=[ \t]*(.+)[ \t]*[^A-Za-z0-9_/\"][ \t]*\"(.+)\"[ \t]*[,][ \t]*(.+)",s)) { if (GetVariable("match","2",(void *)&retval,&rtype) != cf_notype) { if( RemoveChars(retval,unwanted)) snprintf(type, CF_SMALLBUF, "%s", retval); if ((ret = GetType1(type)) > 0) { p->type = ret; } // printf("GetPrepareCleanup(1): TYPE = %s; %d\n",type,p->type); } if (GetVariable("match","3",(void *)&retval,&rtype) != cf_notype) { if( RemoveChars(retval,unwanted)) { snprintf(p->buf, CF_BUFSIZE, "%s", retval); // printf("GetPrepareCleanup(): NAME = %s\n",p->buf); } } if (GetVariable("match","4",(void *)&retval,&rtype) != cf_notype) { RemoveComment(retval); if( RemoveChars(retval,unwanted)) { snprintf(action, CF_SMALLBUF, "%s", retval); } p->action = GetAction(action); } if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) { if((ret = GetVarIndex(id, retval)) < 0) { printf(" GetPrepareCleanup(): Error!! Variable %s is not defined in test \"%s\"\n",retval, id); p->var_index = -1; } else { p->var_index = ret; // snprintf(o->buf, CF_SMALLBUF, "%s", retval); // printf(" GetPrepareCleanup(): var_index = %d\n", p->var_index); } } return 1; } else if(FullTextMatch("[ \t]*(.+)[ \t]*[^A-Za-z0-9_/\"][ \t]*\"(.+)\"[ \t]*[,][ \t]*(.+)",s)) { if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) { if( RemoveChars(retval,unwanted)) { snprintf(type, CF_SMALLBUF, "%s", retval); } if ((ret = GetType1(type)) > 0) { p->type = ret; } // printf("GetPrepareCleanup(2): TYPE = %s; %d\n",type,p->type); } if (GetVariable("match","2",(void *)&retval,&rtype) != cf_notype) { //if( RemoveChars(retval,unwanted)) snprintf(p->buf, CF_BUFSIZE, "%s", retval); // printf("GetPrepareCleanup(): NAME = %s\n",p->buf); } if (GetVariable("match","3",(void *)&retval,&rtype) != cf_notype) { RemoveComment(retval); if (RemoveChars(retval,unwanted)) { snprintf(action, CF_SMALLBUF, "%s", retval); } p->action = GetAction(action); if(p->action == -1) { snprintf(p->text, CF_BUFSIZE, "%s", retval); } } } else if (FullTextMatch("[ \t]*([A-Za-z0-9_]+)[ \t]*[^A-Za-z0-9_/\"]\"(.+)\"[ \t]*[^A-Za-z0-9_/\"][ \t]*",s)) { if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) { if( (ret = GetType1(retval)) > 0) { p->type = ret; } if (GetVariable("match","2",(void *)&retval,&rtype) != cf_notype) { // if( RemoveChars(retval,unwanted)) snprintf(p->text, CF_BUFSIZE, "%s", retval); Debug("GetPrepareCleanup(): %s\n",retval); } } } else { printf("GetPrepareCleanup(): Syntax Error; %s\n",s); // display line number return -1; } return 1; } /*********************************************************/ int RemoveChars(char *s, char *u) { int len1, len2; int i,j, ok = 1, index = 0; char tmp[CF_BUFSIZE]; char src[CF_BUFSIZE]; len1 = strlen(s); if (len1 < 1) { return 0; } len2 = strlen(u); if (len2 < 1) { return 0; } len1++; // +1 for the terminating \0 snprintf(src, len1, "%s",s); Debug("RemoveChars(): src= %s \n ", src); for(i = 0; i < len1; i++) { ok = 1; for(j = 0; j < len2; j++) { if(src[i] == u[j]) { ok = 0; break; } } if(ok) { tmp[index++] = src[i]; } } tmp[index] = '\0'; if(strlen(tmp) < 1) { return 0; } snprintf(s, len1, "%s",tmp); return 1; } /*********************************************************/ int RemoveComment(char *s) { int len = strlen(s) + 1; char tmp[len]; char unwanted[] = "()"; snprintf(tmp, CF_BUFSIZE, "%s", s); if (FullTextMatch("(.+);[ ]*#(.+)",tmp)) { char rtype,*retval; if (GetVariable("match","1",(void *)&retval,&rtype) != cf_notype) { snprintf(s, CF_BUFSIZE, "%s", retval); Debug("RemoveComment(): %s\n", retval); } } else { Debug("RemoveComment(): Comment not found\n"); return -1; } return 0; } /*********************************************************/ int GetAction(char *a) { if(strlen(a) < 1) { return -1; } if(strcmp(a, CF_ACCESS_TEXT) == 0) { return CF_ACCESS; } if(strcmp(a, CF_BACKUP_TEXT) == 0) { return CF_BACKUP; } if(strcmp(a, CF_DELETE_TEXT) == 0) { return CF_DELETE; } if(strcmp(a, CF_RESTORE_TEXT) == 0) { return CF_RESTORE; } if(strcmp(a, CF_EXISTS_TEXT) == 0) { return CF_EXISTS; } if(strcmp(a, CF_CREATE_TEXT) == 0) { return CF_CREATE; } return -1; } /*********************************************************/ int IsDuplicate(char *s, struct input *data, int n) { int i; if (n < 0 || data == NULL || (strlen(s) < 1)) { return 0; } for(i = 0; i < n; i++) { if(strcmp(data[i].id,s) == 0) { Debug("Is Duplicate(): Found Duplicate: %s\n",s); return 1; } } return 0; } /*********************************************************/ // used only for internal testing void PrintChars(char *s) { int i = 0; while(s[i] != '\0') { printf("PrintChars(): %c\n", s[i]); i++; } } /*********************************************************/ int FindTextInFile(char *str, char *file) { char *buf, tmp[CF_BUFSIZE], bufEsc[CF_BUFSIZE]; char any[] = ".*"; buf = (char *) malloc(CF_BUFSIZE * sizeof(char)); if(buf == NULL) { printf("FindTextInFile(): Memory allocation error!!\n"); return -1; } buf = (char *) CfReadFile(file, CF_BUFSIZE); if(buf == NULL) { printf("FindTextInFile(): Error reading file \"%s\"!!\n",file); return -1; } Chop(buf); // flatten text file FlattenText(buf); snprintf(tmp, CF_BUFSIZE, "%s", any); strcat(tmp, str); strcat(tmp, any); if(FullTextMatch(tmp,buf)) { // printf("FindTextInFile(): Found text!!\n"); return 1; } free(buf); return -1; } /*********************************************************/ // TODO: use size_t instead of long return value?? long fsize(char* file) { long ret; FILE * f = fopen(file, "r"); if (f == NULL) { printf("Error Opening File: %s\n", file); return -1; } fseek(f, 0, SEEK_END); ret = (long) ftell(f); fclose(f); return ret; } /*********************************************************/ int ReplaceCharTS(char *str, char to, char frm) { int ret = 0; char *sp; for (sp = str; *sp != '\0'; sp++) { if (*sp == frm) { *sp = to; ret++; } } return ret; } /*********************************************************/ int FlattenText(char *str) { return ReplaceCharTS(str, ' ', '\n'); } /*********************************************************/ int ReadLineInput(char *dst, char *frm ) { int len_prev, len_after, size; char buf[CF_BUFSIZE]; char *tmp1, *tmp2; tmp1 = frm; tmp2 = buf; len_prev = strlen(tmp1); tmp2 = strstr(tmp1, "\n"); len_after = strlen(tmp2); size = len_prev - len_after; snprintf(dst, size + 1, "%s", frm); return size; } /*********************************************************/ int FindProcess(char *str) { int retval = -1; struct Item *ip; char *psopts = "aux"; char any[] = ".*"; char tmp[CF_SMALLBUF]; int count = 0; snprintf(tmp,CF_SMALLBUF,"%s",any); strcat(tmp,str); strcat(tmp,any); if (LoadProcessTable(&PROCESSTABLE,psopts)) { for (ip = PROCESSTABLE; ip != NULL; ip = ip->next ) { if(FullTextMatch(tmp, ip->name)) { count++; } } } DeleteItemList(PROCESSTABLE); if(count > 0) { retval = count; } return retval; } /*********************************************************/ int GetVarIndex(char *test_id, char *var) { struct input *data = DATA; int i,j; for(i = 0; i <= nInput; i++) { if(strcmp(data[i].id, test_id) == 0) { for(j = 0; j < data[i].nVar; j++) { if(strcmp(data[i].internal[j].name, var) == 0) { return data[i].internal[j].index; } } } } return -1; } /*********************************************************/ int CheckPredefined(char *name) { if(strcmp(name, BOOTSTRAP_TEXT) == 0) { return BOOTSTRAP; } else { return -1; } } /*********************************************************/ int ExecutePreDefined(int id, char *opt) { switch(id) { case BOOTSTRAP: return PerformBootstrap(opt); break; } return -1; } /*********************************************************/ int PerformBootstrap(char *server) { char buf[CF_BUFSIZE], output[CF_BUFSIZE]; snprintf(buf,CF_BUFSIZE,"%s/ppkeys/localhost.pub",CFWORKDIR); if(!FileExists(buf)) { snprintf(buf,CF_BUFSIZE,"%s/bin/cf-key",CFWORKDIR); if (GetExecOutput(buf,output,false)) { } } // bootstrapping snprintf(buf,CF_BUFSIZE,"%s/bin/cf-agent --bootstrap --policy-server %s",CFWORKDIR,server); printf("\tBootstrapping... [Command = \"%s\"]\n",buf); GetExecOutput(buf,output,false); // printf("%s\n",output); // check for promises.cf snprintf(buf,CF_BUFSIZE,"%s/inputs/promises.cf",CFWORKDIR); //printf("PerformBootstrap(): Checking for %s\n",buf); if(!FileExists(buf)) { return -1; } // check for 2 cf-execd processes snprintf(buf,CF_SMALLBUF,"cf-execd"); if(FindProcess(buf) != 2) { return -1; } return 1; } /*********************************************************/ int FileExists(char *file) { struct stat sb; if(cfstat(file, &sb) != 0) { return -1; } return 1; } #endif /* BUILD_TESTSUITE */ /*********************************************************/ static void CheckInstalledLibraries(void) { printf("---- INSTALLED LIBRARIES ----\n"); #ifndef HAVE_LIBACL printf("\t->LIBACL not found!!\n"); #endif #ifndef HAVE_LIBPTHREAD printf("\t->LIBPTHREAD not found!!\n"); #endif #if !defined(TCDB) && !defined(QDB) printf("\t->TCDB and QDB not found!!\n"); #endif #ifndef HAVE_LIBMYSQLCLIENT printf("\t->LIBMYSQLCLIENT not found!!\n"); #endif #ifdef HAVE_LIBPQ printf("\t-> LIBPQ (postgresql) version ???\n"); #else printf("\t!! LIBPQ (postgresql) not found\n"); #endif #ifdef HAVE_NOVA Nova_CheckInstalledLibraries(); #else printf("\t->Nova not found!!\n"); #endif } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/sockaddr.c�����������������������������������������������������������������������0000644�0001750�0001750�00000007773�11715232734�012767� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: sockaddr.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /*****************************************************************************/ /* TOOLKIT */ /* INET independent address/struct conversion routines */ /* Note these functions are not thread safe */ /*****************************************************************************/ char *sockaddr_ntop(struct sockaddr *sa) { #if defined(HAVE_GETADDRINFO) static char addrbuf[INET6_ADDRSTRLEN]; void *addr; #else static char addrbuf[20]; struct in_addr addr; #endif switch (sa->sa_family) { case AF_INET: Debug("IPV4 address\n"); snprintf(addrbuf,20,"%.19s",inet_ntoa(((struct sockaddr_in *)sa)->sin_addr)); break; #ifdef AF_LOCAL case AF_LOCAL: Debug("Local socket\n") ; strcpy(addrbuf, "127.0.0.1") ; break; #endif #if defined(HAVE_GETADDRINFO) case AF_INET6: Debug("IPV6 address\n"); addr = &((struct sockaddr_in6 *)sa)->sin6_addr; inet_ntop(sa->sa_family,addr,addrbuf,sizeof(addrbuf)); break; #endif default: Debug("Address family was %d\n",sa->sa_family); FatalError("Software failure in sockaddr_ntop\n"); } Debug("sockaddr_ntop(%s)\n",addrbuf); return addrbuf; } /*****************************************************************************/ /* Example: struct sockaddr_in p; struct sockaddr_in6 p6; sockaddr_pton(AF_INET,"128.39.89.10", &p); sockaddr_pton(AF_INET6,"2001:700:700:3:290:27ff:fea2:477b", &p6); printf("Coded %s\n",sockaddr_ntop((struct sockaddr *)&p)); */ /*****************************************************************************/ bool sockaddr_pton(int af,void *src, void *genaddr) { switch (af) { case AF_INET: { struct sockaddr_in *addr = (struct sockaddr_in *)genaddr; memset(addr, 0, sizeof(struct sockaddr_in)); addr->sin_family = AF_INET; addr->sin_addr.s_addr = inet_addr(src); Debug("Coded ipv4 %s\n",sockaddr_ntop((struct sockaddr *)genaddr)); return addr->sin_addr.s_addr != INADDR_NONE; } #if defined(HAVE_GETADDRINFO) case AF_INET6: { int err; struct sockaddr_in6 *addr = (struct sockaddr_in6 *)genaddr; memset(addr, 0, sizeof(struct sockaddr_in6)); addr->sin6_family = AF_INET6; err = inet_pton(AF_INET6, src, &addr->sin6_addr); Debug("Coded ipv6 %s\n",sockaddr_ntop((struct sockaddr *)genaddr)); return err > 0; } #endif default: Debug("Address family was %d\n",af); FatalError("Software failure in sockaddr_pton\n"); } } �����cfengine-3.2.4/src/files_hashes.c�������������������������������������������������������������������0000644�0001750�0001750�00000041562�11715232734�013624� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ /* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: file_hashes.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int ReadHash(CF_DB *dbp,enum cfhashes type,char *name,unsigned char digest[EVP_MAX_MD_SIZE+1]); static int WriteHash(CF_DB *dbp,enum cfhashes type,char *name,unsigned char digest[EVP_MAX_MD_SIZE+1]); static char *NewIndexKey(char type,char *name, int *size); static void DeleteIndexKey(char *key); static void DeleteHashValue(struct Checksum_Value *value); static void HashList(struct Item *list,unsigned char digest[EVP_MAX_MD_SIZE+1],enum cfhashes type); static int FileHashSize(enum cfhashes id); /*******************************************************************/ int RefHash(char *name) // This function wants HASHTABLESIZE to be prime { int i, slot = 0; for (i = 0; name[i] != '\0'; i++) { slot = (CF_MACROALPHABET * slot + name[i]) % CF_HASHTABLESIZE; } return slot; } /*******************************************************************/ int ElfHash(char *key) { unsigned char *p = key; int len = strlen(key); unsigned h = 0, g; unsigned int hashtablesize = CF_HASHTABLESIZE; int i; for ( i = 0; i < len; i++ ) { h = ( h << 4 ) + p[i]; g = h & 0xf0000000L; if ( g != 0 ) { h ^= g >> 24; } h &= ~g; } return (h & (hashtablesize-1)); } /*******************************************************************/ int OatHash(const char *key) { unsigned int hashtablesize = CF_HASHTABLESIZE; unsigned const char *p = key; unsigned h = 0; int i, len = strlen(key); for ( i = 0; i < len; i++ ) { h += p[i]; h += ( h << 10 ); h ^= ( h >> 6 ); } h += ( h << 3 ); h ^= ( h >> 11 ); h += ( h << 15 ); return (h & (hashtablesize-1)); } /*****************************************************************************/ int FileHashChanged(char *filename,unsigned char digest[EVP_MAX_MD_SIZE+1],int warnlevel,enum cfhashes type,struct Attributes attr,struct Promise *pp) /* Returns false if filename never seen before, and adds a checksum to the database. Returns true if hashes do not match and also potentially updates database to the new value */ { int i,size = 21; unsigned char dbdigest[EVP_MAX_MD_SIZE+1]; CF_DB *dbp; Debug("HashChanged: key %s (type=%d) with data %s\n",filename,type,HashPrint(type,digest)); size = FileHashSize(type); if (!OpenDB(HASHDB,&dbp)) { cfPS(cf_error,CF_FAIL,"open",pp,attr,"Unable to open the hash database!"); return false; } if (ReadHash(dbp,type,filename,dbdigest)) { for (i = 0; i < size; i++) { if (digest[i] != dbdigest[i]) { Debug("Found cryptohash for %s in database but it didn't match\n",filename); if (EXCLAIM) { CfOut(warnlevel,"","!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } CfOut(warnlevel,"","ALERT: Hash (%s) for %s changed!",FileHashName(type),filename); if (pp->ref) { CfOut(warnlevel,"","Preceding promise: %s",pp->ref); } if (EXCLAIM) { CfOut(warnlevel,"","!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } if (attr.change.update) { cfPS(warnlevel,CF_CHG,"",pp,attr," -> Updating hash for %s to %s",filename,HashPrint(type,digest)); DeleteHash(dbp,type,filename); WriteHash(dbp,type,filename,digest); } else { cfPS(warnlevel,CF_FAIL,"",pp,attr,"!! Hash for file \"%s\" changed",filename); } CloseDB(dbp); return true; } } cfPS(cf_verbose,CF_NOP,"",pp,attr," -> File hash for %s is correct",filename); CloseDB(dbp); return false; } else { char s[CF_BUFSIZE]; snprintf(s,CF_BUFSIZE," !! File %s was not in %s database - new file found",filename,FileHashName(type)); /* Key was not found, so install it */ cfPS(warnlevel,CF_CHG,"",pp,attr,s); Debug("Storing checksum for %s in database %s\n",filename,HashPrint(type,digest)); WriteHash(dbp,type,filename,digest); LogHashChange(s); CloseDB(dbp); return false; } } /*******************************************************************/ int CompareFileHashes(char *file1,char *file2,struct stat *sstat,struct stat *dstat,struct Attributes attr,struct Promise *pp) { static unsigned char digest1[EVP_MAX_MD_SIZE+1], digest2[EVP_MAX_MD_SIZE+1]; int i; Debug("CompareFileHashes(%s,%s)\n",file1,file2); if (sstat->st_size != dstat->st_size) { Debug("File sizes differ, no need to compute checksum\n"); return true; } if (attr.copy.servers == NULL || strcmp(attr.copy.servers->item,"localhost") == 0) { HashFile(file1,digest1,CF_DEFAULT_DIGEST); HashFile(file2,digest2,CF_DEFAULT_DIGEST); for (i = 0; i < EVP_MAX_MD_SIZE; i++) { if (digest1[i] != digest2[i]) { return true; } } Debug("Files were identical\n"); return false; /* only if files are identical */ } else { return CompareHashNet(file1,file2,attr,pp); /* client.c */ } } /*******************************************************************/ int CompareBinaryFiles(char *file1,char *file2,struct stat *sstat,struct stat *dstat,struct Attributes attr,struct Promise *pp) { int fd1, fd2,bytes1,bytes2; char buff1[BUFSIZ],buff2[BUFSIZ]; Debug("CompareBinarySums(%s,%s)\n",file1,file2); if (sstat->st_size != dstat->st_size) { Debug("File sizes differ, no need to compute checksum\n"); return true; } if (attr.copy.servers == NULL || strcmp(attr.copy.servers->item,"localhost") == 0) { fd1 = open(file1, O_RDONLY|O_BINARY, 0400); fd2 = open(file2, O_RDONLY|O_BINARY, 0400); do { bytes1 = read(fd1, buff1, BUFSIZ); bytes2 = read(fd2, buff2, BUFSIZ); if ((bytes1 != bytes2) || (memcmp(buff1, buff2, bytes1) != 0)) { CfOut(cf_verbose,"","Binary Comparison mismatch...\n"); close(fd2); close(fd1); return true; } } while (bytes1 > 0); close(fd2); close(fd1); return false; /* only if files are identical */ } else { Debug("Using network checksum instead\n"); return CompareHashNet(file1,file2,attr,pp); /* client.c */ } } /*******************************************************************/ void HashFile(char *filename,unsigned char digest[EVP_MAX_MD_SIZE+1],enum cfhashes type) { FILE *file; EVP_MD_CTX context; int len, md_len; unsigned char buffer[1024]; const EVP_MD *md = NULL; Debug2("HashFile(%d,%s)\n",type,filename); if ((file = fopen(filename, "rb")) == NULL) { CfOut(cf_inform,"fopen","%s can't be opened\n", filename); } else { md = EVP_get_digestbyname(FileHashName(type)); EVP_DigestInit(&context,md); while ((len = fread(buffer,1,1024,file))) { EVP_DigestUpdate(&context,buffer,len); } EVP_DigestFinal(&context,digest,&md_len); /* Digest length stored in md_len */ fclose (file); } } /*******************************************************************/ static void HashList(struct Item *list,unsigned char digest[EVP_MAX_MD_SIZE+1],enum cfhashes type) { struct Item *ip; EVP_MD_CTX context; int md_len; const EVP_MD *md = NULL; Debug2("HashList(%s)\n",FileHashName(type)); memset(digest,0,EVP_MAX_MD_SIZE+1); md = EVP_get_digestbyname(FileHashName(type)); EVP_DigestInit(&context,md); for (ip = list; ip != NULL; ip=ip->next) { Debug(" digesting %s\n",ip->name); EVP_DigestUpdate(&context,ip->name,strlen(ip->name)); } EVP_DigestFinal(&context,digest,&md_len); } /*******************************************************************/ void HashString(char *buffer,int len,unsigned char digest[EVP_MAX_MD_SIZE+1],enum cfhashes type) { EVP_MD_CTX context; const EVP_MD *md = NULL; int md_len; Debug2("HashString(%c)\n",type); switch (type) { case cf_crypt: CfOut(cf_error,"","The crypt support is not presently implemented, please use another algorithm instead"); memset(digest,0,EVP_MAX_MD_SIZE+1); break; default: md = EVP_get_digestbyname(FileHashName(type)); if (md == NULL) { CfOut(cf_inform,""," !! Digest type %s not supported by OpenSSL library",CF_DIGEST_TYPES[type][0]); } EVP_DigestInit(&context,md); EVP_DigestUpdate(&context,(unsigned char*)buffer,(size_t)len); EVP_DigestFinal(&context,digest,&md_len); break; } } /*******************************************************************/ void HashPubKey(RSA *key,unsigned char digest[EVP_MAX_MD_SIZE+1],enum cfhashes type) { EVP_MD_CTX context; const EVP_MD *md = NULL; int md_len,i,buf_len, actlen; unsigned char *buffer; Debug("HashPubKey(%d)\n",type); //RSA_print_fp(stdout,key,0); if (key->n) { buf_len = (size_t)BN_num_bytes(key->n); } else { buf_len = 0; } if (key->e) { if (buf_len < (i = (size_t)BN_num_bytes(key->e))) { buf_len = i; } } if ((buffer = malloc(buf_len+10)) == NULL) { FatalError("Memory alloc in HashPubKey"); } switch (type) { case cf_crypt: CfOut(cf_error,"","The crypt support is not presently implemented, please use sha256 instead"); break; default: md = EVP_get_digestbyname(FileHashName(type)); if (md == NULL) { CfOut(cf_inform,""," !! Digest type %s not supported by OpenSSL library",CF_DIGEST_TYPES[type][0]); } EVP_DigestInit(&context,md); actlen = BN_bn2bin(key->n,buffer); EVP_DigestUpdate(&context,buffer,actlen); actlen = BN_bn2bin(key->e,buffer); EVP_DigestUpdate(&context,buffer,actlen); EVP_DigestFinal(&context,digest,&md_len); break; } free(buffer); } /*******************************************************************/ int HashesMatch(unsigned char digest1[EVP_MAX_MD_SIZE+1],unsigned char digest2[EVP_MAX_MD_SIZE+1],enum cfhashes type) { int i,size = EVP_MAX_MD_SIZE; size = FileHashSize(type); Debug("1. CHECKING DIGEST type %d - size %d (%s)\n",type,size,HashPrint(type,digest1)); Debug("2. CHECKING DIGEST type %d - size %d (%s)\n",type,size,HashPrint(type,digest2)); for (i = 0; i < size; i++) { if (digest1[i] != digest2[i]) { return false; } } return true; } /*********************************************************************/ char *HashPrint(enum cfhashes type,unsigned char digest[EVP_MAX_MD_SIZE+1]) /** * WARNING: Not thread-safe (returns pointer to global memory). * Use HashPrintSafe for a thread-safe equivalent */ { static char buffer[EVP_MAX_MD_SIZE*4]; HashPrintSafe(type,digest,buffer); return buffer; } /*********************************************************************/ char *HashPrintSafe(enum cfhashes type,unsigned char digest[EVP_MAX_MD_SIZE+1], char buffer[EVP_MAX_MD_SIZE*4]) /** * Thread safe. Note the buffer size. */ { unsigned int i; switch (type) { case cf_md5: sprintf(buffer,"MD5= "); break; default: sprintf(buffer,"SHA= "); break; } for (i = 0; i < CF_DIGEST_SIZES[type]; i++) { sprintf((char *)(buffer+4+2*i),"%02x", digest[i]); } return buffer; } /***************************************************************/ void PurgeHashes(char *path,struct Attributes attr,struct Promise *pp) /* Go through the database and purge records about non-existent files */ { CF_DB *dbp; CF_DBC *dbcp; struct stat statbuf; int ksize,vsize; char *key; void *value; if (!OpenDB(HASHDB,&dbp)) { return; } if (path) { if (cfstat(path,&statbuf) == -1) { DeleteDB(dbp,path); } CloseDB(dbp); return; } /* Acquire a cursor for the database. */ if (!NewDBCursor(dbp,&dbcp)) { CfOut(cf_inform,""," !! Unable to scan hash database"); CloseDB(dbp); return; } /* Walk through the database and print out the key/data pairs. */ while(NextDB(dbp,dbcp,&key,&ksize,&value,&vsize)) { char *obj = (char *)key + CF_INDEX_OFFSET; if (cfstat(obj,&statbuf) == -1) { char s[CF_BUFSIZE]; snprintf(s,CF_BUFSIZE,"ALERT: %s file no longer exists!",obj); if (attr.change.update) { if (DeleteComplexKeyDB(dbp,key,ksize)) { cfPS(cf_error,CF_CHG,"",pp,attr,s); } } else { cfPS(cf_error,CF_WARN,"",pp,attr,s); } LogHashChange(s); } memset(&key,0,sizeof(key)); memset(&value,0,sizeof(value)); } DeleteDBCursor(dbp,dbcp); CloseDB(dbp); } /*****************************************************************************/ static int ReadHash(CF_DB *dbp,enum cfhashes type,char *name,unsigned char digest[EVP_MAX_MD_SIZE+1]) { char *key; int size; struct Checksum_Value chk_val; key = NewIndexKey(type,name,&size); if (ReadComplexKeyDB(dbp,key,size,(void *)&chk_val,sizeof(struct Checksum_Value))) { memset(digest,0,EVP_MAX_MD_SIZE+1); memcpy(digest,chk_val.mess_digest,EVP_MAX_MD_SIZE+1); DeleteIndexKey(key); return true; } else { DeleteIndexKey(key); return false; } } /*****************************************************************************/ static int WriteHash(CF_DB *dbp,enum cfhashes type,char *name,unsigned char digest[EVP_MAX_MD_SIZE+1]) { char *key; struct Checksum_Value *value; int ret, keysize; key = NewIndexKey(type,name,&keysize); value = NewHashValue(digest); ret = WriteComplexKeyDB(dbp,key,keysize,value,sizeof(struct Checksum_Value)); DeleteIndexKey(key); DeleteHashValue(value); return ret; } /*****************************************************************************/ void DeleteHash(CF_DB *dbp,enum cfhashes type,char *name) { int size; char *key; key = NewIndexKey(type,name,&size); DeleteComplexKeyDB(dbp,key,size); DeleteIndexKey(key); } /*****************************************************************************/ /* level */ /*****************************************************************************/ static char *NewIndexKey(char type,char *name, int *size) { char *chk_key; // Filename plus index_str in one block + \0 *size = strlen(name)+CF_INDEX_OFFSET+1; if ((chk_key = malloc(*size)) == NULL) { FatalError("NewIndexKey malloc error"); } // Data start after offset for index memset(chk_key,0,*size); strncpy(chk_key,FileHashName(type),CF_INDEX_FIELD_LEN); strncpy(chk_key+CF_INDEX_OFFSET,name,strlen(name)); return chk_key; } /*****************************************************************************/ static void DeleteIndexKey(char *key) { free(key); } /*****************************************************************************/ struct Checksum_Value *NewHashValue(unsigned char digest[EVP_MAX_MD_SIZE+1]) { struct Checksum_Value *chk_val; if ((chk_val = (struct Checksum_Value *)malloc(sizeof(struct Checksum_Value))) == NULL) { FatalError("NewHashValue malloc error"); } memset(chk_val,0,sizeof(struct Checksum_Value)); memcpy(chk_val->mess_digest,digest,EVP_MAX_MD_SIZE+1); /* memcpy(chk_val->attr_digest,attr,EVP_MAX_MD_SIZE+1); depricated */ return chk_val; } /*****************************************************************************/ static void DeleteHashValue(struct Checksum_Value *chk_val) { free((char *)chk_val); } /*********************************************************************/ char *FileHashName(enum cfhashes id) { return CF_DIGEST_TYPES[id][0]; } /***************************************************************************/ static int FileHashSize(enum cfhashes id) { return CF_DIGEST_SIZES[id]; } ����������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/dtypes.c�������������������������������������������������������������������������0000644�0001750�0001750�00000004257�11715232734�012477� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: dtypes.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int IsProcessType(char *s); /*****************************************************************/ int IsSocketType(char *s) { int i; for (i = 0; i < ATTR; i++) { if (strstr(s,ECGSOCKS[i].name)) { Debug("IsSocketType(%s=%s)\n",s,ECGSOCKS[i].name); return true; } } return false; } /*****************************************************************/ int IsTCPType(char *s) { int i; for (i = 0; i < CF_NETATTR; i++) { if (strstr(s,TCPNAMES[i])) { Debug("IsTCPType(%s)\n",s); return true; } } return false; } /*****************************************************************/ static int IsProcessType(char *s) { if (strcmp(s,"procs") == 0) { return true; } return false; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/files_interfaces.c���������������������������������������������������������������0000644�0001750�0001750�00000145337�11715232734�014501� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: files_interfaces.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static void PurgeLocalFiles(struct Item *filelist,char *directory,struct Attributes attr,struct Promise *pp); static void CfCopyFile(char *sourcefile,char *destfile,struct stat sourcestatbuf,struct Attributes attr, struct Promise *pp); static int CompareForFileCopy(char *sourcefile,char *destfile,struct stat *ssb, struct stat *dsb,struct Attributes attr,struct Promise *pp); static void RegisterAHardLink(int i,char *value,struct Attributes attr, struct Promise *pp); static void FileAutoDefine(char *destfile); static void LoadSetuid(struct Attributes a,struct Promise *pp); static void SaveSetuid(struct Attributes a,struct Promise *pp); /*****************************************************************************/ /* File copying is a special case, particularly complex - cannot be integrated */ void SourceSearchAndCopy(char *from,char *to,int maxrecurse,struct Attributes attr,struct Promise *pp) { struct stat sb, dsb; char newfrom[CF_BUFSIZE]; char newto[CF_BUFSIZE]; struct Item *namecache = NULL; const struct dirent *dirp; CFDIR *dirh; if (maxrecurse == 0) /* reached depth limit */ { Debug("MAXRECURSE ran out, quitting at level %s\n",from); return; } Debug("RecursiveCopy(%s,%s,lev=%d)\n",from,to,maxrecurse); if (strlen(from) == 0) /* Check for root dir */ { from = "/"; } /* Check that dest dir exists before starting */ strncpy(newto,to,CF_BUFSIZE-10); AddSlash(newto); strcat(newto,"dummy"); if (attr.transaction.action != cfa_warn) { struct stat tostat; if (!MakeParentDirectory(newto,attr.move_obstructions)) { cfPS(cf_error,CF_FAIL,"",pp,attr,"Unable to make directory for %s in file-copy %s to %s\n",newto,attr.copy.source,attr.copy.destination); return; } DeleteSlash(to); /* Set aside symlinks */ if (lstat(to, &tostat) != 0) { cfPS(cf_error, CF_WARN, "lstat", pp, attr, "Unable to stat newly created directory %s", to); return; } if (S_ISLNK(tostat.st_mode)) { char backup[CF_BUFSIZE]; mode_t mask; if (!attr.move_obstructions) { CfOut(cf_inform, "", "Path %s is a symlink. Unable to move it aside without move_obstructions is set"); return; } strcpy(backup, to); DeleteSlash(to); strcat(backup, ".cf-moved"); if (cf_rename(to, backup) == -1) { CfOut(cf_inform, "", "Unable to backup old %s", to); unlink(to); } mask = umask(0); if (cf_mkdir(to, DEFAULTMODE) == -1) { CfOut(cf_error, "cf_mkdir", "Unable to make directory %s", to); umask(mask); return; } umask(mask); } } if ((dirh = OpenDirForPromise(from,attr,pp)) == NULL) { cfPS(cf_inform,CF_INTERPT,"",pp,attr,"copy can't open directory [%s]\n",from); return; } for (dirp = ReadDir(dirh); dirp != NULL; dirp = ReadDir(dirh)) { if (!ConsiderFile(dirp->d_name,from,attr,pp)) { continue; } if (attr.copy.purge) /* Do not purge this file */ { AppendItem(&namecache,dirp->d_name,NULL); } strncpy(newfrom,from,CF_BUFSIZE-2); /* Assemble pathname */ strncpy(newto,to,CF_BUFSIZE-2); if (!JoinPath(newfrom,dirp->d_name)) { CloseDir(dirh); return; } if (attr.recursion.travlinks || attr.copy.link_type == cfa_notlinked) { /* No point in checking if there are untrusted symlinks here, since this is from a trusted source, by defintion */ if (cf_stat(newfrom,&sb,attr,pp) == -1) { CfOut(cf_verbose,"cf_stat"," !! (Can't stat %s)\n",newfrom); continue; } } else { if (cf_lstat(newfrom,&sb,attr,pp) == -1) { CfOut(cf_verbose,"cf_stat"," !! (Can't stat %s)\n",newfrom); continue; } } /* If we are tracking subdirs in copy, then join else don't add*/ if (attr.copy.collapse) { if (!S_ISDIR(sb.st_mode) && !JoinPath(newto,dirp->d_name)) { CloseDir(dirh); return; } } else { if (!JoinPath(newto,dirp->d_name)) { CloseDir(dirh); return; } } if (attr.recursion.xdev && DeviceBoundary(&sb,pp)) { CfOut(cf_verbose,""," !! Skipping %s on different device\n",newfrom); continue; } if (S_ISDIR(sb.st_mode)) { if (attr.recursion.travlinks) { CfOut(cf_verbose,"","Traversing directory links during copy is too dangerous, pruned"); continue; } if (SkipDirLinks(newfrom,dirp->d_name,attr.recursion)) { continue; } memset(&dsb,0,sizeof(struct stat)); /* Only copy dirs if we are tracking subdirs */ if (!attr.copy.collapse && (cfstat(newto,&dsb) == -1)) { if (cf_mkdir(newto,0700) == -1) { cfPS(cf_error,CF_INTERPT,"cf_mkdir",pp,attr," !! Can't make directory %s\n",newto); continue; } if (cfstat(newto,&dsb) == -1) { cfPS(cf_error,CF_INTERPT,"stat",pp,attr," !! Can't stat local copy %s - failed to establish directory\n",newto); continue; } } CfOut(cf_verbose,""," ->> Entering %s\n",newto); if (!attr.copy.collapse) { VerifyCopiedFileAttributes(newto,&dsb,&sb,attr,pp); } SourceSearchAndCopy(newfrom,newto,maxrecurse-1,attr,pp); } else { VerifyCopy(newfrom,newto,attr,pp); } } if (attr.copy.purge) { PurgeLocalFiles(namecache,to,attr,pp); DeleteItemList(namecache); } DeleteCompressedArray(pp->inode_cache); pp->inode_cache = NULL; CloseDir(dirh); } /*******************************************************************/ /* Level */ /*******************************************************************/ void VerifyFilePromise(char *path,struct Promise *pp) { struct stat osb,oslb,dsb; struct Attributes a = {{0}}; struct CfLock thislock; int exists,success,rlevel = 0; a = GetFilesAttributes(pp); if (!FileSanityChecks(path,a,pp)) { return; } thislock = AcquireLock(path,VUQNAME,CFSTARTTIME,a,pp,false); if (thislock.lock == NULL) { return; } CF_OCCUR++; LoadSetuid(a,pp); if (lstat(path,&oslb) == -1) /* Careful if the object is a link */ { if (a.create||a.touch) { if (!CfCreateFile(path,pp,a)) { SaveSetuid(a,pp); YieldCurrentLock(thislock); return; } else { exists = (lstat(path,&oslb) != -1); } } exists = false; } else { if (a.create||a.touch) { cfPS(cf_verbose,CF_NOP,"",pp,a," -> File \"%s\" exists as promised",path); } exists = true; } if (a.havedelete && !exists) { cfPS(cf_verbose,CF_NOP,"",pp,a," -> File \"%s\" does not exist as promised",path); } if (!a.havedepthsearch) /* if the search is trivial, make sure that we are in the parent dir of the leaf */ { char basedir[CF_BUFSIZE]; Debug(" -> Direct file reference %s, no search implied\n",path); snprintf(basedir, sizeof(basedir), "%s", path); if (strcmp(ReadLastNode(basedir),".") == 0) { // Handle /. notation for deletion of directories ChopLastNode(basedir); ChopLastNode(path); } ChopLastNode(basedir); chdir(basedir); } if (exists && !VerifyFileLeaf(path,&oslb,a,pp)) { if (!S_ISDIR(oslb.st_mode)) { SaveSetuid(a,pp); YieldCurrentLock(thislock); return; } } if (cfstat(path,&osb) == -1) { if (a.create||a.touch) { if (!CfCreateFile(path,pp,a)) { SaveSetuid(a,pp); YieldCurrentLock(thislock); return; } else { exists = true; } } else { exists = false; } } else { if (!S_ISDIR(osb.st_mode)) { if (a.havedepthsearch) { CfOut(cf_inform,"","Warning: depth_search (recursion) is promised for a base object %s that is not a directory",path); SaveSetuid(a,pp); YieldCurrentLock(thislock); return; } } exists = true; } if (a.link.link_children) { if (cfstat(a.link.source,&dsb) != -1) { if (!S_ISDIR(dsb.st_mode)) { CfOut(cf_error,"","Cannot promise to link the children of %s as it is not a directory!",a.link.source); SaveSetuid(a,pp); YieldCurrentLock(thislock); return; } } } /* Phase 1 - */ if (exists && (a.havedelete||a.haverename||a.haveperms||a.havechange||a.transformer)) { lstat(path,&oslb); /* if doesn't exist have to stat again anyway */ if (a.havedepthsearch) { SetSearchDevice(&oslb,pp); } success = DepthSearch(path,&oslb,rlevel,a,pp); /* normally searches do not include the base directory */ if (a.recursion.include_basedir) { int save_search = a.havedepthsearch; /* Handle this node specially */ a.havedepthsearch = false; success = DepthSearch(path,&oslb,rlevel,a,pp); a.havedepthsearch = save_search; } if (a.change.report_changes == cfa_contentchange || a.change.report_changes == cfa_allchanges) { if (a.havedepthsearch) { PurgeHashes(NULL,a,pp); } else { PurgeHashes(path,a,pp); } } } /* Phase 2a - copying is potentially threadable if no followup actions */ if (a.havecopy) { ScheduleCopyOperation(path,a,pp); } /* Phase 2b link after copy in case need file first */ if (a.havelink && a.link.link_children) { ScheduleLinkChildrenOperation(path,a.link.source,1,a,pp); } else if (a.havelink) { ScheduleLinkOperation(path,a.link.source,a,pp); } /* Phase 3 - content editing */ if (a.haveedit) { ScheduleEditOperation(path,a,pp); } // Once more in case a file has been created as a result of editing or copying if (cfstat(path,&osb) != -1 && S_ISREG(osb.st_mode)) { VerifyFileLeaf(path,&osb,a,pp); } SaveSetuid(a,pp); YieldCurrentLock(thislock); } /*********************************************************************/ void VerifyCopy(char *source,char *destination,struct Attributes attr,struct Promise *pp) { CFDIR *dirh; char sourcefile[CF_BUFSIZE]; char sourcedir[CF_BUFSIZE]; char destdir[CF_BUFSIZE]; char destfile[CF_BUFSIZE]; struct stat ssb, dsb; const struct dirent *dirp; int found; Debug("VerifyCopy (source=%s destination=%s)\n",source,destination); if (attr.copy.link_type == cfa_notlinked) { Debug("Treating links as files for %s\n",source); found = cf_stat(source,&ssb,attr,pp); } else { found = cf_lstat(source,&ssb,attr,pp); } if (found == -1) { cfPS(cf_error,CF_FAIL,"",pp,attr,"Can't stat %s in verify copy\n",source); DeleteClientCache(attr,pp); return; } if (ssb.st_nlink > 1) /* Preserve hard link structure when copying */ { RegisterAHardLink(ssb.st_ino,destination,attr,pp); } if (S_ISDIR(ssb.st_mode)) { strcpy(sourcedir,source); AddSlash(sourcedir); strcpy(destdir,destination); AddSlash(destdir); if ((dirh = OpenDirForPromise(sourcedir,attr,pp)) == NULL) { cfPS(cf_verbose,CF_FAIL,"opendir",pp,attr,"Can't open directory %s\n",sourcedir); DeleteClientCache(attr,pp); return; } /* Now check any overrides */ if (cfstat(destdir,&dsb) == -1) { cfPS(cf_error,CF_FAIL,"stat",pp,attr,"Can't stat directory %s\n",destdir); } else { VerifyCopiedFileAttributes(destdir,&dsb,&ssb,attr,pp); } for (dirp = ReadDir(dirh); dirp != NULL; dirp = ReadDir(dirh)) { if (!ConsiderFile(dirp->d_name,sourcedir,attr,pp)) { continue; } strcpy(sourcefile, sourcedir); if (!JoinPath(sourcefile,dirp->d_name)) { FatalError("VerifyCopy"); } strcpy(destfile,destdir); if (!JoinPath(destfile,dirp->d_name)) { FatalError("VerifyCopy"); } if (attr.copy.link_type == cfa_notlinked) { if (cf_stat(sourcefile,&ssb,attr,pp) == -1) { cfPS(cf_inform,CF_FAIL,"stat",pp,attr,"Can't stat source file (notlinked) %s\n",sourcefile); DeleteClientCache(attr,pp); return; } } else { if (cf_lstat(sourcefile,&ssb,attr,pp) == -1) { cfPS(cf_inform,CF_FAIL,"lstat",pp,attr,"Can't stat source file %s\n",sourcefile); DeleteClientCache(attr,pp); return; } } CfCopyFile(sourcefile,destfile,ssb,attr,pp); } CloseDir(dirh); DeleteClientCache(attr,pp); return; } strcpy(sourcefile,source); strcpy(destfile,destination); CfCopyFile(sourcefile,destfile,ssb,attr,pp); DeleteClientCache(attr,pp); } /*********************************************************************/ static void PurgeLocalFiles(struct Item *filelist,char *localdir,struct Attributes attr,struct Promise *pp) { CFDIR *dirh; struct stat sb; const struct dirent *dirp; char filename[CF_BUFSIZE] = {0}; Debug("PurgeLocalFiles(%s)\n",localdir); if (strlen(localdir) < 2) { CfOut(cf_error,"","Purge of %s denied -- too dangerous!",localdir); return; } /* If we purge with no authentication we wipe out EVERYTHING ! */ if (pp->conn && !pp->conn->authenticated) { CfOut(cf_verbose,""," !! Not purge local files %s - no authenticated contact with a source\n",localdir); return; } if (!attr.havedepthsearch) { CfOut(cf_verbose,""," !! No depth search when copying %s so purging does not apply\n",localdir); return; } /* chdir to minimize the risk of race exploits during copy (which is inherently dangerous) */ if (chdir(localdir) == -1) { CfOut(cf_verbose,"chdir","Can't chdir to local directory %s\n",localdir); return; } if ((dirh = OpenDirLocal(".")) == NULL) { CfOut(cf_verbose,"opendir","Can't open local directory %s\n",localdir); return; } for (dirp = ReadDir(dirh); dirp != NULL; dirp = ReadDir(dirh)) { if (!ConsiderFile(dirp->d_name,localdir,attr,pp)) { continue; } if (!IsItemIn(filelist,dirp->d_name)) { strncpy(filename,localdir,CF_BUFSIZE-2); AddSlash(filename); Join(filename,dirp->d_name,CF_BUFSIZE-1); if (DONTDO) { printf(" !! Need to purge %s from copy dest directory\n",filename); } else { CfOut(cf_inform,""," !! Purging %s in copy dest directory\n",filename); if (lstat(filename,&sb) == -1) { cfPS(cf_verbose,CF_INTERPT,"lstat",pp,attr," !! Couldn't stat %s while purging\n",filename); } else if (S_ISDIR(sb.st_mode)) { struct Attributes purgeattr = {{0}}; memset(&purgeattr,0,sizeof(purgeattr)); /* Deletion is based on a files promise */ purgeattr.havedepthsearch = true; purgeattr.havedelete = true; purgeattr.delete.dirlinks = cfa_linkdelete; purgeattr.delete.rmdirs = true; purgeattr.recursion.depth = CF_INFINITY; purgeattr.recursion.travlinks = false; purgeattr.recursion.xdev = false; SetSearchDevice(&sb,pp); if (!DepthSearch(filename,&sb,0,purgeattr,pp)) { cfPS(cf_verbose,CF_INTERPT,"rmdir",pp,attr," !! Couldn't empty directory %s while purging\n",filename); } if (chdir("..") != 0) { CfOut(cf_error, "chdir", "!! Can't step out of directory \"%s\" before deletion",filename); } if (rmdir(filename) == -1) { cfPS(cf_verbose,CF_INTERPT,"rmdir",pp,attr," !! Couldn't remove directory %s while purging\n",filename); } } else if (unlink(filename) == -1) { cfPS(cf_verbose,CF_FAIL,"",pp,attr," !! Couldn't delete %s while purging\n",filename); } } } } CloseDir(dirh); } /*********************************************************************/ static void CfCopyFile(char *sourcefile,char *destfile,struct stat ssb,struct Attributes attr, struct Promise *pp) { char *server; const char *lastnode; struct stat dsb; int found; mode_t srcmode = ssb.st_mode; Debug2("CopyFile(%s,%s)\n",sourcefile,destfile); #ifdef MINGW if(attr.copy.copy_links != NULL) { CfOut(cf_verbose, "", "copy_from.copylink_patterns is ignored on Windows (source files cannot be symbolic links)"); } #endif /* MINGW */ attr.link.when_no_file = cfa_force; if (attr.copy.servers) { server = (char *)attr.copy.servers->item; } else { server = NULL; } if ((strcmp(sourcefile,destfile) == 0) && server && (strcmp(server,"localhost") == 0)) { CfOut(cf_inform,""," !! File copy promise loop: file/dir %s is its own source",sourcefile); return; } if (!SelectLeaf(sourcefile,&ssb,attr,pp)) { Debug("Skipping non-selected file %s\n",sourcefile); return; } if (IsInListOfRegex(SINGLE_COPY_CACHE,destfile)) { CfOut(cf_inform,""," -> Skipping single-copied file %s\n",destfile); return; } if (attr.copy.link_type != cfa_notlinked) { lastnode=ReadLastNode(sourcefile); if (MatchRlistItem(attr.copy.link_instead,lastnode)) { if (MatchRlistItem(attr.copy.copy_links,lastnode)) { CfOut(cf_inform,"","File %s matches both copylink_patterns and linkcopy_patterns - promise loop (skipping)!",sourcefile); return; } else { CfOut(cf_verbose,"","Copy item %s marked for linking\n",sourcefile); #ifdef MINGW CfOut(cf_verbose,"","Links are not yet supported on Windows - copying instead\n",sourcefile); #else LinkCopy(sourcefile,destfile,&ssb,attr,pp); return; #endif } } } found = lstat(destfile,&dsb); if (found != -1) { if ((S_ISLNK(dsb.st_mode) && (attr.copy.link_type == cfa_notlinked)) || (S_ISLNK(dsb.st_mode) && ! S_ISLNK(ssb.st_mode))) { if (!S_ISLNK(ssb.st_mode) && (attr.copy.type_check && (attr.copy.link_type != cfa_notlinked))) { cfPS(cf_error,CF_FAIL,"",pp,attr,"file image exists but destination type is silly (file/dir/link doesn't match)\n"); PromiseRef(cf_error,pp); return; } if (DONTDO) { CfOut(cf_verbose,"","Need to remove old symbolic link %s to make way for copy\n",destfile); } else { if (unlink(destfile) == -1) { cfPS(cf_error,CF_FAIL,"unlink",pp,attr,"Couldn't remove link %s",destfile); return; } CfOut(cf_verbose,"","Removing old symbolic link %s to make way for copy\n",destfile); found = -1; } } } else { MakeParentDirectory(destfile,true); } if (attr.copy.min_size != CF_NOINT) { if (ssb.st_size < attr.copy.min_size || ssb.st_size > attr.copy.max_size) { cfPS(cf_verbose,CF_NOP,"",pp,attr," -> Source file %s size is not in the permitted safety range\n",sourcefile); return; } } if (found == -1) { if (attr.transaction.action == cfa_warn) { cfPS(cf_error,CF_WARN,"",pp,attr," !! Image file \"%s\" is non-existent and should be a copy of %s\n",destfile,sourcefile); return; } if (S_ISREG(srcmode) || (S_ISLNK(srcmode) && attr.copy.link_type == cfa_notlinked)) { if (DONTDO) { CfOut(cf_verbose,""," -> %s wasn't at destination (needs copying)",destfile); return; } else { CfOut(cf_verbose,""," -> %s wasn't at destination (copying)",destfile); if (server) { CfOut(cf_inform,""," -> Copying from %s:%s\n",server,sourcefile); } else { CfOut(cf_inform,""," -> Copying from localhost:%s\n",sourcefile); } } if (S_ISLNK(srcmode) && attr.copy.link_type != cfa_notlinked) { CfOut(cf_verbose,""," -> %s is a symbolic link\n",sourcefile); LinkCopy(sourcefile,destfile,&ssb,attr,pp); } else if (CopyRegularFile(sourcefile,destfile,ssb,dsb,attr,pp)) { if (cfstat(destfile,&dsb) == -1) { CfOut(cf_error,"stat","Can't stat destination file %s\n",destfile); } else { VerifyCopiedFileAttributes(destfile,&dsb,&ssb,attr,pp); } if (server) { cfPS(cf_verbose,CF_CHG,"",pp,attr," -> Updated file from %s:%s\n",server,sourcefile); } else { cfPS(cf_verbose,CF_CHG,"",pp,attr," -> Updated file from localhost:%s\n",sourcefile); } if (SINGLE_COPY_LIST) { IdempPrependRScalar(&SINGLE_COPY_CACHE,destfile,CF_SCALAR); } if (MatchRlistItem(AUTO_DEFINE_LIST,destfile)) { FileAutoDefine(destfile); } } else { if (server) { cfPS(cf_inform,CF_FAIL,"",pp,attr," !! Copy from %s:%s failed\n",server,sourcefile); } else { cfPS(cf_inform,CF_FAIL,"",pp,attr," !! Copy from localhost:%s failed\n",sourcefile); } } return; } if (S_ISFIFO (srcmode)) { #ifdef HAVE_MKFIFO if (DONTDO) { CfOut(cf_inform,"","Need to make FIFO %s\n",destfile); } else if (mkfifo(destfile,srcmode)) { cfPS(cf_error,CF_FAIL,"mkfifo",pp,attr," !! Cannot create fifo `%s'", destfile); return; } cfPS(cf_inform,CF_CHG,"",pp,attr," -> Created fifo %s", destfile); #endif } else { #ifndef MINGW // only regular files on windows if (S_ISBLK (srcmode) || S_ISCHR (srcmode) || S_ISSOCK (srcmode)) { if (DONTDO) { CfOut(cf_inform,"","Make BLK/CHR/SOCK %s\n",destfile); } else if (mknod (destfile, srcmode, ssb.st_rdev)) { cfPS(cf_error,CF_FAIL,"mknod",pp,attr," !! Cannot create special file `%s'",destfile); return; } cfPS(cf_inform,CF_CHG,"mknod",pp,attr," -> Created special file/device `%s'",destfile); } #endif /* NOT MINGW */ } if (S_ISLNK(srcmode) && attr.copy.link_type != cfa_notlinked) { LinkCopy(sourcefile,destfile,&ssb,attr,pp); } } else { int ok_to_copy = false; CfOut(cf_verbose,""," -> Destination file \"%s\" already exists\n",destfile); if (attr.copy.compare == cfa_exists) { CfOut(cf_verbose,""," -> Existence only is promised, no copying required\n",destfile); return; } if (!attr.copy.force_update) { ok_to_copy = CompareForFileCopy(sourcefile,destfile,&ssb,&dsb,attr,pp); } else { ok_to_copy = true; } if (attr.copy.type_check && attr.copy.link_type != cfa_notlinked) { if ((S_ISDIR(dsb.st_mode) && ! S_ISDIR(ssb.st_mode)) || (S_ISREG(dsb.st_mode) && ! S_ISREG(ssb.st_mode)) || (S_ISBLK(dsb.st_mode) && ! S_ISBLK(ssb.st_mode)) || (S_ISCHR(dsb.st_mode) && ! S_ISCHR(ssb.st_mode)) || (S_ISSOCK(dsb.st_mode) && ! S_ISSOCK(ssb.st_mode)) || (S_ISFIFO(dsb.st_mode) && ! S_ISFIFO(ssb.st_mode)) || (S_ISLNK(dsb.st_mode) && ! S_ISLNK(ssb.st_mode))) { cfPS(cf_inform,CF_FAIL,"",pp,attr,"Promised file copy %s exists but type mismatch with source=%s\n",destfile,sourcefile); return; } } if (ok_to_copy && (attr.transaction.action == cfa_warn)) { cfPS(cf_error,CF_WARN,"",pp,attr," !! Image file \"%s\" exists but is not up to date wrt %s\n",destfile,sourcefile); cfPS(cf_error,CF_WARN,"",pp,attr," !! Only a warning has been promised\n"); return; } if (attr.copy.force_update || ok_to_copy || S_ISLNK(ssb.st_mode)) /* Always check links */ { if (S_ISREG(srcmode) || attr.copy.link_type == cfa_notlinked) { if (DONTDO) { CfOut(cf_error,"","Should update file %s from source %s on %s",destfile,sourcefile,server); return; } else { if (server) { cfPS(cf_inform,CF_CHG,"",pp,attr," -> Updated %s from source %s on %s",destfile,sourcefile,server); } else { cfPS(cf_inform,CF_CHG,"",pp,attr," -> Updated %s from source %s on localhost",destfile,sourcefile); } } if (MatchRlistItem(AUTO_DEFINE_LIST,destfile)) { FileAutoDefine(destfile); } if (CopyRegularFile(sourcefile,destfile,ssb,dsb,attr,pp)) { if (cfstat(destfile,&dsb) == -1) { cfPS(cf_error,CF_INTERPT,"stat",pp,attr,"Can't stat destination %s\n",destfile); } else { VerifyCopiedFileAttributes(destfile,&dsb,&ssb,attr,pp); } if (IsInListOfRegex(SINGLE_COPY_LIST,destfile)) { IdempPrependRScalar(&SINGLE_COPY_CACHE,destfile,CF_SCALAR); } } else { cfPS(cf_error,CF_FAIL,"",pp,attr,"Was not able to copy %s to %s\n",sourcefile,destfile); } return; } if (S_ISLNK(ssb.st_mode)) { LinkCopy(sourcefile,destfile,&ssb,attr,pp); } } else { VerifyCopiedFileAttributes(destfile,&dsb,&ssb,attr,pp); /* Now we have to check for single copy, even though nothing was copied otherwise we can get oscillations between multipe versions if type is based on a checksum */ if (IsInListOfRegex(SINGLE_COPY_LIST,destfile)) { IdempPrependRScalar(&SINGLE_COPY_CACHE,destfile,CF_SCALAR); } cfPS(cf_verbose,CF_NOP,"",pp,attr," -> File %s is an up to date copy of source\n",destfile); } } } /*********************************************************************/ int cfstat(const char *path, struct stat *buf) { #ifdef MINGW return NovaWin_stat(path, buf); #else return stat(path, buf); #endif } /*********************************************************************/ int cf_stat(char *file,struct stat *buf,struct Attributes attr,struct Promise *pp) { int res; if (attr.copy.servers == NULL || strcmp(attr.copy.servers->item,"localhost") == 0) { res = cfstat(file,buf); CheckForFileHoles(buf,pp); return res; } else { return cf_remote_stat(file,buf,"file",attr,pp); } } /*********************************************************************/ int cf_lstat(char *file,struct stat *buf,struct Attributes attr,struct Promise *pp) { int res; if (attr.copy.servers == NULL || strcmp(attr.copy.servers->item,"localhost") == 0) { res = lstat(file,buf); CheckForFileHoles(buf,pp); return res; } else { return cf_remote_stat(file,buf,"link",attr,pp); } } /*********************************************************************/ #ifndef MINGW int cf_readlink(char *sourcefile,char *linkbuf,int buffsize,struct Attributes attr,struct Promise *pp) /* wrapper for network access */ { struct cfstat *sp; memset(linkbuf,0,buffsize); if (attr.copy.servers == NULL || strcmp(attr.copy.servers->item,"localhost") == 0) { return readlink(sourcefile,linkbuf,buffsize-1); } for (sp = pp->cache; sp != NULL; sp=sp->next) { if ((strcmp(attr.copy.servers->item,sp->cf_server) == 0) && (strcmp(sourcefile,sp->cf_filename) == 0)) { if (sp->cf_readlink != NULL) { if (strlen(sp->cf_readlink)+1 > buffsize) { cfPS(cf_error,CF_FAIL,"",pp,attr,"readlink value is too large in cfreadlink\n"); CfOut(cf_error,"","Contained [%s]]n",sp->cf_readlink); return -1; } else { memset(linkbuf,0,buffsize); strcpy(linkbuf,sp->cf_readlink); return 0; } } } } return -1; } #endif /* NOT MINGW */ /*********************************************************************/ int CfReadLine(char *buff,int size,FILE *fp) { char ch; buff[0] = '\0'; buff[size - 1] = '\0'; /* mark end of buffer */ if (fgets(buff,size,fp) == NULL) { *buff = '\0'; /* EOF */ return false; } else { char *tmp; if ((tmp = strrchr(buff, '\n')) != NULL) { /* remove newline */ *tmp = '\0'; } else { /* The line was too long and truncated so, discard probable remainder */ while (true) { if (feof(fp)) { break; } ch = fgetc(fp); if (ch == '\n') { break; } } } } return true; } /*******************************************************************/ int FileSanityChecks(char *path,struct Attributes a,struct Promise *pp) { if (a.havelink && a.havecopy) { CfOut(cf_error,""," !! Promise constraint conflicts - %s file cannot both be a copy of and a link to the source",path); PromiseRef(cf_error,pp); return false; } if (a.havelink && !a.link.source) { CfOut(cf_error,""," !! Promise to establish a link at %s has no source",path); PromiseRef(cf_error,pp); return false; } /* We can't do this verification during parsing as we did not yet read the body, * so we can't distinguish between link and copy source. In post-verification * all bodies are already expanded, so we don't have the information either */ if (a.havecopy && a.copy.source && !FullTextMatch(CF_ABSPATHRANGE, a.copy.source)) { CfOut(cf_error,""," !! Non-absolute path in source attribute (have no invariant meaning): %s",path); PromiseRef(cf_error,pp); FatalError(""); } if (a.haveeditline && a.haveeditxml) { CfOut(cf_error,""," !! Promise constraint conflicts - %s editing file as both line and xml makes no sense",path); PromiseRef(cf_error,pp); return false; } if (a.havedepthsearch && a.haveedit) { CfOut(cf_error,""," !! Recursive depth_searches are not compatible with general file editing",path); PromiseRef(cf_error,pp); return false; } if (a.havedelete && (a.create||a.havecopy||a.haveedit||a.haverename)) { CfOut(cf_error,""," !! Promise constraint conflicts - %s cannot be deleted and exist at the same time",path); PromiseRef(cf_error,pp); return false; } if (a.haverename && (a.create||a.havecopy||a.haveedit)) { CfOut(cf_error,""," !! Promise constraint conflicts - %s cannot be renamed/moved and exist there at the same time",path); PromiseRef(cf_error,pp); return false; } if (a.havedelete && a.havedepthsearch && !a.haveselect) { CfOut(cf_error,""," !! Dangerous or ambiguous promise - %s specifies recursive deletion but has no file selection criteria",path); PromiseRef(cf_error,pp); return false; } if (a.haveselect && !a.select.result) { CfOut(cf_error,""," !! File select constraint body promised no result (check body definition)"); PromiseRef(cf_error,pp); return false; } if (a.havedelete && a.haverename) { CfOut(cf_error,""," !! File %s cannot promise both deletion and renaming",path); PromiseRef(cf_error,pp); return false; } if (a.havecopy && a.havedepthsearch && a.havedelete) { CfOut(cf_inform,""," !! Warning: depth_search of %s applies to both delete and copy, but these refer to different searches (source/destination)",pp->promiser); PromiseRef(cf_inform,pp); } if (a.transaction.background && a.transaction.audit) { CfOut(cf_error,""," !! Auditing cannot be performed on backgrounded promises (this might change).",pp->promiser); PromiseRef(cf_error,pp); return false; } if ((a.havecopy || a.havelink) && a.transformer) { CfOut(cf_error,""," !! File object(s) %s cannot both be a copy of source and transformed simultaneously",pp->promiser); PromiseRef(cf_error,pp); return false; } if (a.haveselect && a.select.result == NULL) { CfOut(cf_error,""," !! Missing file_result attribute in file_select body",pp->promiser); PromiseRef(cf_error,pp); return false; } if (a.havedepthsearch && a.change.report_diffs) { CfOut(cf_error,""," !! Difference reporting is not allowed during a depth_search",pp->promiser); PromiseRef(cf_error,pp); return false; } return true; } /*********************************************************************/ static void LoadSetuid(struct Attributes a,struct Promise *pp) { struct Attributes b = {{0}}; char filename[CF_BUFSIZE]; b = a; b.edits.backup = cfa_nobackup; b.edits.maxfilesize = 1000000; snprintf(filename,CF_BUFSIZE,"%s/cfagent.%s.log",CFWORKDIR,VSYSNAME.nodename); MapName(filename); if (!LoadFileAsItemList(&VSETUIDLIST,filename,b,pp)) { CfOut(cf_verbose,"","Did not find any previous setuid log %s, creating a new one",filename); } } /*********************************************************************/ static void SaveSetuid(struct Attributes a,struct Promise *pp) { struct Attributes b = {{0}}; char filename[CF_BUFSIZE]; b = a; b.edits.backup = cfa_nobackup; b.edits.maxfilesize = 1000000; snprintf(filename,CF_BUFSIZE,"%s/cfagent.%s.log",CFWORKDIR,VSYSNAME.nodename); MapName(filename); PurgeItemList(&VSETUIDLIST,"SETUID/SETGID"); if (!CompareToFile(VSETUIDLIST,filename,a,pp)) { SaveItemListAsFile(VSETUIDLIST,filename,b,pp); } DeleteItemList(VSETUIDLIST); VSETUIDLIST = NULL; } /*********************************************************************/ /* Level 4 */ /*********************************************************************/ static int CompareForFileCopy(char *sourcefile,char *destfile,struct stat *ssb, struct stat *dsb,struct Attributes attr,struct Promise *pp) { int ok_to_copy; switch (attr.copy.compare) { case cfa_checksum: case cfa_hash: if (S_ISREG(dsb->st_mode) && S_ISREG(ssb->st_mode)) { ok_to_copy = CompareFileHashes(sourcefile,destfile,ssb,dsb,attr,pp); } else { CfOut(cf_verbose,"","Checksum comparison replaced by ctime: files not regular\n"); ok_to_copy = (dsb->st_ctime < ssb->st_ctime)||(dsb->st_mtime < ssb->st_mtime); } if (ok_to_copy) { CfOut(cf_verbose,""," !! Image file %s has a wrong digest/checksum (should be copy of %s)\n",destfile,sourcefile); return ok_to_copy; } break; case cfa_binary: if (S_ISREG(dsb->st_mode) && S_ISREG(ssb->st_mode)) { ok_to_copy = CompareBinaryFiles(sourcefile,destfile,ssb,dsb,attr,pp); } else { CfOut(cf_verbose,"","Byte comparison replaced by ctime: files not regular\n"); ok_to_copy = (dsb->st_ctime < ssb->st_ctime)||(dsb->st_mtime < ssb->st_mtime); } if (ok_to_copy) { CfOut(cf_verbose,""," !! Image file %s has a wrong binary checksum (should be copy of %s)\n",destfile,sourcefile); return ok_to_copy; } break; case cfa_mtime: ok_to_copy = (dsb->st_mtime < ssb->st_mtime); if (ok_to_copy) { CfOut(cf_verbose,""," !! Image file %s out of date (should be copy of %s)\n",destfile,sourcefile); return ok_to_copy; } break; case cfa_atime: ok_to_copy = (dsb->st_ctime < ssb->st_ctime)|| (dsb->st_mtime < ssb->st_mtime)|| CompareBinaryFiles(sourcefile,destfile,ssb,dsb,attr,pp); if (ok_to_copy) { CfOut(cf_verbose,""," !! Image file %s seems out of date (should be copy of %s)\n",destfile,sourcefile); return ok_to_copy; } break; default: ok_to_copy = (dsb->st_ctime < ssb->st_ctime)||(dsb->st_mtime < ssb->st_mtime); if (ok_to_copy) { CfOut(cf_verbose,""," !! Image file %s out of date (should be copy of %s)\n",destfile,sourcefile); return ok_to_copy; } break; } return false; } /*************************************************************************************/ void LinkCopy(char *sourcefile,char *destfile,struct stat *sb,struct Attributes attr, struct Promise *pp) /* Link the file to the source, instead of copying */ #ifdef MINGW { CfOut(cf_verbose, "", "Windows does not support symbolic links"); cfPS(cf_error,CF_FAIL,"",pp,attr,"Windows can't link \"%s\" to \"%s\"",sourcefile, destfile); } #else /* NOT MINGW */ { char linkbuf[CF_BUFSIZE]; const char *lastnode; int status = CF_UNKNOWN; struct stat dsb; linkbuf[0] = '\0'; if (S_ISLNK(sb->st_mode) && cf_readlink(sourcefile,linkbuf,CF_BUFSIZE,attr,pp) == -1) { cfPS(cf_error,CF_FAIL,"",pp,attr,"Can't readlink %s\n",sourcefile); return; } else if (S_ISLNK(sb->st_mode)) { CfOut(cf_verbose,"","Checking link from %s to %s\n",destfile,linkbuf); if (attr.copy.link_type == cfa_absolute && !IsAbsoluteFileName(linkbuf)) /* Not absolute path - must fix */ { char vbuff[CF_BUFSIZE]; strcpy(vbuff,sourcefile); ChopLastNode(vbuff); AddSlash(vbuff); strncat(vbuff,linkbuf,CF_BUFSIZE-1); strncpy(linkbuf,vbuff,CF_BUFSIZE-1); } } else { strcpy(linkbuf,sourcefile); } lastnode=ReadLastNode(sourcefile); if (MatchRlistItem(attr.copy.copy_links,lastnode)) { struct stat ssb; ExpandLinks(linkbuf,sourcefile,0); CfOut(cf_verbose,"","cfengine: link item in copy %s marked for copying from %s instead\n",sourcefile,linkbuf); cfstat(linkbuf,&ssb); CfCopyFile(linkbuf,destfile,ssb,attr,pp); return; } switch (attr.copy.link_type) { case cfa_symlink: if (*linkbuf == '.') { status = VerifyRelativeLink(destfile,linkbuf,attr,pp); } else { status = VerifyLink(destfile,linkbuf,attr,pp); } break; case cfa_relative: status = VerifyRelativeLink(destfile,linkbuf,attr,pp); break; case cfa_absolute: status = VerifyAbsoluteLink(destfile,linkbuf,attr,pp); break; case cfa_hardlink: status = VerifyHardLink(destfile,linkbuf,attr,pp); break; default: FatalError("LinkCopy software error"); return; } if (status == CF_CHG || status == CF_NOP) { if (lstat(destfile,&dsb) == -1) { CfOut(cf_error,"lstat","Can't lstat %s\n",destfile); } else { VerifyCopiedFileAttributes(destfile,&dsb,sb,attr,pp); } if (status == CF_CHG) { cfPS(cf_inform,status,"",pp,attr," -> Created link %s", destfile); } else if (status == CF_NOP) { cfPS(cf_inform,status,"",pp,attr," -> Link %s as promised", destfile); } else { cfPS(cf_inform,status,"",pp,attr," -> Unable to create link %s", destfile); } } } #endif /* NOT MINGW */ /*************************************************************************************/ int CopyRegularFile(char *source,char *dest,struct stat sstat,struct stat dstat,struct Attributes attr,struct Promise *pp) { char backup[CF_BUFSIZE]; char new[CF_BUFSIZE], *linkable; struct cfagent_connection *conn = pp->conn; int remote = false, backupisdir=false, backupok=false,discardbackup; struct stat s; #ifdef HAVE_UTIME_H struct utimbuf timebuf; #endif #ifdef DARWIN /* For later copy from new to dest */ char *rsrcbuf; int rsrcbytesr; /* read */ int rsrcbytesw; /* written */ int rsrcbytesl; /* to read */ int rsrcrd; int rsrcwd; /* Keep track of if a resrouce fork */ char * tmpstr; char * forkpointer; int rsrcfork = 0; #endif #ifdef WITH_SELINUX int selinux_enabled=0; /* need to keep track of security context of destination file (if any) */ security_context_t scontext=NULL; struct stat cur_dest; int dest_exists; selinux_enabled = (is_selinux_enabled()>0); #endif Debug("CopyRegularFile(%s,%s)\n",source,dest); discardbackup = (attr.copy.backup == cfa_nobackup || attr.copy.backup == cfa_repos_store); if (DONTDO) { CfOut(cf_error,"","Promise requires copy from %s to %s\n",source,dest); return false; } #ifdef WITH_SELINUX if (selinux_enabled) { dest_exists = cfstat(dest,&cur_dest); if (dest_exists == 0) { /* get current security context of destination file */ getfilecon(dest,&scontext); } else { /* use default security context when creating destination file */ matchpathcon(dest,0,&scontext); setfscreatecon(scontext); } } #endif /* Make an assoc array of inodes used to preserve hard links */ linkable = CompressedArrayValue(pp->inode_cache,sstat.st_ino); if (sstat.st_nlink > 1) /* Preserve hard links, if possible */ { if (CompressedArrayElementExists(pp->inode_cache,sstat.st_ino) && (strcmp(dest,linkable) != 0)) { unlink(dest); MakeHardLink(dest,linkable,attr,pp); return true; } } if (attr.copy.servers != NULL && strcmp(attr.copy.servers->item,"localhost") != 0) { Debug("This is a remote copy from server: %s\n",(char *)attr.copy.servers->item); remote = true; } #ifdef DARWIN if (strstr(dest, _PATH_RSRCFORKSPEC)) { rsrcfork = 1; tmpstr = malloc(CF_BUFSIZE); /* Drop _PATH_RSRCFORKSPEC */ strncpy(tmpstr, dest, CF_BUFSIZE); forkpointer = strstr(tmpstr, _PATH_RSRCFORKSPEC); *forkpointer = '\0'; strncpy(new,tmpstr,CF_BUFSIZE); free(tmpstr); } else { #endif strncpy(new,dest,CF_BUFSIZE); if (!JoinSuffix(new,CF_NEW)) { CfOut(cf_error,"","Unable to construct filename for copy"); return false; } #ifdef DARWIN } #endif if (remote) { if (conn->error) { return false; } if (attr.copy.encrypt) { if (!EncryptCopyRegularFileNet(source,new,sstat.st_size,attr,pp)) { return false; } } else { if (!CopyRegularFileNet(source,new,sstat.st_size,attr,pp)) { return false; } } } else { if (!CopyRegularFileDisk(source,new,attr,pp)) { return false; } if (attr.copy.stealth) { #ifdef HAVE_UTIME_H timebuf.actime = sstat.st_atime; timebuf.modtime = sstat.st_mtime; utime(source,&timebuf); #endif } } CfOut(cf_verbose,""," -> Copy of regular file succeeded %s to %s\n",source,new); backup[0] = '\0'; if (!discardbackup) { char stamp[CF_BUFSIZE]; time_t stampnow; Debug("Backup file %s\n",source); strncpy(backup,dest,CF_BUFSIZE); if (attr.copy.backup == cfa_timestamp) { stampnow = time((time_t *)NULL); snprintf(stamp,CF_BUFSIZE-1,"_%lu_%s", CFSTARTTIME, CanonifyName(cf_ctime(&stampnow))); if (!JoinSuffix(backup,stamp)) { return false; } } if (!JoinSuffix(backup,CF_SAVED)) { return false; } /* Now in case of multiple copies of same object, try to avoid overwriting original backup */ if (lstat(backup,&s) != -1) { if (S_ISDIR(s.st_mode)) /* if there is a dir in the way */ { backupisdir = true; PurgeLocalFiles(NULL,backup,attr,pp); rmdir(backup); } unlink(backup); } if (cf_rename(dest,backup) == -1) { /* ignore */ } backupok = (lstat(backup,&s) != -1); /* Did the cf_rename() succeed? NFS-safe */ } else { /* Mainly important if there is a dir in the way */ if (cfstat(dest,&s) != -1) { if (S_ISDIR(s.st_mode)) { PurgeLocalFiles(NULL,dest,attr,pp); rmdir(dest); } } } if (lstat(new,&dstat) == -1) { cfPS(cf_inform,CF_FAIL,"stat",pp,attr,"Can't stat new file %s - another agent has picked it up?\n",new); return false; } if (S_ISREG(dstat.st_mode) && dstat.st_size != sstat.st_size) { cfPS(cf_error,CF_FAIL,"",pp,attr," !! New file %s seems to have been corrupted in transit (dest %d and src %d), aborting!\n",new, (int) dstat.st_size, (int) sstat.st_size); if (backupok) { cf_rename(backup,dest); /* ignore failure of this call, as there is nothing more we can do */ } return false; } if (attr.copy.verify) { CfOut(cf_verbose,""," ?? Final verification of transmission ...\n"); if (CompareFileHashes(source,new,&sstat,&dstat,attr,pp)) { cfPS(cf_verbose,CF_FAIL,"",pp,attr," !! New file %s seems to have been corrupted in transit, aborting!\n",new); if (backupok) { cf_rename(backup,dest); } return false; } else { CfOut(cf_verbose,""," -> New file %s transmitted correctly - verified\n",new); } } #ifdef DARWIN if (rsrcfork) { /* Can't just "mv" the resource fork, unfortunately */ rsrcrd = open(new, O_RDONLY|O_BINARY); rsrcwd = open(dest, O_WRONLY|O_BINARY|O_CREAT|O_TRUNC, 0600); if (rsrcrd == -1 || rsrcwd == -1) { CfOut(cf_inform,"open", "Open of Darwin resource fork rsrcrd/rsrcwd failed\n"); close(rsrcrd); close(rsrcwd); return(false); } rsrcbuf = malloc(CF_BUFSIZE); rsrcbytesr = 0; while(1) { rsrcbytesr = read(rsrcrd, rsrcbuf, CF_BUFSIZE); if (rsrcbytesr == -1) { /* Ck error */ if (errno == EINTR) { continue; } else { CfOut(cf_inform,"read", "Read of Darwin resource fork rsrcrd failed\n"); close(rsrcrd); close(rsrcwd); free(rsrcbuf); return(false); } } else if (rsrcbytesr == 0) { /* Reached EOF */ close(rsrcrd); close(rsrcwd); free(rsrcbuf); unlink(new); /* Go ahead and unlink .cfnew */ break; } rsrcbytesl = rsrcbytesr; rsrcbytesw = 0; while (rsrcbytesl > 0) { rsrcbytesw += write(rsrcwd, rsrcbuf, rsrcbytesl); if (rsrcbytesw == -1) { if (errno == EINTR) { continue; } else { CfOut(cf_inform,"write", "Write of Darwin resource fork rsrcwd failed\n"); close(rsrcrd); close(rsrcwd); free(rsrcbuf); return(false); } } rsrcbytesl = rsrcbytesr - rsrcbytesw; } } } else { #endif if (cf_rename(new,dest) == -1) { cfPS(cf_error,CF_FAIL,"cf_rename",pp,attr," !! Could not install copy file as %s, directory in the way?\n",dest); if (backupok) { cf_rename(backup,dest); /* ignore failure */ } return false; } #ifdef DARWIN } #endif if (!discardbackup && backupisdir) { CfOut(cf_inform,"","Cannot move a directory to repository, leaving at %s",backup); } else if (!discardbackup && ArchiveToRepository(backup,attr,pp)) { unlink(backup); } if (attr.copy.stealth) { #ifdef HAVE_UTIME_H timebuf.actime = sstat.st_atime; timebuf.modtime = sstat.st_mtime; utime(dest,&timebuf); #endif } #ifdef WITH_SELINUX if (selinux_enabled) { if (dest_exists == 0) { /* set dest context to whatever it was before copy */ setfilecon(dest,scontext); } else { /* set create context back to default */ setfscreatecon(NULL); } freecon(scontext); } #endif return true; } /*********************************************************************/ static void FileAutoDefine(char *destfile) { char class[CF_MAXVARSIZE]; snprintf(class,CF_MAXVARSIZE,"auto_%s",CanonifyName(destfile)); NewClass(class); CfOut(cf_inform,"","Auto defining class %s\n",class); } /*********************************************************************/ /* Level 3 */ /*********************************************************************/ static void RegisterAHardLink(int i,char *value,struct Attributes attr,struct Promise *pp) { if (!FixCompressedArrayValue(i,value,&(pp->inode_cache))) { /* Not root hard link, remove to preserve consistency */ if (DONTDO) { CfOut(cf_verbose,""," !! Need to remove old hard link %s to preserve structure..\n",value); } else { if (attr.transaction.action == cfa_warn) { CfOut(cf_verbose,""," !! Need to remove old hard link %s to preserve structure..\n",value); } else { CfOut(cf_verbose,""," -> Removing old hard link %s to preserve structure..\n",value); unlink(value); } } } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/keyring.c������������������������������������������������������������������������0000644�0001750�0001750�00000016124�11715232734�012633� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*****************************************************************************/ /* */ /* File: keyring.c */ /* */ /* Created: Sun May 29 13:35:34 2011 */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" /***************************************************************/ int HostKeyAddressUnknown(char *value) { if (strcmp(value,CF_UNKNOWN_IP) == 0) { return true; } // Is there some other non-ip string left over? if (!(strchr(value,'.') || strchr(value,':'))) { return false; } return false; } /***************************************************************/ /* deprecated code */ /***************************************************************/ #ifdef NOT_DEFINED // This version is deprecated, but saved for future reference void LastSaw(char *username,char *ipaddress,unsigned char digest[EVP_MAX_MD_SIZE+1],enum roles role) { char databuf[CF_BUFSIZE]; time_t now = time(NULL); int known = false; struct Rlist *rp; struct CfKeyBinding *kp; if (strlen(ipaddress) == 0) { CfOut(cf_inform,"","LastSeen registry for empty IP with role %d",role); return; } ThreadLock(cft_output); switch (role) { case cf_accept: snprintf(databuf,CF_BUFSIZE-1,"-%s",HashPrint(CF_DEFAULT_DIGEST,digest)); break; case cf_connect: snprintf(databuf,CF_BUFSIZE-1,"+%s",HashPrint(CF_DEFAULT_DIGEST,digest)); break; } ThreadUnlock(cft_output); ThreadLock(cft_server_keyseen); for (rp = SERVER_KEYSEEN; rp != NULL; rp=rp->next) { kp = (struct CfKeyBinding *) rp->item; if (strcmp(kp->name,databuf) == 0) { known = true; kp->timestamp = now; CfOut(cf_verbose,""," -> Last saw %s (%s) now",ipaddress,databuf); // Refresh address ThreadLock(cft_system); if (kp->address) { free(kp->address); } kp->address = strdup(ipaddress); ThreadUnlock(cft_system); ThreadUnlock(cft_server_keyseen); return; } } CfOut(cf_verbose,""," -> Last saw %s (%s) first time now",ipaddress,databuf); ThreadLock(cft_system); kp = (struct CfKeyBinding *)malloc((sizeof(struct CfKeyBinding))); ThreadUnlock(cft_system); if (kp == NULL) { ThreadUnlock(cft_server_keyseen); return; } rp = PrependRlist(&SERVER_KEYSEEN,"nothing",CF_SCALAR); ThreadLock(cft_system); free(rp->item); rp->item = kp; kp->address = strdup(ipaddress); if ((kp->name = strdup(databuf)) == NULL) { free(kp); ThreadUnlock(cft_system); ThreadUnlock(cft_server_keyseen); return; } ThreadUnlock(cft_system); kp->key = HavePublicKey(username,ipaddress,databuf+1); kp->timestamp = now; ThreadUnlock(cft_server_keyseen); } /***************************************************************/ void UpdateLastSeen() // This function is temporarily or permanently deprecated { double lsea = LASTSEENEXPIREAFTER; int intermittency = false,qsize,ksize; struct CfKeyHostSeen q,newq; double lastseen,delta2; void *stored; CF_DB *dbp = NULL,*dbpent = NULL; CF_DBC *dbcp; char name[CF_BUFSIZE],*key; struct Rlist *rp; struct CfKeyBinding *kp; time_t now = time(NULL); static time_t then; if (now < then + 300 && then > 0 && then <= now + 300) { // Rate limiter return; } then = now; CfOut(cf_verbose,""," -> Writing last-seen observations"); ThreadLock(cft_server_keyseen); if (SERVER_KEYSEEN == NULL) { ThreadUnlock(cft_server_keyseen); CfOut(cf_verbose,""," -> Keyring is empty"); return; } if (BooleanControl("control_agent",CFA_CONTROLBODY[cfa_intermittency].lval)) { CfOut(cf_inform,""," -> Recording intermittency"); intermittency = true; } snprintf(name,CF_BUFSIZE-1,"%s/%s",CFWORKDIR,CF_LASTDB_FILE); MapName(name); if (!OpenDB(name,&dbp)) { ThreadUnlock(cft_server_keyseen); return; } /* First scan for hosts that have moved address and purge their records so that the database always has a 1:1 relationship between keyhash and IP address */ if (!NewDBCursor(dbp,&dbcp)) { ThreadUnlock(cft_server_keyseen); CfOut(cf_inform,""," !! Unable to scan class db"); return; } while(NextDB(dbp,dbcp,&key,&ksize,&stored,&qsize)) { memcpy(&q,stored,sizeof(q)); lastseen = (double)now - q.Q.q; if (lastseen > lsea) { CfOut(cf_verbose,""," -> Last-seen record for %s expired after %.1lf > %.1lf hours\n",key,lastseen/3600,lsea/3600); DeleteDB(dbp,key); } for (rp = SERVER_KEYSEEN; rp != NULL; rp=rp->next) { kp = (struct CfKeyBinding *) rp->item; if ((strcmp(q.address,kp->address) == 0) && (strcmp(key+1,kp->name+1) != 0)) { CfOut(cf_verbose,""," ! Deleting %s's address (%s=%d) as this host %s seems to have moved elsewhere (%s=5d)",key,kp->address,strlen(kp->address),kp->name,q.address,strlen(q.address)); DeleteDB(dbp,key); } } } DeleteDBCursor(dbp,dbcp); /* Now perform updates with the latest data */ for (rp = SERVER_KEYSEEN; rp != NULL; rp=rp->next) { kp = (struct CfKeyBinding *) rp->item; now = kp->timestamp; if (intermittency) { /* Open special file for peer entropy record - INRIA intermittency */ snprintf(name,CF_BUFSIZE-1,"%s/lastseen/%s.%s",CFWORKDIR,CF_LASTDB_FILE,kp->name); MapName(name); if (!OpenDB(name,&dbpent)) { continue; } } if (ReadDB(dbp,kp->name,&q,sizeof(q))) { lastseen = (double)now - q.Q.q; if (q.Q.q <= 0) { lastseen = 300; q.Q.expect = 0; q.Q.var = 0; } newq.Q.q = (double)now; newq.Q.expect = GAverage(lastseen,q.Q.expect,0.4); delta2 = (lastseen - q.Q.expect)*(lastseen - q.Q.expect); newq.Q.var = GAverage(delta2,q.Q.var,0.4); strncpy(newq.address,kp->address,CF_ADDRSIZE-1); } else { lastseen = 0.0; newq.Q.q = (double)now; newq.Q.expect = 0.0; newq.Q.var = 0.0; strncpy(newq.address,kp->address,CF_ADDRSIZE-1); } if (lastseen > lsea) { CfOut(cf_verbose,""," -> Last-seen record for %s expired after %.1lf > %.1lf hours\n",kp->name,lastseen/3600,lsea/3600); DeleteDB(dbp,kp->name); } else { char timebuf[26]; CfOut(cf_verbose,""," -> Last saw %s (alias %s) at %s (noexpiry %.1lf <= %.1lf)\n",kp->name,kp->address,cf_strtimestamp_local(now,timebuf),lastseen/3600,lsea/3600); WriteDB(dbp,kp->name,&newq,sizeof(newq)); if (intermittency) { WriteDB(dbpent,GenTimeKey(now),&newq,sizeof(newq)); } } if (intermittency && dbpent) { CloseDB(dbpent); } } ThreadUnlock(cft_server_keyseen); } #endif ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/verify_processes.c���������������������������������������������������������������0000644�0001750�0001750�00000030345�11715232734�014556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: verify_processes.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" static int ExecPackageCommand(char *command,int verify,int setCmdClasses,struct Attributes a,struct Promise *pp); static int ProcessSanityChecks(struct Attributes a,struct Promise *pp); static void VerifyProcessOp(struct Item *procdata,struct Attributes a,struct Promise *pp); static int FindPidMatches(struct Item *procdata,struct Item **killlist,struct Attributes a,struct Promise *pp); static int ExtractPid(char *psentry,char **names,int *start,int *end); /*****************************************************************************/ void VerifyProcessesPromise(struct Promise *pp) { struct Attributes a = {{0}}; a = GetProcessAttributes(pp); ProcessSanityChecks(a,pp); VerifyProcesses(a,pp); } /*****************************************************************************/ /* Level */ /*****************************************************************************/ static int ProcessSanityChecks(struct Attributes a,struct Promise *pp) { int promised_zero, promised_any, ret = true; if (a.signals != NULL && a.process_stop != NULL) { CfOut(cf_error,"","Promise constraint conflicts - %s processes cannot be signalled if they are stopped",pp->promiser); PromiseRef(cf_error,pp); ret = false; } promised_zero = (a.process_count.min_range == 0 && a.process_count.max_range == 0); promised_any = (a.process_count.min_range == CF_NOINT); if (a.restart_class) { if (IsStringIn(a.signals,"term") || IsStringIn(a.signals,"kill")) { CfOut(cf_inform,""," -> (warning) Promise %s kills then restarts - never strictly converges",pp->promiser); PromiseRef(cf_inform,pp); } if (a.haveprocess_count) { CfOut(cf_error,""," !! process_count and restart_class should not be used in the same promise as this makes no sense",pp->promiser); PromiseRef(cf_inform,pp); ret = false; } } if (promised_zero && a.restart_class) { CfOut(cf_error,"","Promise constraint conflicts - %s processes cannot have zero count if restarted",pp->promiser); PromiseRef(cf_error,pp); ret = false; } if (a.haveselect && !a.process_select.process_result) { CfOut(cf_error,""," !! Process select constraint body promised no result (check body definition)"); PromiseRef(cf_error,pp); return false; } return ret; } /*****************************************************************************/ void VerifyProcesses(struct Attributes a, struct Promise *pp) { struct CfLock thislock; char lockname[CF_BUFSIZE]; if (a.restart_class) { snprintf(lockname,CF_BUFSIZE-1,"proc-%s-%s",pp->promiser,a.restart_class); } else { snprintf(lockname,CF_BUFSIZE-1,"proc-%s-norestart",pp->promiser); } thislock = AcquireLock(lockname,VUQNAME,CFSTARTTIME,a,pp,false); if (thislock.lock == NULL) { return; } DeleteScalar("this","promiser"); NewScalar("this","promiser",pp->promiser,cf_str); PromiseBanner(pp); VerifyProcessOp(PROCESSTABLE,a,pp); DeleteScalar("this","promiser"); YieldCurrentLock(thislock); } /*******************************************************************/ int LoadProcessTable(struct Item **procdata) { if (PROCESSTABLE) { CfOut(cf_verbose,""," -> Reusing cached process state"); return true; } #ifdef MINGW return NovaWin_LoadProcessTable(procdata); #else return Unix_LoadProcessTable(procdata); #endif } /*******************************************************************/ static void VerifyProcessOp(struct Item *procdata,struct Attributes a,struct Promise *pp) { int matches = 0,do_signals = true,out_of_range,killed = 0,need_to_restart = true; struct Item *killlist = NULL; Debug("VerifyProcessOp\n"); matches = FindPidMatches(procdata,&killlist,a,pp); /* promise based on number of matches */ if (a.process_count.min_range != CF_NOINT) /* if a range is specified */ { if (matches < a.process_count.min_range || matches > a.process_count.max_range) { cfPS(cf_error,CF_CHG,"",pp,a," !! Process count for \'%s\' was out of promised range (%d found)\n",pp->promiser,matches); AddEphemeralClasses(a.process_count.out_of_range_define); out_of_range = true; } else { AddEphemeralClasses(a.process_count.in_range_define); cfPS(cf_verbose,CF_NOP,"",pp,a," -> Process promise for %s is kept",pp->promiser); out_of_range = false; } } else { out_of_range = true; } if (!out_of_range) { return; } if (a.transaction.action == cfa_warn) { do_signals = false; } else { do_signals = true; } /* signal/kill promises for existing matches */ if (do_signals && matches > 0) { if (a.process_stop != NULL) { if (DONTDO) { cfPS(cf_error,CF_WARN,"",pp,a," -- Need to keep process-stop promise for %s, but only a warning is promised",pp->promiser); } else { if (IsExecutable(GetArg0(a.process_stop))) { ShellCommandReturnsZero(a.process_stop,false); } else { cfPS(cf_verbose,CF_FAIL,"",pp,a,"Process promise to stop %s could not be kept because %s the stop operator failed",pp->promiser,a.process_stop); DeleteItemList(killlist); return; } } } else { killed = DoAllSignals(killlist,a,pp); } } /* delegated promise to restart killed or non-existent entries */ need_to_restart = (a.restart_class != NULL) && (killed || matches == 0); DeleteItemList(killlist); if (!need_to_restart) { cfPS(cf_verbose,CF_NOP,"",pp,a," -> No restart promised for %s\n",pp->promiser); return; } else { if (a.transaction.action == cfa_warn) { cfPS(cf_error,CF_WARN,"",pp,a," -- Need to keep restart promise for %s, but only a warning is promised",pp->promiser); } else { cfPS(cf_inform,CF_CHG,"",pp,a," -> Making a one-time restart promise for %s",pp->promiser); NewClass(a.restart_class); } } } /**********************************************************************************/ static int FindPidMatches(struct Item *procdata,struct Item **killlist,struct Attributes a,struct Promise *pp) { struct Item *ip; char saveuid[16]; int pid=-1,matches=0,i,s,e,promised_zero; pid_t cfengine_pid = getpid(); char *names[CF_PROCCOLS]; /* ps headers */ int start[CF_PROCCOLS]; int end[CF_PROCCOLS]; if (procdata == NULL) { return 0; } GetProcessColumnNames(procdata->name,(char **)names,start,end); for (ip = procdata->next; ip != NULL; ip=ip->next) { CF_OCCUR++; if (BlockTextMatch(pp->promiser,ip->name,&s,&e)) { if (EMPTY(ip->name)) { continue; } if (!SelectProcess(ip->name,names,start,end,a,pp)) { continue; } pid = ExtractPid(ip->name,names,start,end); if (pid == -1) { CfOut(cf_verbose,"","Unable to extract pid while looking for %s\n",pp->promiser); continue; } CfOut(cf_verbose,""," -> Found matching pid %d\n (%s)",pid,ip->name); matches++; if (pid == 1) { if ((RlistLen(a.signals) == 1) && IsStringIn(a.signals,"hup")) { CfOut(cf_verbose,"","(Okay to send only HUP to init)\n"); } else { continue; } } if (pid < 4 && a.signals) { CfOut(cf_verbose,"","Will not signal or restart processes 0,1,2,3 (occurred while looking for %s)\n",pp->promiser); continue; } promised_zero = a.process_count.min_range == 0 && a.process_count.max_range == 0; if (a.transaction.action == cfa_warn && promised_zero) { CfOut(cf_error,"","Process alert: %s\n",procdata->name); /* legend */ CfOut(cf_error,"","Process alert: %s\n",ip->name); continue; } if (pid == cfengine_pid && a.signals) { CfOut(cf_verbose,""," !! cf-agent will not signal itself!\n"); continue; } PrependItem(killlist,ip->name,""); (*killlist)->counter = pid; } } // Free up allocated memory for (i = 0; i < CF_PROCCOLS; i++) { if (names[i] != NULL) { free(names[i]); } } return matches; } /**********************************************************************************/ int DoAllSignals(struct Item *siglist,struct Attributes a,struct Promise *pp) { #ifdef MINGW return NovaWin_DoAllSignals(siglist,a,pp); #else return Unix_DoAllSignals(siglist,a,pp); #endif } /**********************************************************************************/ /* Level */ /**********************************************************************************/ static int ExtractPid(char *psentry,char **names,int *start,int *end) { char *sp; int col,pid = -1,offset = 0; for (col = 0; col < CF_PROCCOLS; col++) { if (strcmp(names[col],"PID") == 0) { if (col > 0) { offset=end[col-1]; } break; } } for (sp = psentry+offset; *sp != '\0'; sp++) /* if first field contains alpha, skip */ { /* If start with alphanum then skip it till the first space */ if (isalnum((int)*sp)) { while ((*sp != ' ') && (*sp != '\0')) { sp++; } } while ((*sp == ' ') && (*sp == '\t')) { sp++; } sscanf(sp,"%d",&pid); if (pid != -1) { break; } } return pid; } /**********************************************************************************/ void GetProcessColumnNames(char *proc,char **names,int *start,int *end) { char *sp,title[16]; int col,offset = 0; for (col = 0; col < CF_PROCCOLS; col++) { start[col] = end[col] = -1; names[col] = NULL; } col = 0; for (sp = proc; *sp != '\0'; sp++) { offset = sp - proc; if (isspace((int)*sp)) { if (start[col] != -1) { Debug("End of %s is %d\n",title,offset-1); end[col++] = offset - 1; if (col > CF_PROCCOLS - 1) { CfOut(cf_error,"","Column overflow in process table"); break; } } continue; } else if (start[col] == -1) { start[col] = offset; sscanf(sp,"%15s",title); Debug("Start of %s is %d\n",title,offset); names[col] = strdup(title); Debug("Col[%d]=%s\n",col,names[col]); } } if (end[col] == -1) { Debug("End of %s is %d\n",title,offset); end[col] = offset; } } /**********************************************************************************/ int GracefulTerminate(pid_t pid) { #ifdef MINGW return NovaWin_GracefulTerminate(pid); #else return Unix_GracefulTerminate(pid); #endif } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/mod_services.c�������������������������������������������������������������������0000644�0001750�0001750�00000005601�11715232734�013643� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: mod_services.c */ /* */ /* Created: Fri Dec 4 09:36:59 2009 */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #define CF3_MOD_SERVICES struct BodySyntax CF_SERVMETHOD_BODY[] = { {"service_type",cf_opts,"windows,init,inetd,xinetd","Service abstraction type"}, {"service_args",cf_str,"","Parameters for starting the service"}, {"service_autostart_policy",cf_opts,"none,boot_time,on_demand","Should the service be started automatically by the OS"}, {"service_dependence_chain",cf_opts,"ignore,start_parent_services,stop_child_services,all_related","How to handle dependencies and dependent services"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ struct BodySyntax CF_SERVICES_BODIES[] = { {"service_policy",cf_opts,"start,stop,disable","Policy for cfengine service status"}, {"service_dependencies",cf_slist,CF_IDRANGE,"A list of services on which the named service abstraction depends"}, {"service_method",cf_body,CF_SERVMETHOD_BODY,"Details of promise body for the service abtraction feature"}, {NULL,cf_notype,NULL,NULL} }; /***************************************************************/ /* This is the point of entry from mod_common.c */ /***************************************************************/ struct SubTypeSyntax CF_SERVICES_SUBTYPES[] = { {"agent","services",CF_SERVICES_BODIES}, {NULL,NULL,NULL}, }; �������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/dbm_quick.c����������������������������������������������������������������������0000644�0001750�0001750�00000015463�11715232734�013126� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: dbm_quick.c */ /* */ /*****************************************************************************/ /* * Implementation of the Cfengine DBM API using Quick Database Manager. */ #include "cf3.defs.h" #include "cf3.extern.h" #ifdef QDB int QDB_OpenDB(char *filename, CF_QDB **qdbp) { ThreadLock(cft_system); *qdbp = malloc(sizeof(CF_QDB)); if(*qdbp == NULL) { FatalError("Memory allocation in QDB_OpenDB()"); } (*qdbp)->depot = dpopen(filename, DP_OWRITER | DP_OCREAT, -1); if(((*qdbp)->depot == NULL) && (dpecode == DP_EBROKEN)) { CfOut(cf_error, "", "!! Database \"%s\" is broken, trying to repair...", filename); if(dprepair(filename)) { CfOut(cf_log, "", "Successfully repaired database \"%s\"", filename); } (*qdbp)->depot = dpopen(filename, DP_OWRITER | DP_OCREAT, -1); } if((*qdbp)->depot == NULL) { CfOut(cf_error, "", "!! dpopen: Opening database \"%s\" failed: %s", filename, dperrmsg(dpecode)); free(*qdbp); *qdbp = NULL; ThreadUnlock(cft_system); return false; } (*qdbp)->valmemp = NULL; ThreadUnlock(cft_system); return true; } /*****************************************************************************/ int QDB_CloseDB(CF_QDB *qdbp) { int res; char *dbName = NULL; char buf[CF_MAXVARSIZE]; dbName = dpname(qdbp->depot); snprintf(buf, sizeof(buf), "CloseDB(%s)\n", dbName); Debug(buf); ThreadLock(cft_system); free(dbName); if(qdbp->valmemp != NULL) { free(qdbp->valmemp); qdbp->valmemp = NULL; } res = dpclose(qdbp->depot); free(qdbp); qdbp = NULL; ThreadUnlock(cft_system); return res; } /*****************************************************************************/ int QDB_ValueSizeDB(CF_QDB *qdbp, char *key) { return dpvsiz(qdbp->depot, key, -1); } /*****************************************************************************/ int QDB_ReadComplexKeyDB(CF_QDB *qdbp, char *key, int keySz,void *dest, int destSz) { int bytesRead; bytesRead = dpgetwb(qdbp->depot, key, keySz, 0, destSz, dest); if(bytesRead == -1) { Debug("QDB_ReadComplexKeyDB(%s): Could not read: %s\n", key, dperrmsg(dpecode)); return false; } return true; } /*****************************************************************************/ int QDB_RevealDB(CF_QDB *qdbp, char *key, void **result, int *rsize) { ThreadLock(cft_system); if(qdbp->valmemp != NULL) { free(qdbp->valmemp); qdbp->valmemp = NULL; } ThreadUnlock(cft_system); *result = dpget(qdbp->depot, key, -1, 0, -1, rsize); if(*result == NULL) { Debug("QDB_RevealDB(%s): Could not read: %s\n", key, dperrmsg(dpecode)); return false; } qdbp->valmemp = *result; // save mem-pointer for later free return true; } /*****************************************************************************/ int QDB_WriteComplexKeyDB(CF_QDB *qdbp, char *key, int keySz, const void *src, int srcSz) { char *dbName = NULL; if(!dpput(qdbp->depot, key, keySz, src, srcSz, DP_DOVER)) { dbName = dpname(qdbp->depot); CfOut(cf_error, "", "!! dpput: Could not write key to DB \"%s\": %s", dbName, dperrmsg(dpecode)); free(dbName); return false; } return true; } /*****************************************************************************/ int QDB_DeleteComplexKeyDB(CF_QDB *qdbp, char *key, int size) { if(!dpout(qdbp->depot, key, size)) { return false; } return true; } /*****************************************************************************/ int QDB_NewDBCursor(CF_QDB *qdbp,CF_QDBC **qdbcp) { Debug("Entering QDB_NewDBCursor()\n"); if(!dpiterinit(qdbp->depot)) { CfOut(cf_error, "", "!! dpiterinit: Could not initialize iterator: %s", dperrmsg(dpecode)); return false; } ThreadLock(cft_system); *qdbcp = malloc(sizeof(CF_QDBC)); ThreadUnlock(cft_system); if(*qdbcp == NULL) { FatalError("Memory allocation in QDB_NewDBCursor"); } (*qdbcp)->curkey = NULL; (*qdbcp)->curval = NULL; return true; } /*****************************************************************************/ int QDB_NextDB(CF_QDB *qdbp,CF_QDBC *qdbcp,char **key,int *ksize,void **value,int *vsize) { Debug("Entering QDB_NextDB()\n"); ThreadLock(cft_system); if(qdbcp->curkey != NULL) { free(qdbcp->curkey); qdbcp->curkey = NULL; } if(qdbcp->curval != NULL) { free(qdbcp->curval); qdbcp->curval = NULL; } *key = dpiternext(qdbp->depot, ksize); if(*key == NULL) { ThreadUnlock(cft_system); Debug("Got NULL-key in QDB_NextDB(): %s\n", dperrmsg(dpecode)); return false; } *value = dpget(qdbp->depot, *key, *ksize, 0, -1, vsize); if(*value == NULL) { CfOut(cf_error, "", "!! Got NULL-value in QDB_NextDB() for key %s: %s\n", *key, dperrmsg(dpecode)); free(*key); *key = NULL; ThreadUnlock(cft_system); return false; } // keep pointers for later free qdbcp->curkey = *key; qdbcp->curval = *value; ThreadUnlock(cft_system); return true; } /*****************************************************************************/ int QDB_DeleteDBCursor(CF_QDB *qdbp,CF_QDBC *qdbcp) { Debug("Entering QDB_DeleteDBCursor()\n"); ThreadLock(cft_system); if(qdbcp->curkey != NULL) { free(qdbcp->curkey); qdbcp->curkey = NULL; } if(qdbcp->curval != NULL) { free(qdbcp->curval); qdbcp->curval = NULL; } free(qdbcp); ThreadUnlock(cft_system); return true; } #endif �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/generic_agent.c������������������������������������������������������������������0000644�0001750�0001750�00000142275�11715232734�013764� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ /* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: generic_agent.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" extern FILE *yyin; extern char *CFH[][2]; static void VerifyPromises(enum cfagenttype ag); static void SetAuditVersion(void); static void CheckWorkingDirectories(void); static void Cf3ParseFile(char *filename); static void Cf3ParseFiles(void); static int MissingInputFile(void); static void UnHashVariables(void); static void CheckControlPromises(char *scope,char *agent,struct Constraint *controllist); static void CheckVariablePromises(char *scope,struct Promise *varlist); static void CheckCommonClassPromises(struct Promise *classlist); static void PrependAuditFile(char *file); static void OpenReports(char *agents); static void CloseReports(char *agents); static char *InputLocation(char *filename); extern void CheckOpts(int argc,char **argv); static void Cf3OpenLog(int facility); static bool VerifyBundleSequence(enum cfagenttype agent); /*****************************************************************************/ static void SanitizeEnvironment() { /* ps(1) and other utilities invoked by Cfengine may be affected */ unsetenv("COLUMNS"); /* Make sure subprocesses output is not localized */ unsetenv("LANG"); unsetenv("LANGUAGE"); unsetenv("LC_MESSAGES"); } /*****************************************************************************/ void GenericInitialize(int argc,char **argv,char *agents) { enum cfagenttype ag = Agent2Type(agents); char vbuff[CF_BUFSIZE]; int ok = false; #ifdef HAVE_NOVA CF_DEFAULT_DIGEST = cf_sha256; CF_DEFAULT_DIGEST_LEN = CF_SHA256_LEN; #else CF_DEFAULT_DIGEST = cf_md5; CF_DEFAULT_DIGEST_LEN = CF_MD5_LEN; #endif InitializeGA(argc,argv); SetReferenceTime(true); SetStartTime(false); SetSignals(); SanitizeEnvironment(); strcpy(THIS_AGENT,CF_AGENTTYPES[ag]); NewClass(THIS_AGENT); THIS_AGENT_TYPE = ag; // need scope sys to set vars in expiry function SetNewScope("sys"); if (EnterpriseExpiry()) { CfOut(cf_error,"","Cfengine - autonomous configuration engine. This enterprise license is invalid.\n"); exit(1); } if (AM_NOVA) { CfOut(cf_verbose,""," -> This is CFE Nova\n"); } if (AM_CONSTELLATION) { CfOut(cf_verbose,""," -> This is CFE Constellation\n"); } NewScope("const"); NewScope("match"); NewScope("mon"); GetNameInfo3(); CfGetInterfaceInfo(ag); if (ag != cf_know) { Get3Environment(); BuiltinClasses(); OSClasses(); } LoadPersistentContext(); LoadSystemConstants(); snprintf(vbuff,CF_BUFSIZE,"control_%s",THIS_AGENT); SetNewScope(vbuff); NewScope("this"); NewScope("match"); if (BOOTSTRAP) { CheckAutoBootstrap(); } else { if (strlen(POLICY_SERVER) > 0) { CfOut(cf_verbose,""," -> Found a policy server (hub) on %s",POLICY_SERVER); } else { CfOut(cf_verbose,""," -> No policy server (hub) watch yet registered"); } } SetPolicyServer(POLICY_SERVER); if (ag != cf_keygen) { if (!MissingInputFile()) { bool check_promises = false; if (SHOWREPORTS) { check_promises = true; CfOut(cf_verbose, "", " -> Reports mode is enabled, force-validating policy"); } if (IsFileOutsideDefaultRepository(VINPUTFILE)) { check_promises = true; CfOut(cf_verbose, "", " -> Input file is outside default repository, validating it"); } if (NewPromiseProposals()) { check_promises = true; CfOut(cf_verbose, "", " -> Input file is changed since last validation, validating it"); } if (check_promises) { ok = CheckPromises(ag); if (BOOTSTRAP && !ok) { CfOut(cf_verbose, "", " -> Policy is not valid, but proceeding with bootstrap"); ok = true; } } else { CfOut(cf_verbose, "", " -> Policy is already validated"); ok = true; } } if (ok) { ReadPromises(ag,agents); } else { CfOut(cf_error,"","cf-agent was not able to get confirmation of promises from cf-promises, so going to failsafe\n"); snprintf(VINPUTFILE,CF_BUFSIZE-1,"failsafe.cf"); ReadPromises(ag,agents); } if (SHOWREPORTS) { CompilationReport(VINPUTFILE); } CheckLicenses(); } XML = 0; } /*****************************************************************************/ void GenericDeInitialize() { Debug("GenericDeInitialize()\n"); CloseWmi(); CloseNetwork(); Cf3CloseLog(); CloseAllDB(); } /*****************************************************************************/ /* Level */ /*****************************************************************************/ int CheckPromises(enum cfagenttype ag) { char cmd[CF_BUFSIZE], cfpromises[CF_MAXVARSIZE]; char filename[CF_MAXVARSIZE]; struct stat sb; int fd; if ((ag != cf_agent) && (ag != cf_executor) && (ag != cf_server)) { return true; } CfOut(cf_verbose,""," -> Verifying the syntax of the inputs...\n"); snprintf(cfpromises,sizeof(cfpromises),"%s%cbin%ccf-promises%s",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR,EXEC_SUFFIX); if (cfstat(cfpromises,&sb) == -1) { CfOut(cf_error,"","cf-promises%s needs to be installed in %s%cbin for pre-validation of full configuration",EXEC_SUFFIX,CFWORKDIR,FILE_SEPARATOR); return false; } /* If we are cf-agent, check syntax before attempting to run */ snprintf(cmd, sizeof(cmd), "\"%s\" -f \"", cfpromises); if (IsFileOutsideDefaultRepository(VINPUTFILE)) { strlcat(cmd, VINPUTFILE, CF_BUFSIZE); } else { strlcat(cmd, CFWORKDIR, CF_BUFSIZE); strlcat(cmd, FILE_SEPARATOR_STR "inputs" FILE_SEPARATOR_STR, CF_BUFSIZE); strlcat(cmd, VINPUTFILE, CF_BUFSIZE); } strlcat(cmd, "\"", CF_BUFSIZE); if (CBUNDLESEQUENCE) { strlcat(cmd, " -b \"", CF_BUFSIZE); strlcat(cmd, CBUNDLESEQUENCE_STR, CF_BUFSIZE); strlcat(cmd, "\"", CF_BUFSIZE); } if(BOOTSTRAP) { // avoids license complains from commercial cf-promises during bootstrap - see Nova_CheckLicensePromise strlcat(cmd, " -D bootstrap_mode", CF_BUFSIZE); } /* Check if reloading policy will succeed */ CfOut(cf_verbose, "", "Checking policy with command \"%s\"", cmd); if (ShellCommandReturnsZero(cmd,true)) { if (MINUSF) { snprintf(filename,CF_MAXVARSIZE,"%s/state/validated_%s",CFWORKDIR,CanonifyName(VINPUTFILE)); MapName(filename); } else { snprintf(filename,CF_MAXVARSIZE,"%s/masterfiles/cf_promises_validated",CFWORKDIR); MapName(filename); } MakeParentDirectory(filename,true); if ((fd = creat(filename,0600)) != -1) { close(fd); CfOut(cf_verbose,""," -> Caching the state of validation\n"); } else { CfOut(cf_verbose,"creat"," -> Failed to cache the state of validation\n"); } return true; } else { return false; } } /*****************************************************************************/ void ReadPromises(enum cfagenttype ag,char *agents) { char *v,rettype; void *retval; char vbuff[CF_BUFSIZE]; if (ag == cf_keygen) { return; } DeleteAllPromiseIds(); // in case we are re-reading, delete old handles /* Parse the files*/ Cf3ParseFiles(); /* Now import some web variables that are set in cf-know/control for the report options */ strncpy(STYLESHEET,"/cf_enterprise.css",CF_BUFSIZE-1); strncpy(WEBDRIVER,"",CF_MAXVARSIZE-1); /* Make the compilation reports*/ OpenReports(agents); SetAuditVersion(); if (GetVariable("control_common","version",&retval,&rettype) != cf_notype) { v = (char *)retval; } else { v = "not specified"; } snprintf(vbuff,CF_BUFSIZE-1,"Expanded promises for %s",agents); CfHtmlHeader(FREPORT_HTML,vbuff,STYLESHEET,WEBDRIVER,BANNER); fprintf(FREPORT_TXT,"Expanded promise list for %s component\n\n",agents); ShowContext(); fprintf(FREPORT_HTML,"<div id=\"reporttext\">\n"); fprintf(FREPORT_HTML,"%s",CFH[cfx_promise][cfb]); VerifyPromises(cf_common); fprintf(FREPORT_HTML,"%s",CFH[cfx_promise][cfe]); if (ag != cf_common) { ShowScopedVariables(); } fprintf(FREPORT_HTML,"</div>\n"); CfHtmlFooter(FREPORT_HTML,FOOTER); CloseReports(agents); } /*****************************************************************************/ void Cf3OpenLog(int facility) { #ifdef MINGW NovaWin_OpenLog(facility); #else openlog(VPREFIX,LOG_PID|LOG_NOWAIT|LOG_ODELAY,facility); #endif } /*****************************************************************************/ void Cf3CloseLog() { #ifdef MINGW NovaWin_CloseLog(); #else closelog(); #endif } /*******************************************************************/ /* Level 1 */ /*******************************************************************/ void InitializeGA(int argc,char *argv[]) { int seed,force = false; struct stat statbuf,sb; unsigned char s[16]; char vbuff[CF_BUFSIZE]; char ebuff[CF_EXPANDSIZE]; SHORT_CFENGINEPORT = htons((unsigned short)5308); snprintf(STR_CFENGINEPORT,15,"5308"); NewClass("any"); #if defined HAVE_CONSTELLATION NewClass("constellation_edition"); #elif defined HAVE_NOVA NewClass("nova_edition"); #else NewClass("community_edition"); #endif strcpy(VPREFIX,GetConsolePrefix()); if (VERBOSE) { NewClass("verbose_mode"); } if (INFORM) { NewClass("inform_mode"); } if (DEBUG) { NewClass("debug_mode"); } CfOut(cf_verbose,"","Cfengine - autonomous configuration engine - commence self-diagnostic prelude\n"); CfOut(cf_verbose,"","------------------------------------------------------------------------\n"); /* Define trusted directories */ #ifdef MINGW if(NovaWin_GetProgDir(CFWORKDIR, CF_BUFSIZE - sizeof("Cfengine"))) { strcat(CFWORKDIR, "\\Cfengine"); } else { CfOut(cf_error, "", "!! Could not get CFWORKDIR from Windows environment variable, falling back to compile time dir (%s)", WORKDIR); strcpy(CFWORKDIR,WORKDIR); } Debug("Setting CFWORKDIR=%s\n", CFWORKDIR); #elif defined(CFCYG) strcpy(CFWORKDIR,WORKDIR); MapName(CFWORKDIR); #else if (getuid() > 0) { strncpy(CFWORKDIR,GetHome(getuid()),CF_BUFSIZE-10); strcat(CFWORKDIR,"/.cfagent"); if (strlen(CFWORKDIR) > CF_BUFSIZE/2) { FatalError("Suspicious looking home directory. The path is too long and will lead to problems."); } } else { strcpy(CFWORKDIR,WORKDIR); } #endif /* On windows, use 'binary mode' as default for files */ #ifdef MINGW _fmode = _O_BINARY; #endif strcpy(SYSLOGHOST,"localhost"); SYSLOGPORT = htons(514); Cf3OpenLog(LOG_USER); if (!LOOKUP) /* cf-know should not do this in lookup mode */ { CfOut(cf_verbose,"","Work directory is %s\n",CFWORKDIR); snprintf(HASHDB,CF_BUFSIZE-1,"%s%c%s",CFWORKDIR,FILE_SEPARATOR,CF_CHKDB); snprintf(vbuff,CF_BUFSIZE,"%s%cinputs%cupdate.conf",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); MakeParentDirectory(vbuff,force); snprintf(vbuff,CF_BUFSIZE,"%s%cbin%ccf-agent -D from_cfexecd",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); MakeParentDirectory(vbuff,force); snprintf(vbuff,CF_BUFSIZE,"%s%coutputs%cspooled_reports",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); MakeParentDirectory(vbuff,force); snprintf(vbuff,CF_BUFSIZE,"%s%clastseen%cintermittencies",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); MakeParentDirectory(vbuff,force); snprintf(vbuff,CF_BUFSIZE,"%s%creports%cvarious",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); MakeParentDirectory(vbuff,force); snprintf(vbuff,CF_BUFSIZE,"%s%cinputs",CFWORKDIR,FILE_SEPARATOR); if (cfstat(vbuff,&sb) == -1) { FatalError(" !!! No access to WORKSPACE/inputs dir"); } else { cf_chmod(vbuff,sb.st_mode | 0700); } snprintf(vbuff,CF_BUFSIZE,"%s%coutputs",CFWORKDIR,FILE_SEPARATOR); if (cfstat(vbuff,&sb) == -1) { FatalError(" !!! No access to WORKSPACE/outputs dir"); } else { cf_chmod(vbuff,sb.st_mode | 0700); } sprintf(ebuff,"%s%cstate%ccf_procs",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); MakeParentDirectory(ebuff,force); if (cfstat(ebuff,&statbuf) == -1) { CreateEmptyFile(ebuff); } sprintf(ebuff,"%s%cstate%ccf_rootprocs",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); if (cfstat(ebuff,&statbuf) == -1) { CreateEmptyFile(ebuff); } sprintf(ebuff,"%s%cstate%ccf_otherprocs",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); if (cfstat(ebuff,&statbuf) == -1) { CreateEmptyFile(ebuff); } } OpenNetwork(); /* Init crypto stuff */ OpenSSL_add_all_algorithms(); OpenSSL_add_all_digests(); ERR_load_crypto_strings(); if(!LOOKUP) { CheckWorkingDirectories(); } RandomSeed(); RAND_bytes(s,16); s[15] = '\0'; seed = ElfHash(s); srand48((long)seed); LoadSecretKeys(); /* CheckOpts(argc,argv); - MacOS can't handle this back reference */ if (!MINUSF) { snprintf(VINPUTFILE,CF_BUFSIZE-1,"promises.cf"); } AUDITDBP = NULL; DetermineCfenginePort(); VIFELAPSED = 1; VEXPIREAFTER = 1; setlinebuf(stdout); if (BOOTSTRAP) { snprintf(vbuff,CF_BUFSIZE,"%s%cinputs%cfailsafe.cf",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); if (!IsEnterprise() && cfstat(vbuff,&statbuf) == -1) { snprintf(VINPUTFILE,CF_BUFSIZE-1,".%cfailsafe.cf",FILE_SEPARATOR); } else { strncpy(VINPUTFILE,vbuff,CF_BUFSIZE-1); } } } /*******************************************************************/ static void Cf3ParseFiles() { struct Rlist *rp,*sl; PARSING = true; PROMISETIME = time(NULL); Cf3ParseFile(VINPUTFILE); // Expand any lists in this list now HashVariables(NULL); HashControls(); if (VINPUTLIST != NULL) { for (rp = VINPUTLIST; rp != NULL; rp=rp->next) { if (rp->type != CF_SCALAR) { CfOut(cf_error,"","Non-file object in inputs list\n"); } else { struct Rval returnval; if (strcmp(rp->item,CF_NULL_VALUE) == 0) { continue; } returnval = EvaluateFinalRval("sys",rp->item,rp->type,true,NULL); switch (returnval.rtype) { case CF_SCALAR: Cf3ParseFile((char *)returnval.item); break; case CF_LIST: for (sl = (struct Rlist *)returnval.item; sl != NULL; sl=sl->next) { Cf3ParseFile((char *)sl->item); } break; } DeleteRvalItem(returnval.item,returnval.rtype); } HashVariables(NULL); HashControls(); } } HashVariables(NULL); PARSING = false; } /*******************************************************************/ static int MissingInputFile() { struct stat sb; if (cfstat(InputLocation(VINPUTFILE),&sb) == -1) { CfOut(cf_error,"stat","There is no readable input file at %s",VINPUTFILE); return true; } return false; } /*******************************************************************/ int NewPromiseProposals() { struct Rlist *rp,*sl; struct stat sb; int result = false; char filename[CF_MAXVARSIZE]; if (MINUSF) { snprintf(filename,CF_MAXVARSIZE,"%s/state/validated_%s",CFWORKDIR,CanonifyName(VINPUTFILE)); MapName(filename); } else { snprintf(filename,CF_MAXVARSIZE,"%s/masterfiles/cf_promises_validated",CFWORKDIR); MapName(filename); } if (stat(filename,&sb) != -1) { PROMISETIME = sb.st_mtime; } else { PROMISETIME = 0; } // sanity check if(PROMISETIME > time(NULL)) { CfOut(cf_inform, "", "!! Clock seems to have jumped back in time - mtime of %s is newer than current time - touching it", filename); if(utime(filename,NULL) == -1) { CfOut(cf_error, "utime", "!! Could not touch %s", filename); } PROMISETIME = 0; return true; } if (cfstat(InputLocation(VINPUTFILE),&sb) == -1) { CfOut(cf_verbose,"stat","There is no readable input file at %s",VINPUTFILE); return true; } if (sb.st_mtime > PROMISETIME) { CfOut(cf_verbose,""," -> Promises seem to change"); return true; } // Check the directories first for speed and because non-input/data files should trigger an update snprintf(filename,CF_MAXVARSIZE,"%s/inputs",CFWORKDIR); MapName(filename); if (IsNewerFileTree(filename,PROMISETIME)) { CfOut(cf_verbose,""," -> Quick search detected file changes"); return true; } // Check files in case there are any abs paths if (VINPUTLIST != NULL) { for (rp = VINPUTLIST; rp != NULL; rp=rp->next) { if (rp->type != CF_SCALAR) { CfOut(cf_error,"","Non file object %s in list\n",(char *)rp->item); } else { struct Rval returnval = EvaluateFinalRval("sys",rp->item,rp->type,true,NULL); switch (returnval.rtype) { case CF_SCALAR: if (cfstat(InputLocation((char *)returnval.item),&sb) == -1) { CfOut(cf_error,"stat","Unreadable promise proposals at %s",(char *)returnval.item); result = true; break; } if (sb.st_mtime > PROMISETIME) { result = true; } break; case CF_LIST: for (sl = (struct Rlist *)returnval.item; sl != NULL; sl=sl->next) { if (cfstat(InputLocation((char *)sl->item),&sb) == -1) { CfOut(cf_error,"stat","Unreadable promise proposals at %s",(char *)sl->item); result = true; break; } if (sb.st_mtime > PROMISETIME) { result = true; break; } } break; } DeleteRvalItem(returnval.item,returnval.rtype); if (result) { break; } } } } // did policy server change (used in $(sys.policy_hub))? snprintf(filename,CF_MAXVARSIZE,"%s/policy_server.dat",CFWORKDIR); MapName(filename); if ((cfstat(filename,&sb) != -1) && (sb.st_mtime > PROMISETIME)) { result = true; } return result | ALWAYS_VALIDATE; } /*******************************************************************/ static void OpenReports(char *agents) { char name[CF_BUFSIZE]; if (SHOWREPORTS) { snprintf(name,CF_BUFSIZE,"%s%creports%cpromise_output_%s.txt",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR,agents); if ((FREPORT_TXT = fopen(name,"w")) == NULL) { CfOut(cf_error,"fopen","Cannot open output file %s",name); FREPORT_TXT = fopen(NULLFILE,"w"); } snprintf(name,CF_BUFSIZE,"%s%creports%cpromise_output_%s.html",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR,agents); if ((FREPORT_HTML = fopen(name,"w")) == NULL) { CfOut(cf_error,"fopen","Cannot open output file %s",name); FREPORT_HTML = fopen(NULLFILE,"w"); } snprintf(name,CF_BUFSIZE,"%s%cpromise_knowledge.cf",CFWORKDIR,FILE_SEPARATOR); if ((FKNOW = fopen(name,"w")) == NULL) { CfOut(cf_error,"fopen","Cannot open output file %s",name); FKNOW = fopen(NULLFILE,"w"); } CfOut(cf_inform,""," -> Writing knowledge output to %s",CFWORKDIR); } else { snprintf(name,CF_BUFSIZE,NULLFILE); if ((FREPORT_TXT = fopen(name,"w")) == NULL) { char vbuff[CF_BUFSIZE]; snprintf(vbuff,CF_BUFSIZE,"Cannot open output file %s",name); FatalError(vbuff); } if ((FREPORT_HTML = fopen(name,"w")) == NULL) { char vbuff[CF_BUFSIZE]; snprintf(vbuff,CF_BUFSIZE,"Cannot open output file %s",name); FatalError(vbuff); } if ((FKNOW = fopen(name,"w")) == NULL) { char vbuff[CF_BUFSIZE]; snprintf(vbuff,CF_BUFSIZE,"Cannot open output file %s",name); FatalError(vbuff); } } if (!(FKNOW && FREPORT_HTML && FREPORT_TXT)) { FatalError("Unable to continue as the null-file is unwritable"); } fprintf(FKNOW,"bundle knowledge CfengineEnterpriseFundamentals\n{\n"); ShowTopicRepresentation(FKNOW); fprintf(FKNOW,"}\n\nbundle knowledge CfengineSiteConfiguration\n{\n"); } /*******************************************************************/ static void CloseReports(char *agents) { char name[CF_BUFSIZE]; #ifndef HAVE_NOVA if (SHOWREPORTS) { CfOut(cf_verbose,"","Wrote compilation report %s%creports%cpromise_output_%s.txt",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR,agents); CfOut(cf_verbose,"","Wrote compilation report %s%creports%cpromise_output_%s.html",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR,agents); CfOut(cf_verbose,"","Wrote knowledge map %s%cpromise_knowledge.cf",CFWORKDIR,FILE_SEPARATOR,agents); } #endif fprintf(FKNOW,"}\n"); fclose(FKNOW); fclose(FREPORT_HTML); fclose(FREPORT_TXT); // Make the knowledge readable in situ snprintf(name,CF_BUFSIZE,"%s%cpromise_knowledge.cf",CFWORKDIR,FILE_SEPARATOR); chmod(name,0644); } /*******************************************************************/ /* Level */ /*******************************************************************/ static void Cf3ParseFile(char *filename) { struct stat statbuf; char wfilename[CF_BUFSIZE]; strncpy(wfilename,InputLocation(filename),CF_BUFSIZE); if (cfstat(wfilename,&statbuf) == -1) { if (IGNORE_MISSING_INPUTS) { return; } CfOut(cf_error,"stat","Can't stat file \"%s\" for parsing\n",wfilename); exit(1); } #ifndef NT if (statbuf.st_mode & (S_IWGRP | S_IWOTH)) { CfOut(cf_error,"","File %s (owner %d) is writable by others (security exception)",wfilename,statbuf.st_uid); exit(1); } #endif Debug("+++++++++++++++++++++++++++++++++++++++++++++++\n"); CfOut(cf_verbose,""," > Parsing file %s\n",wfilename); Debug("+++++++++++++++++++++++++++++++++++++++++++++++\n"); PrependAuditFile(wfilename); if ((yyin = fopen(wfilename,"r")) == NULL) /* Open root file */ { printf("Can't open file %s for parsing\n",wfilename); exit (1); } P.line_no = 1; P.line_pos = 1; P.list_nesting = 0; P.arg_nesting = 0; strncpy(P.filename,wfilename,CF_MAXVARSIZE); P.currentid[0] = '\0'; P.currentstring = NULL; P.currenttype[0] = '\0'; P.currentclasses = NULL; P.currentRlist = NULL; P.currentpromise = NULL; P.promiser = NULL; P.blockid[0] = '\0'; P.blocktype[0] = '\0'; while (!feof(yyin)) { yyparse(); if (ferror(yyin)) /* abortable */ { perror("cfengine"); exit(1); } } fclose (yyin); } /*******************************************************************/ struct Constraint *ControlBodyConstraints(enum cfagenttype agent) { struct Body *body; for (body = BODIES; body != NULL; body = body->next) { if (strcmp(body->type,CF_AGENTTYPES[agent]) == 0) { if (strcmp(body->name,"control") == 0) { Debug("%s body for type %s\n",body->name,body->type); return body->conlist; } } } return NULL; } /*******************************************************************/ static int ParseFacility(const char *name) { if (strcmp(name,"LOG_USER") == 0) { return LOG_USER; } if (strcmp(name,"LOG_DAEMON") == 0) { return LOG_DAEMON; } if (strcmp(name,"LOG_LOCAL0") == 0) { return LOG_LOCAL0; } if (strcmp(name,"LOG_LOCAL1") == 0) { return LOG_LOCAL1; } if (strcmp(name,"LOG_LOCAL2") == 0) { return LOG_LOCAL2; } if (strcmp(name,"LOG_LOCAL3") == 0) { return LOG_LOCAL3; } if (strcmp(name,"LOG_LOCAL4") == 0) { return LOG_LOCAL4; } if (strcmp(name,"LOG_LOCAL5") == 0) { return LOG_LOCAL5; } if (strcmp(name,"LOG_LOCAL6") == 0) { return LOG_LOCAL6; } if (strcmp(name,"LOG_LOCAL7") == 0) { return LOG_LOCAL7; } return -1; } void SetFacility(const char *retval) { CfOut(cf_verbose, "", "SET Syslog FACILITY = %s\n", retval); Cf3CloseLog(); Cf3OpenLog(ParseFacility(retval)); } /**************************************************************/ struct Bundle *GetBundle(char *name,char *agent) { struct Bundle *bp; for (bp = BUNDLES; bp != NULL; bp = bp->next) /* get schedule */ { if (strcmp(bp->name,name) == 0) { if (agent) { if ((strcmp(bp->type,agent) == 0) || (strcmp(bp->type,"common") == 0)) { return bp; } else { CfOut(cf_verbose,"","The bundle called %s is not of type %s\n",name,agent); } } else { return bp; } } } return NULL; } /**************************************************************/ struct SubType *GetSubTypeForBundle(char *type,struct Bundle *bp) { struct SubType *sp; if (bp == NULL) { return NULL; } for (sp = bp->subtypes; sp != NULL; sp=sp->next) { if (strcmp(type,sp->name)== 0) { return sp; } } return NULL; } /**************************************************************/ void BannerBundle(struct Bundle *bp,struct Rlist *params) { CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,"","*****************************************************************\n"); if (VERBOSE || DEBUG) { printf("%s> BUNDLE %s",VPREFIX,bp->name); } if (params && (VERBOSE||DEBUG)) { printf("("); ShowRlist(stdout,params); printf(" )\n"); } else { if (VERBOSE||DEBUG) printf("\n"); } CfOut(cf_verbose,"","*****************************************************************\n"); CfOut(cf_verbose,"","\n"); LastSawBundle(bp->name); } /**************************************************************/ void BannerSubBundle(struct Bundle *bp,struct Rlist *params) { CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,""," * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"); if (VERBOSE || DEBUG) { printf("%s> BUNDLE %s",VPREFIX,bp->name); } if (params && (VERBOSE||DEBUG)) { printf("("); ShowRlist(stdout,params); printf(" )\n"); } else { if (VERBOSE||DEBUG) printf("\n"); } CfOut(cf_verbose,""," * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"); CfOut(cf_verbose,"","\n"); LastSawBundle(bp->name); } /**************************************************************/ void PromiseBanner(struct Promise *pp) { char *sp,handle[CF_MAXVARSIZE]; if ((sp = GetConstraint("handle",pp,CF_SCALAR)) || (sp = PromiseID(pp))) { strncpy(handle,sp,CF_MAXVARSIZE-1); } else { strcpy(handle,"(enterprise only)"); } CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,""," .........................................................\n"); if (VERBOSE||DEBUG) { printf ("%s> Promise handle: %s\n",VPREFIX,handle); printf ("%s> Promise made by: %s",VPREFIX,pp->promiser); } if (pp->promisee) { if (VERBOSE) { printf(" -> "); ShowRval(stdout,pp->promisee,pp->petype); } } if (VERBOSE) { printf("\n"); } if (pp->ref) { CfOut(cf_verbose,"","\n"); CfOut(cf_verbose,""," Comment: %s\n",pp->ref); } CfOut(cf_verbose,""," .........................................................\n"); CfOut(cf_verbose,"","\n"); } /*********************************************************************/ static void CheckWorkingDirectories() /* NOTE: We do not care about permissions (ACLs) in windows */ { struct stat statbuf; char vbuff[CF_BUFSIZE]; char output[CF_BUFSIZE]; Debug("CheckWorkingDirectories()\n"); if (uname(&VSYSNAME) == -1) { CfOut(cf_error, "uname", "!!! Couldn't get kernel name info!"); memset(&VSYSNAME, 0, sizeof(VSYSNAME)); } else { snprintf(LOGFILE,CF_BUFSIZE,"%s%ccfagent.%s.log",CFWORKDIR,FILE_SEPARATOR,VSYSNAME.nodename); } snprintf(vbuff,CF_BUFSIZE,"%s%c.",CFWORKDIR,FILE_SEPARATOR); MakeParentDirectory(vbuff,false); CfOut(cf_verbose,"","Making sure that locks are private...\n"); if (chown(CFWORKDIR,getuid(),getgid()) == -1) { CfOut(cf_error,"chown","Unable to set owner on %s to %d.%d",CFWORKDIR,getuid(),getgid()); } if (cfstat(CFWORKDIR,&statbuf) != -1) { /* change permissions go-w */ cf_chmod(CFWORKDIR,(mode_t)(statbuf.st_mode & ~022)); } snprintf(vbuff,CF_BUFSIZE,"%s%cstate%c.",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); MakeParentDirectory(vbuff,false); if (strlen(CFPRIVKEYFILE) == 0) { snprintf(CFPRIVKEYFILE,CF_BUFSIZE,"%s%cppkeys%clocalhost.priv",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); snprintf(CFPUBKEYFILE,CF_BUFSIZE,"%s%cppkeys%clocalhost.pub",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); } CfOut(cf_verbose,"","Checking integrity of the state database\n"); snprintf(vbuff,CF_BUFSIZE,"%s%cstate",CFWORKDIR,FILE_SEPARATOR); if (cfstat(vbuff,&statbuf) == -1) { snprintf(vbuff,CF_BUFSIZE,"%s%cstate%c.",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); MakeParentDirectory(vbuff,false); if (chown(vbuff,getuid(),getgid()) == -1) { CfOut(cf_error,"chown","Unable to set owner on %s to %d.%d",vbuff,getuid(),getgid()); } cf_chmod(vbuff,(mode_t)0755); } else { #ifndef MINGW if (statbuf.st_mode & 022) { CfOut(cf_error,"","UNTRUSTED: State directory %s (mode %o) was not private!\n",CFWORKDIR,statbuf.st_mode & 0777); } #endif /* NOT MINGW */ } CfOut(cf_verbose,"","Checking integrity of the module directory\n"); snprintf(vbuff,CF_BUFSIZE,"%s%cmodules",CFWORKDIR,FILE_SEPARATOR); if (cfstat(vbuff,&statbuf) == -1) { snprintf(vbuff,CF_BUFSIZE,"%s%cmodules%c.",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); MakeParentDirectory(vbuff,false); if (chown(vbuff,getuid(),getgid()) == -1) { CfOut(cf_error,"chown","Unable to set owner on %s to %d.%d",vbuff,getuid(),getgid()); } cf_chmod(vbuff,(mode_t)0700); } else { #ifndef MINGW if (statbuf.st_mode & 022) { CfOut(cf_error,"","UNTRUSTED: Module directory %s (mode %o) was not private!\n",vbuff,statbuf.st_mode & 0777); } #endif /* NOT MINGW */ } CfOut(cf_verbose,"","Checking integrity of the PKI directory\n"); snprintf(vbuff,CF_BUFSIZE,"%s%cppkeys",CFWORKDIR,FILE_SEPARATOR); if (cfstat(vbuff,&statbuf) == -1) { snprintf(vbuff,CF_BUFSIZE,"%s%cppkeys%c.",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR); MakeParentDirectory(vbuff,false); cf_chmod(vbuff,(mode_t)0700); /* Keys must be immutable to others */ } else { #ifndef MINGW if (statbuf.st_mode & 077) { snprintf(output,CF_BUFSIZE-1,"UNTRUSTED: Private key directory %s%cppkeys (mode %o) was not private!\n",CFWORKDIR,FILE_SEPARATOR,statbuf.st_mode & 0777); FatalError(output); } #endif /* NOT MINGW */ } } /*******************************************************************/ /* Level 2 */ /*******************************************************************/ static char *InputLocation(char *filename) { static char wfilename[CF_BUFSIZE], path[CF_BUFSIZE]; if (MINUSF && (filename != VINPUTFILE) && IsFileOutsideDefaultRepository(VINPUTFILE) && !IsAbsoluteFileName(filename)) { /* If -f assume included relative files are in same directory */ strncpy(path,VINPUTFILE,CF_BUFSIZE-1); ChopLastNode(path); snprintf(wfilename,CF_BUFSIZE-1,"%s%c%s",path,FILE_SEPARATOR,filename); } else if (IsFileOutsideDefaultRepository(filename)) { strncpy(wfilename,filename,CF_BUFSIZE-1); } else { snprintf(wfilename,CF_BUFSIZE-1,"%s%cinputs%c%s",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR,filename); } return MapName(wfilename); } /*******************************************************************/ void CompilationReport(char *fname) { if (THIS_AGENT_TYPE != cf_common) { return; } #if defined(HAVE_NOVA) Nova_OpenCompilationReportFiles(fname); #else OpenCompilationReportFiles(fname); #endif if ((FKNOW = fopen(NULLFILE,"w")) == NULL) { FatalError("Null-file failed"); } ShowPromises(BUNDLES,BODIES); fclose(FREPORT_HTML); fclose(FREPORT_TXT); fclose(FKNOW); } void OpenCompilationReportFiles(const char *fname) { char filename[CF_BUFSIZE]; snprintf(filename,CF_BUFSIZE-1,"%s.txt",fname); CfOut(cf_inform,"","Summarizing promises as text to %s\n",filename); if ((FREPORT_TXT = fopen(filename,"w")) == NULL) { FatalError("Could not write output log to %s",filename); } snprintf(filename,CF_BUFSIZE-1,"%s.html",fname); CfOut(cf_inform,"","Summarizing promises as html to %s\n",filename); if ((FREPORT_HTML = fopen(filename,"w")) == NULL) { FatalError("Could not write output log to %s",filename); } } /*******************************************************************/ static void VerifyPromises(enum cfagenttype agent) { struct Bundle *bp; struct SubType *sp; struct Promise *pp; struct Body *bdp; struct Rlist *rp; struct FnCall *fp; char *scope; if (REQUIRE_COMMENTS == CF_UNDEFINED) { for (bdp = BODIES; bdp != NULL; bdp = bdp->next) /* get schedule */ { if ((strcmp(bdp->name,"control") == 0) && (strcmp(bdp->type,"common") == 0)) { REQUIRE_COMMENTS = GetRawBooleanConstraint("require_comments",bdp->conlist); break; } } } for (rp = BODYPARTS; rp != NULL; rp=rp->next) { switch (rp->type) { case CF_SCALAR: if (!IsBody(BODIES,(char *)rp->item)) { CfOut(cf_error,"","Undeclared promise body \"%s()\" was referenced in a promise\n",(char *)rp->item); ERRORCOUNT++; } break; case CF_FNCALL: fp = (struct FnCall *)rp->item; if (!IsBody(BODIES,fp->name)) { CfOut(cf_error,"","Undeclared promise body \"%s()\" was referenced in a promise\n",fp->name); ERRORCOUNT++; } break; } } /* Check for undefined subbundles */ for (rp = SUBBUNDLES; rp != NULL; rp=rp->next) { switch (rp->type) { case CF_SCALAR: if (!IGNORE_MISSING_BUNDLES && !IsCf3VarString(rp->item) && !IsBundle(BUNDLES,(char *)rp->item)) { CfOut(cf_error,"","Undeclared promise bundle \"%s()\" was referenced in a promise\n",(char *)rp->item); ERRORCOUNT++; } break; case CF_FNCALL: fp = (struct FnCall *)rp->item; if (!IGNORE_MISSING_BUNDLES && !IsCf3VarString(fp->name) && !IsBundle(BUNDLES,fp->name)) { CfOut(cf_error,"","Undeclared promise bundle \"%s()\" was referenced in a promise\n",fp->name); ERRORCOUNT++; } break; } } /* Now look once through ALL the bundles themselves */ for (bp = BUNDLES; bp != NULL; bp = bp->next) /* get schedule */ { scope = bp->name; THIS_BUNDLE = bp->name; for (sp = bp->subtypes; sp != NULL; sp = sp->next) /* get schedule */ { if (strcmp(sp->name,"classes") == 0) { /* these should not be evaluated here */ if (agent != cf_common) { continue; } } for (pp = sp->promiselist; pp != NULL; pp=pp->next) { ExpandPromise(agent,scope,pp,NULL); } } } HashVariables(NULL); HashControls(); /* Now look once through the sequences bundles themselves */ if (VerifyBundleSequence(agent) == false) { FatalError("Errors in promise bundles"); } } /********************************************************************/ static void PrependAuditFile(char *file) { struct stat statbuf; if ((AUDITPTR = (struct Audit *)malloc(sizeof(struct Audit))) == NULL) { FatalError("Memory allocation failure in PrependAuditFile"); } if (cfstat(file,&statbuf) == -1) { /* shouldn't happen */ return; } HashFile(file,AUDITPTR->digest,CF_DEFAULT_DIGEST); AUDITPTR->next = VAUDIT; AUDITPTR->filename = strdup(file); AUDITPTR->date = strdup(cf_ctime(&statbuf.st_mtime)); Chop(AUDITPTR->date); AUDITPTR->version = NULL; VAUDIT = AUDITPTR; } /*******************************************************************/ /* Level 3 */ /*******************************************************************/ static void CheckVariablePromises(char *scope,struct Promise *varlist) { struct Promise *pp; int allow_redefine = false; Debug("CheckVariablePromises()\n"); for (pp = varlist; pp != NULL; pp=pp->next) { ConvergeVarHashPromise(scope,pp,allow_redefine); } } /*******************************************************************/ static void CheckCommonClassPromises(struct Promise *classlist) { struct Promise *pp; CfOut(cf_verbose,""," -> Checking common class promises...\n"); for (pp = classlist; pp != NULL; pp=pp->next) { ExpandPromise(cf_agent,THIS_BUNDLE,pp,KeepClassContextPromise); } } /*******************************************************************/ static void CheckControlPromises(char *scope,char *agent,struct Constraint *controllist) { struct Constraint *cp; struct BodySyntax *bp = NULL; struct Rlist *rp; int i = 0; struct Rval returnval; char rettype; void *retval; Debug("CheckControlPromises(%s)\n",agent); for (i = 0; CF_ALL_BODIES[i].bs != NULL; i++) { bp = CF_ALL_BODIES[i].bs; if (strcmp(agent,CF_ALL_BODIES[i].btype) == 0) { break; } } if (bp == NULL) { FatalError("Unknown agent"); } for (cp = controllist; cp != NULL; cp=cp->next) { if (IsExcluded(cp->classes)) { continue; } if (strcmp(cp->lval,CFG_CONTROLBODY[cfg_bundlesequence].lval) == 0) { returnval = ExpandPrivateRval(CONTEXTID,cp->rval,cp->type); } else { returnval = EvaluateFinalRval(CONTEXTID,cp->rval,cp->type,true,NULL); } DeleteVariable(scope,cp->lval); if (!AddVariableHash(scope,cp->lval,returnval.item,returnval.rtype,GetControlDatatype(cp->lval,bp),cp->audit->filename,cp->lineno)) { CfOut(cf_error,""," !! Rule from %s at/before line %d\n",cp->audit->filename,cp->lineno); } if (strcmp(cp->lval,CFG_CONTROLBODY[cfg_output_prefix].lval) == 0) { strncpy(VPREFIX,returnval.item,CF_MAXVARSIZE); } if (strcmp(cp->lval,CFG_CONTROLBODY[cfg_domain].lval) == 0) { strcpy(VDOMAIN,cp->rval); CfOut(cf_verbose,"","SET domain = %s\n",VDOMAIN); DeleteScalar("sys","domain"); DeleteScalar("sys","fqhost"); snprintf(VFQNAME,CF_MAXVARSIZE,"%s.%s",VUQNAME,VDOMAIN); NewScalar("sys","fqhost",VFQNAME,cf_str); NewScalar("sys","domain",VDOMAIN,cf_str); DeleteClass("undefined_domain"); NewClass(VDOMAIN); } if (strcmp(cp->lval,CFG_CONTROLBODY[cfg_ignore_missing_inputs].lval) == 0) { CfOut(cf_verbose,"","SET ignore_missing_inputs %s\n",cp->rval); IGNORE_MISSING_INPUTS = GetBoolean(cp->rval); } if (strcmp(cp->lval,CFG_CONTROLBODY[cfg_ignore_missing_bundles].lval) == 0) { CfOut(cf_verbose,"","SET ignore_missing_bundles %s\n",cp->rval); IGNORE_MISSING_BUNDLES = GetBoolean(cp->rval); } if (strcmp(cp->lval,CFG_CONTROLBODY[cfg_goalpatterns].lval) == 0) { GOALS = NULL; for (rp = (struct Rlist *)returnval.item; rp != NULL; rp=rp->next) { PrependRScalar(&GOALS,rp->item,CF_SCALAR); } CfOut(cf_verbose,"","SET goal_patterns list\n"); continue; } if (strcmp(cp->lval,CFG_CONTROLBODY[cfg_goalcategories].lval) == 0) { GOALCATEGORIES = NULL; for (rp = (struct Rlist *)returnval.item; rp != NULL; rp=rp->next) { PrependRScalar(&GOALCATEGORIES,rp->item,CF_SCALAR); } CfOut(cf_verbose,"","SET goal_categories list\n"); continue; } DeleteRvalItem(returnval.item,returnval.rtype); } } /*******************************************************************/ static void SetAuditVersion() { void *rval; char rtype = 'x'; /* In addition, each bundle can have its own version */ switch (GetVariable("control_common","cfinputs_version",&rval,&rtype)) { case cf_str: if (rtype != CF_SCALAR) { yyerror("non-scalar version string"); } AUDITPTR->version = strdup((char *)rval); break; default: AUDITPTR->version = strdup("no specified version"); break; } } /*******************************************************************/ void Syntax(const char *component, const struct option options[], const char *hints[], const char *id) { int i; printf("\n\n%s\n\n",component); printf("SYNOPSIS:\n\n program [options]\n\nDESCRIPTION:\n\n%s\n",id); printf("Command line options:\n\n"); for (i=0; options[i].name != NULL; i++) { if (options[i].has_arg) { printf("--%-12s, -%c value - %s\n",options[i].name,(char)options[i].val,hints[i]); } else { printf("--%-12s, -%-7c - %s\n",options[i].name,(char)options[i].val,hints[i]); } } printf("\nBug reports: http://bug.cfengine.com, "); printf("Community help: http://forum.cfengine.com\n"); printf("Community info: http://www.cfengine.com/pages/community, "); printf("Support services: http://www.cfengine.com\n\n"); printf("This software is Copyright (C) 2008,2010-present CFEngine AS.\n"); } /*******************************************************************/ void ManPage(const char *component, const struct option options[], const char *hints[], const char *id) { int i; printf(".TH %s 8 \"Maintenance Commands\"\n",GetArg0(component)); printf(".SH NAME\n%s\n\n",component); printf(".SH SYNOPSIS:\n\n %s [options]\n\n.SH DESCRIPTION:\n\n%s\n",GetArg0(component),id); printf(".B cfengine\n" "is a self-healing configuration and change management based system. You can think of" ".B cfengine\n" "as a very high level language, much higher level than Perl or shell. A" "single statement is called a promise, and compliance can result in many hundreds of files" "being created, or the permissions of many hundreds of" "files being set. The idea of " ".B cfengine\n" "is to create a one or more sets of configuration files which will" "classify and describe the setup of every host in a network.\n"); printf(".SH COMMAND LINE OPTIONS:\n"); for (i=0; options[i].name != NULL; i++) { if (options[i].has_arg) { printf(".IP \"--%s, -%c\" value\n%s\n",options[i].name,(char)options[i].val,hints[i]); } else { printf(".IP \"--%s, -%c\"\n%s\n",options[i].name,(char)options[i].val,hints[i]); } } printf(".SH AUTHOR\n" "Mark Burgess and CFEngine AS\n" ".SH INFORMATION\n"); printf("\nBug reports: http://bug.cfengine.com, "); printf(".pp\nCommunity help: http://forum.cfengine.com\n"); printf(".pp\nCommunity info: http://www.cfengine.com/pages/community\n"); printf(".pp\nSupport services: http://www.cfengine.com\n"); printf(".pp\nThis software is Copyright (C) 2008-%d CFEngine AS.\n", BUILD_YEAR); } /*******************************************************************/ static const char *banner_lines[] = { " @@@ ", " @@@ ", " ", " @ @@@ @ ", " @ @@@ @ ", " @ @@@ @ ", " @ @ ", " @@@ ", " @ @ ", " @ @ ", " @ @ ", NULL }; static void AgentBanner(const char **text) { const char **b = banner_lines; while (*b) { printf("%s%s\n", *b, *text ? *text : ""); b++; if (*text) { text++; } } } /*******************************************************************/ void PrintVersionBanner(const char *component) { const char *text[] = { "", component, "", NameVersion(), #ifdef HAVE_NOVA Nova_NameVersion(), #endif #ifdef HAVE_CONSTELLATION Constellation_NameVersion(), #endif NULL }; printf("\n"); AgentBanner(text); printf("\n"); printf("Copyright (C) CFEngine AS 2008-%d\n", BUILD_YEAR); printf("See Licensing at http://cfengine.com/3rdpartylicenses\n"); } /*******************************************************************/ const char *Version(void) { return VERSION; } /*******************************************************************/ const char *NameVersion(void) { return "CFEngine Core " VERSION; } /********************************************************************/ void WritePID(char *filename) { FILE *fp; snprintf(PIDFILE,CF_BUFSIZE-1,"%s%c%s",CFWORKDIR,FILE_SEPARATOR,filename); if ((fp = fopen(PIDFILE,"w")) == NULL) { CfOut(cf_inform,"fopen","Could not write to PID file %s\n",filename); return; } fprintf(fp,"%d\n",getpid()); fclose(fp); } /*******************************************************************/ void HashVariables(char *name) { struct Bundle *bp; struct SubType *sp; CfOut(cf_verbose,"","Initiate variable convergence...\n"); for (bp = BUNDLES; bp != NULL; bp = bp->next) /* get schedule */ { if (name && strcmp(name,bp->name) != 0) { continue; } SetNewScope(bp->name); THIS_BUNDLE = bp->name; for (sp = bp->subtypes; sp != NULL; sp = sp->next) /* get schedule */ { if (strcmp(sp->name,"vars") == 0) { CheckVariablePromises(bp->name,sp->promiselist); } // We must also set global classes here? if (strcmp(bp->type,"common") == 0 && strcmp(sp->name,"classes") == 0) { CheckCommonClassPromises(sp->promiselist); } if (THIS_AGENT_TYPE == cf_common) { CheckBundleParameters(bp->name,bp->args); } } } } /*******************************************************************/ void HashControls() { struct Body *bdp; char buf[CF_BUFSIZE]; /* Only control bodies need to be hashed like variables */ for (bdp = BODIES; bdp != NULL; bdp = bdp->next) /* get schedule */ { if (strcmp(bdp->name,"control") == 0) { snprintf(buf,CF_BUFSIZE,"%s_%s",bdp->name,bdp->type); Debug("Initiate control variable convergence...%s\n",buf); DeleteScope(buf); SetNewScope(buf); CheckControlPromises(buf,bdp->type,bdp->conlist); } } } /*******************************************************************/ static void UnHashVariables() { struct Bundle *bp; for (bp = BUNDLES; bp != NULL; bp = bp->next) /* get schedule */ { DeleteScope(bp->name); } } /********************************************************************/ static bool VerifyBundleSequence(enum cfagenttype agent) { struct Rlist *rp,*params; char rettype,*name; void *retval = NULL; int ok = true; struct FnCall *fp; if ((THIS_AGENT_TYPE != cf_agent) && (THIS_AGENT_TYPE != cf_know) && (THIS_AGENT_TYPE != cf_common)) { return true; } if (CBUNDLESEQUENCE) { return true; } if (GetVariable("control_common","bundlesequence",&retval,&rettype) == cf_notype) { CfOut(cf_error,""," !!! No bundlesequence in the common control body"); return false; } if (rettype != CF_LIST) { FatalError("Promised bundlesequence was not a list"); } if ((agent != cf_agent) && (agent != cf_common)) { return true; } for (rp = (struct Rlist *)retval; rp != NULL; rp=rp->next) { switch (rp->type) { case CF_SCALAR: name = (char *)rp->item; params = NULL; break; case CF_FNCALL: fp = (struct FnCall *)rp->item; name = (char *)fp->name; params = (struct Rlist *)fp->args; break; default: name = NULL; params = NULL; CfOut(cf_error,"","Illegal item found in bundlesequence: "); ShowRval(stdout,rp->item,rp->type); printf(" = %c\n",rp->type); ok = false; break; } if (strcmp(name,CF_NULL_VALUE) == 0) { continue; } if (!IGNORE_MISSING_BUNDLES && !GetBundle(name,NULL)) { CfOut(cf_error,"","Bundle \"%s\" listed in the bundlesequence is not a defined bundle\n",name); ok = false; } } return ok; } /*******************************************************************/ void CheckBundleParameters(char *scope,struct Rlist *args) { struct Rlist *rp; struct Rval retval; char *lval,rettype; for (rp = args; rp != NULL; rp = rp->next) { lval = (char *)rp->item; if (GetVariable(scope,lval,(void *)&retval,&rettype) != cf_notype) { CfOut(cf_error,"","Variable and bundle parameter \"%s\" collide in scope \"%s\"",lval,scope); FatalError("Aborting"); } } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/evalfunction.c�������������������������������������������������������������������0000644�0001750�0001750�00000435744�11715232734�013675� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: evalfunction.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #include <libgen.h> #ifndef MINGW static struct Rval Unix_FnCallUserExists(struct FnCall *fp,struct Rlist *finalargs); static struct Rval Unix_FnCallGroupExists(struct FnCall *fp,struct Rlist *finalargs); #endif /* NOT MINGW */ static char *StripPatterns(char *file_buffer,char *pattern,char *filename); static void CloseStringHole(char *s,int start,int end); static int BuildLineArray(char *array_lval,char *file_buffer,char *split,int maxent,enum cfdatatype type,int intIndex); static int ExecModule(char *command); static int CheckID(char *id); /* assume args are all scalar literals by the time we get here and each handler allocates the memory it returns. There is a protocol to be followed here: Set args, Eval Content, Set rtype, ErrorFlags returnval = FnCallXXXResult(fp) */ /*******************************************************************/ /* FnCall API - OS function mapping */ /*******************************************************************/ static struct Rval FnCallUserExists(struct FnCall *fp,struct Rlist *finalargs) { #ifdef MINGW return NovaWin_FnCallUserExists(fp, finalargs); #else return Unix_FnCallUserExists(fp, finalargs); #endif } /*********************************************************************/ static struct Rval FnCallGroupExists(struct FnCall *fp,struct Rlist *finalargs) { #ifdef MINGW return NovaWin_FnCallGroupExists(fp, finalargs); #else return Unix_FnCallGroupExists(fp, finalargs); #endif } /*******************************************************************/ /* End FnCall API */ /*******************************************************************/ static struct Rlist *GetHostsFromLastseenDB(struct Item *addresses, time_t horizon, bool return_address, bool return_recent) { struct Rlist *recent = NULL, *aged = NULL; struct Item *ip; time_t now = time(NULL); double entrytime; char address[CF_MAXVARSIZE]; for(ip = addresses; ip != NULL; ip = ip->next) { if(sscanf(ip->classes,"%lf",&entrytime) != 1) { CfOut(cf_error, "", "!! Could not get host entry age"); continue; } if (return_address) { snprintf(address, sizeof(address), "%s", ip->name); } else { snprintf(address, sizeof(address), "%s", IPString2Hostname(ip->name)); } if (entrytime < now - horizon) { Debug("Old entry.\n"); if (KeyInRlist(recent, address)) { Debug("There is recent entry for this address. Do nothing.\n"); } else { Debug("Adding to list of aged hosts.\n"); IdempPrependRScalar(&aged, address, CF_SCALAR); } } else { struct Rlist *r; Debug("Recent entry.\n"); if ((r = KeyInRlist(aged, address))) { Debug("Purging from list of aged hosts.\n"); DeleteRlistEntry(&aged, r); } Debug ("Adding to list of recent hosts.\n"); IdempPrependRScalar(&recent, address, CF_SCALAR); } } if (return_recent) { DeleteRlist(aged); return recent; } else { DeleteRlist(recent); return aged; } } /*********************************************************************/ static struct Rval FnCallAnd(struct FnCall *fp, struct Rlist *finalargs) { struct Rval rval; struct Rlist *arg; char id[CF_BUFSIZE]; snprintf(id, CF_BUFSIZE, "built-in FnCall and-arg"); /* We need to check all the arguments, ArgTemplate does not check varadic functions */ for(arg = finalargs; arg; arg = arg->next) { CheckConstraintTypeMatch(id, arg->item, arg->type, cf_str, "", 1); } for(arg = finalargs; arg; arg = arg->next) { if (!IsDefinedClass(arg->item)) { SetFnCallReturnStatus("and", FNCALL_SUCCESS, NULL, NULL); rval.item = strdup("!any"); rval.rtype = CF_SCALAR; return rval; } } SetFnCallReturnStatus("and", FNCALL_SUCCESS, NULL, NULL); rval.item = strdup("any"); rval.rtype = CF_SCALAR; return rval; } /*******************************************************************/ static struct Rval FnCallHostsSeen(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; struct Rlist *returnlist = NULL, *rp; char *policy,*format; CF_DB *dbp; CF_DBC *dbcp; char name[CF_BUFSIZE]; int horizon; struct Item *addresses = NULL; char entrytimeChr[CF_SMALLBUF]; int ksize, vsize; char *key; void *value; /* begin fn specific content */ horizon = Str2Int((char *)(finalargs->item)) * 3600; policy = (char *)(finalargs->next->item); format = (char *)(finalargs->next->next->item); Debug("Calling hostsseen(%d,%s,%s)\n", horizon, policy, format); snprintf(name,CF_BUFSIZE-1,"%s%c%s",CFWORKDIR,FILE_SEPARATOR,CF_LASTDB_FILE); // last-seen may be used by cf-serverd when (re-)reading policy if (!OpenDB(name,&dbp)) { SetFnCallReturnStatus("hostsseen",FNCALL_FAILURE,NULL,NULL); rval.item = NULL; rval.rtype = CF_LIST; return rval; } Debug("Database opened succesfully.\n"); /* Acquire a cursor for the database. */ if (!NewDBCursor(dbp,&dbcp)) { CloseDB(dbp); Debug("Failed to obtain cursor for database\n"); SetFnCallReturnStatus("hostsseen",FNCALL_FAILURE,NULL,NULL); CfOut(cf_error,""," !! Error reading from last-seen database: "); rval.item = NULL; rval.rtype = CF_LIST; return rval; } /* Walk through the database and print out the key/data pairs. */ while (NextDB(dbp, dbcp, &key, &ksize, &value, &vsize)) { if (value != NULL) { struct CfKeyHostSeen entry; if (HostKeyAddressUnknown(value)) { continue; } memcpy(&entry,value,sizeof(entry)); snprintf(entrytimeChr, sizeof(entrytimeChr), "%.4lf", entry.Q.q); PrependItem(&addresses, entry.address, entrytimeChr); } } DeleteDBCursor(dbp,dbcp); CloseDB(dbp); returnlist = GetHostsFromLastseenDB(addresses, horizon, strcmp(format, "address") == 0, strcmp(policy, "lastseen") == 0); DeleteItemList(addresses); Debug(" | Return value:\n"); for(rp = returnlist; rp; rp = rp->next) { Debug(" | %s\n", (char *)rp->item); } /* end fn specific content */ if (returnlist == NULL) { SetFnCallReturnStatus("hostsseen",FNCALL_FAILURE,NULL,NULL); rval.item = NULL; rval.rtype = CF_LIST; return rval; } else { SetFnCallReturnStatus("hostsseen",FNCALL_SUCCESS,NULL,NULL); rval.item = returnlist; rval.rtype = CF_LIST; return rval; } } /*********************************************************************/ static struct Rval FnCallRandomInt(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; int tmp,range,result,from=-1,to=-1; buffer[0] = '\0'; /* begin fn specific content */ from = Str2Int((char *)(finalargs->item)); to = Str2Int((char *)(finalargs->next->item)); if (from == CF_NOINT || to == CF_NOINT) { SetFnCallReturnStatus("randomint",FNCALL_FAILURE,"unrecognized integer",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } if (from > to) { tmp = to; to = from; from = tmp; } range = fabs(to-from); result = from + (int)(drand48()*(double)range); snprintf(buffer,CF_BUFSIZE-1,"%d",result); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallRandomInt"); } /* end fn specific content */ SetFnCallReturnStatus("randomint",FNCALL_SUCCESS,NULL,NULL); rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallGetEnv(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE] = "",ctrlstr[CF_SMALLBUF]; char *name; int limit; /* begin fn specific content */ name = finalargs->item; limit = Str2Int(finalargs->next->item); snprintf(ctrlstr,CF_SMALLBUF,"%%.%ds",limit); // -> %45s if (getenv(name)) { snprintf(buffer,CF_BUFSIZE-1,ctrlstr,getenv(name)); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallGetUid"); } SetFnCallReturnStatus("getenv",FNCALL_SUCCESS,NULL,NULL); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallGetUsers(struct FnCall *fp,struct Rlist *finalargs) #ifndef MINGW { struct Rlist *newlist = NULL,*except_names,*except_uids; struct Rval rval; struct passwd *pw; char buffer[CF_BUFSIZE]; char *except_name,*except_uid; buffer[0] = '\0'; /* begin fn specific content */ except_name = finalargs->item; except_uid = finalargs->next->item; except_names = SplitStringAsRList(except_name,','); except_uids = SplitStringAsRList(except_uid,','); setpwent(); while ((pw = getpwent())) { if (!IsStringIn(except_names,pw->pw_name) && !IsIntIn(except_uids,(int)pw->pw_uid)) { IdempPrependRScalar(&newlist,pw->pw_name,CF_SCALAR); } } endpwent(); SetFnCallReturnStatus("getusers",FNCALL_SUCCESS,NULL,NULL); rval.item = newlist; rval.rtype = CF_LIST; return rval; } #else { struct Rval rval; CfOut(cf_error,""," -> getusers is not yet implemented on Windows"); rval.item = NULL; rval.rtype = CF_LIST; return rval; } #endif /*********************************************************************/ static struct Rval FnCallEscape(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; char *name; buffer[0] = '\0'; /* begin fn specific content */ name = finalargs->item; EscapeSpecialChars(name,buffer,CF_BUFSIZE-1,""); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallEscape"); } SetFnCallReturnStatus("escape",FNCALL_SUCCESS,NULL,NULL); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallHost2IP(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; char *name; buffer[0] = '\0'; /* begin fn specific content */ name = finalargs->item; if ((rval.item = strdup(Hostname2IPString(name))) == NULL) { FatalError("Memory allocation in FnCallHost2IP"); } SetFnCallReturnStatus("host2ip",FNCALL_SUCCESS,NULL,NULL); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallIP2Host(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; char *ip; buffer[0] = '\0'; /* begin fn specific content */ ip = finalargs->item; if ((rval.item = strdup(IPString2Hostname(ip))) == NULL) { FatalError("Memory allocation in FnCallIP2Host"); } SetFnCallReturnStatus("ip2host",FNCALL_SUCCESS,NULL,NULL); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallGetUid(struct FnCall *fp,struct Rlist *finalargs) #ifndef MINGW { struct Rval rval; struct passwd *pw; char buffer[CF_BUFSIZE]; uid_t uid; buffer[0] = '\0'; /* begin fn specific content */ if ((pw = getpwnam((char *)finalargs->item)) == NULL) { uid = CF_UNKNOWN_OWNER; /* signal user not found */ SetFnCallReturnStatus("getuid",FNCALL_FAILURE,strerror(errno),NULL); } else { uid = pw->pw_uid; SetFnCallReturnStatus("getuid",FNCALL_SUCCESS,NULL,NULL); } snprintf(buffer,CF_BUFSIZE-1,"%d",uid); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallGetUid"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } #else /* MINGW */ { struct Rval rval; SetFnCallReturnStatus("getuid",FNCALL_FAILURE,"Windows does not have user ids",NULL); rval.item = strdup("\0"); rval.rtype = CF_SCALAR; return rval; } #endif /* MINGW */ /*********************************************************************/ static struct Rval FnCallGetGid(struct FnCall *fp,struct Rlist *finalargs) #ifndef MINGW { struct Rval rval; struct group *gr; char buffer[CF_BUFSIZE]; gid_t gid; buffer[0] = '\0'; /* begin fn specific content */ if ((gr = getgrnam((char *)finalargs->item)) == NULL) { gid = CF_UNKNOWN_GROUP; /* signal user not found */ SetFnCallReturnStatus("getgid",FNCALL_FAILURE,strerror(errno),NULL); } else { gid = gr->gr_gid; SetFnCallReturnStatus("getgid",FNCALL_SUCCESS,NULL,NULL); } snprintf(buffer,CF_BUFSIZE-1,"%d",gid); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallGetGid"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } #else /* MINGW */ { struct Rval rval; SetFnCallReturnStatus("getgid",FNCALL_FAILURE,"Windows does not have group ids",NULL); rval.item = strdup("\0"); rval.rtype = CF_SCALAR; return rval; } #endif /* MINGW */ /*********************************************************************/ static struct Rval FnCallHash(struct FnCall *fp,struct Rlist *finalargs) /* Hash(string,md5|sha1|crypt) */ { struct Rval rval; char buffer[CF_BUFSIZE],*string,*typestring; unsigned char digest[EVP_MAX_MD_SIZE+1]; enum cfhashes type; buffer[0] = '\0'; /* begin fn specific content */ string = finalargs->item; typestring = finalargs->next->item; type = String2HashType(typestring); if (FIPS_MODE && type == cf_md5) { CfOut(cf_error,""," !! FIPS mode is enabled, and md5 is not an approved algorithm in call to hash()"); } HashString(string,strlen(string),digest,type); snprintf(buffer,CF_BUFSIZE-1,"%s",HashPrint(type,digest)); /* lopp off prefix */ if ((rval.item = strdup(buffer+4)) == NULL) { FatalError("Memory allocation in FnCallHash"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallHashMatch(struct FnCall *fp,struct Rlist *finalargs) /* HashMatch(string,md5|sha1|crypt,"abdxy98edj") */ { struct Rval rval; char buffer[CF_BUFSIZE],ret[CF_BUFSIZE],*string,*typestring,*compare; unsigned char digest[EVP_MAX_MD_SIZE+1]; enum cfhashes type; buffer[0] = '\0'; /* begin fn specific content */ string = finalargs->item; typestring = finalargs->next->item; compare = finalargs->next->next->item; type = String2HashType(typestring); HashFile(string,digest,type); snprintf(buffer,CF_BUFSIZE-1,"%s",HashPrint(type,digest)); CfOut(cf_verbose,""," -> File \"%s\" hashes to \"%s\", compare to \"%s\"\n",string,buffer,compare); if (strcmp(buffer+4,compare) == 0) { strcpy(ret,"any"); } else { strcpy(ret,"!any"); } if ((rval.item = strdup(ret)) == NULL) { FatalError("Memory allocation in FnCallHashMatch"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallConcat(struct FnCall *fp, struct Rlist *finalargs) { struct Rval rval; struct Rlist *arg; char id[CF_BUFSIZE]; snprintf(id, CF_BUFSIZE, "built-in FnCall concat-arg"); char result[CF_BUFSIZE] = ""; /* We need to check all the arguments, ArgTemplate does not check varadic functions */ for(arg = finalargs; arg; arg = arg->next) { CheckConstraintTypeMatch(id, arg->item, arg->type, cf_str, "", 1); } for(arg = finalargs; arg; arg = arg->next) { if (strlcat(result, arg->item, CF_BUFSIZE) >= CF_BUFSIZE) { /* Complain */ CfOut(cf_error, "", "!! Unable to evaluate concat() function, arguments are too long"); SetFnCallReturnStatus("concat",FNCALL_FAILURE,"List of arguments is too long",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } } SetFnCallReturnStatus("concat", FNCALL_SUCCESS, NULL, NULL); rval.item = strdup(result); rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallClassMatch(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; strcpy(buffer,"!any"); /* begin fn specific content */ if (MatchInAlphaList(VHEAP,(char *)finalargs->item)) { SetFnCallReturnStatus("classmatch",FNCALL_SUCCESS,NULL,NULL); strcpy(buffer,"any"); } else if (MatchInAlphaList(VADDCLASSES,(char *)finalargs->item)) { SetFnCallReturnStatus("classmatch",FNCALL_SUCCESS,NULL,NULL); strcpy(buffer,"any"); } /* There is no case in which the function can "fail" to find an answer SetFnCallReturnStatus("classmatch",FNCALL_FAILURE,strerror(errno),NULL); */ if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnClassMatch"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallCountClassesMatching(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE], *string = ((char *)finalargs->item); struct Item *ip; int count = 0; int i = (int)*string; /* begin fn specific content */ if (isalnum(i) || *string == '_') { for (ip = VHEAP.list[i]; ip != NULL; ip=ip->next) { if (FullTextMatch(string,ip->name)) { count++; } } for (ip = VHEAP.list[i]; ip != NULL; ip=ip->next) { if (FullTextMatch(string,ip->name)) { count++; } } } else { for (i = 0; i < CF_ALPHABETSIZE; i++) { for (ip = VHEAP.list[i]; ip != NULL; ip=ip->next) { if (FullTextMatch((char *)finalargs->item,ip->name)) { count++; } } for (ip = VADDCLASSES.list[i]; ip != NULL; ip=ip->next) { if (FullTextMatch((char *)finalargs->item,ip->name)) { count++; } } } } SetFnCallReturnStatus("countclassesmatching",FNCALL_SUCCESS,NULL,NULL); snprintf(buffer,CF_MAXVARSIZE,"%d",count); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnClassMatch"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallCanonify(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; /* begin fn specific content */ SetFnCallReturnStatus("canonify",FNCALL_SUCCESS,NULL,NULL); if ((rval.item = strdup(CanonifyName((char *)finalargs->item))) == NULL) { FatalError("Memory allocation in FnCanonify"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallLastNode(struct FnCall *fp,struct Rlist *finalargs) { struct Rlist *rp,*newlist; struct Rval rval; char *name,*split; /* begin fn specific content */ name = finalargs->item; split = finalargs->next->item; newlist = SplitRegexAsRList(name,split,100,true); for (rp = newlist; rp != NULL; rp=rp->next) { if (rp->next == NULL) { break; } } if (rp && rp->item) { SetFnCallReturnStatus("lastnode",FNCALL_SUCCESS,NULL,NULL); if ((rval.item = strdup(rp->item)) == NULL) { FatalError("Memory allocation in FnLastNode"); } } else { SetFnCallReturnStatus("lastnode",FNCALL_FAILURE,NULL,NULL); if ((rval.item = strdup("")) == NULL) { FatalError("Memory allocation in FnLastNode"); } } /* end fn specific content */ DeleteRlist(newlist); rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallClassify(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; /* begin fn specific content */ SetFnCallReturnStatus("classify",FNCALL_SUCCESS,NULL,NULL); if (IsDefinedClass(CanonifyName(finalargs->item))) { strcpy(buffer,"any"); } else { strcpy(buffer,"!any"); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnClassify"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ /* Executions */ /*********************************************************************/ static struct Rval FnCallReturnsZero(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE],comm[CF_BUFSIZE]; int useshell = false; struct stat statbuf; buffer[0] = '\0'; /* begin fn specific content */ if (!IsAbsoluteFileName(finalargs->item)) { CfOut(cf_error,"","execresult \"%s\" does not have an absolute path\n",finalargs->item); SetFnCallReturnStatus("execresult",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } if (!IsExecutable(GetArg0(finalargs->item))) { CfOut(cf_error,"","execresult \"%s\" is assumed to be executable but isn't\n",finalargs->item); SetFnCallReturnStatus("execresult",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } else { if (strcmp(finalargs->next->item,"useshell") == 0) { useshell = true; snprintf(comm,CF_BUFSIZE,"%s", (char *)finalargs->item); } else { useshell = false; snprintf(comm,CF_BUFSIZE,"%s", (char *)finalargs->item); } if (cfstat(GetArg0(finalargs->item),&statbuf) == -1) { SetFnCallReturnStatus("returnszero",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } else if (ShellCommandReturnsZero(comm,useshell)) { SetFnCallReturnStatus("returnszero",FNCALL_SUCCESS,NULL,NULL); strcpy(buffer,"any"); } else { SetFnCallReturnStatus("returnszero",FNCALL_SUCCESS,strerror(errno),NULL); strcpy(buffer,"!any"); } } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallReturnsZero"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallExecResult(struct FnCall *fp,struct Rlist *finalargs) /* execresult("/programpath",useshell|noshell) */ { struct Rval rval; char buffer[CF_EXPANDSIZE]; int ret = false; buffer[0] = '\0'; /* begin fn specific content */ if (!IsAbsoluteFileName(finalargs->item)) { CfOut(cf_error,"","execresult \"%s\" does not have an absolute path\n",finalargs->item); SetFnCallReturnStatus("execresult",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } if (!IsExecutable(GetArg0(finalargs->item))) { CfOut(cf_error,"","execresult \"%s\" is assumed to be executable but isn't\n",finalargs->item); SetFnCallReturnStatus("execresult",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } else { if (strcmp(finalargs->next->item,"useshell") == 0) { ret = GetExecOutput(finalargs->item,buffer,true); } else { ret = GetExecOutput(finalargs->item,buffer,false); } if (ret) { SetFnCallReturnStatus("execresult",FNCALL_SUCCESS,NULL,NULL); } else { SetFnCallReturnStatus("execresult",FNCALL_FAILURE,strerror(errno),NULL); } } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallExecResult"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallUseModule(struct FnCall *fp,struct Rlist *finalargs) /* usemodule("/programpath",varargs) */ { struct Rval rval; char buffer[CF_BUFSIZE],modulecmd[CF_BUFSIZE]; char *command,*args; struct stat statbuf; buffer[0] = '\0'; /* begin fn specific content */ command = finalargs->item; args = finalargs->next->item; snprintf(modulecmd,CF_BUFSIZE,"%s%cmodules%c%s",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR,command); if (cfstat(GetArg0(modulecmd),&statbuf) == -1) { CfOut(cf_error,"","(Plug-in module %s not found)",modulecmd); SetFnCallReturnStatus("usemodule",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } else if ((statbuf.st_uid != 0) && (statbuf.st_uid != getuid())) { CfOut(cf_error,"","Module %s was not owned by uid=%d who is executing agent\n",modulecmd,getuid()); SetFnCallReturnStatus("usemodule",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } else { if (!JoinPath(modulecmd,args)) { CfOut(cf_error,"","Culprit: class list for module (shouldn't happen)\n" ); SetFnCallReturnStatus("usemodule",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } else { snprintf(modulecmd,CF_BUFSIZE,"%s%cmodules%c%s %s",CFWORKDIR,FILE_SEPARATOR,FILE_SEPARATOR,command,args); CfOut(cf_verbose,"","Executing and using module [%s]\n",modulecmd); if (ExecModule(modulecmd)) { SetFnCallReturnStatus("usemodule",FNCALL_SUCCESS,strerror(errno),NULL); strcpy(buffer,"any"); } else { SetFnCallReturnStatus("usemodule",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } } } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallExecResult"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ /* Misc */ /*********************************************************************/ static struct Rval FnCallSplayClass(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE],class[CF_MAXVARSIZE],hrs[CF_MAXVARSIZE]; enum cfinterval policy; char *splay; int hash,box,hours,minblocks; double period; buffer[0] = '\0'; /* begin fn specific content */ splay = finalargs->item; policy = Str2Interval(finalargs->next->item); switch(policy) { default: case cfa_daily: period = 12.0*23.0; // 0-23 break; case cfa_hourly: period = 11.0; // 0-11 break; } SetFnCallReturnStatus("splayclass",FNCALL_SUCCESS,strerror(errno),NULL); hash = (double)GetHash(splay); box = (int)(0.5 + period*hash/(double)CF_HASHTABLESIZE); minblocks = box % 12; hours = box / 12; if (hours == 0) { strcpy(hrs,"any"); } else { snprintf(hrs,CF_MAXVARSIZE-1,"Hr%02d",hours); } switch ((minblocks)) { case 0: snprintf(class,CF_MAXVARSIZE,"Min00_05.%s",hrs); break; case 1: snprintf(class,CF_MAXVARSIZE,"Min05_10.%s",hrs); break; case 2: snprintf(class,CF_MAXVARSIZE,"Min10_15.%s",hrs); break; case 3: snprintf(class,CF_MAXVARSIZE,"Min15_20.%s",hrs); break; case 4: snprintf(class,CF_MAXVARSIZE,"Min20_25.%s",hrs); break; case 5: snprintf(class,CF_MAXVARSIZE,"Min25_30.%s",hrs); break; case 6: snprintf(class,CF_MAXVARSIZE,"Min30_35.%s",hrs); break; case 7: snprintf(class,CF_MAXVARSIZE,"Min35_40.%s",hrs); break; case 8: snprintf(class,CF_MAXVARSIZE,"Min40_45.%s",hrs); break; case 9: snprintf(class,CF_MAXVARSIZE,"Min45_50.%s",hrs); break; case 10: snprintf(class,CF_MAXVARSIZE,"Min50_55.%s",hrs); break; case 11: snprintf(class,CF_MAXVARSIZE,"Min55_00.%s",hrs); break; default: strcpy(class,"never"); break; } if (IsDefinedClass(class)) { strcpy(buffer,"any"); } else { strcpy(buffer,"!any"); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in SplayClass"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallReadTcp(struct FnCall *fp,struct Rlist *finalargs) /* ReadTCP(localhost,80,'GET index.html',1000) */ { struct cfagent_connection *conn = NULL; struct Rval rval; char buffer[CF_BUFSIZE]; char *hostnameip,*maxbytes,*port,*sendstring; int val = 0, n_read = 0; short portnum; struct Attributes attr = {{0}}; memset(buffer, 0, sizeof(buffer)); /* begin fn specific content */ hostnameip = finalargs->item; port = finalargs->next->item; sendstring = finalargs->next->next->item; maxbytes = finalargs->next->next->next->item; val = Str2Int(maxbytes); portnum = (short) Str2Int(port); if (val < 0 || portnum < 0 || THIS_AGENT_TYPE == cf_common) { SetFnCallReturnStatus("readtcp",FNCALL_FAILURE,"port number or maxbytes out of range",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } rval.item = NULL; rval.rtype = CF_NOPROMISEE; if (val > CF_BUFSIZE-1) { CfOut(cf_error,"","Too many bytes to read from TCP port %s@%s",port,hostnameip); val = CF_BUFSIZE - CF_BUFFERMARGIN; } Debug("Want to read %d bytes from port %d at %s\n",val,portnum,hostnameip); conn = NewAgentConn(); attr.copy.force_ipv4 = false; attr.copy.portnumber = portnum; if (!ServerConnect(conn,hostnameip,attr,NULL)) { CfOut(cf_inform,"socket","Couldn't open a tcp socket"); DeleteAgentConn(conn); SetFnCallReturnStatus("readtcp",FNCALL_FAILURE,strerror(errno),NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } if (strlen(sendstring) > 0) { if (SendSocketStream(conn->sd,sendstring,strlen(sendstring),0) == -1) { cf_closesocket(conn->sd); DeleteAgentConn(conn); SetFnCallReturnStatus("readtcp",FNCALL_FAILURE,strerror(errno),NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } } if ((n_read = recv(conn->sd,buffer,val,0)) == -1) { } if (n_read == -1) { cf_closesocket(conn->sd); DeleteAgentConn(conn); SetFnCallReturnStatus("readtcp",FNCALL_FAILURE,strerror(errno),NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } cf_closesocket(conn->sd); DeleteAgentConn(conn); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallReadTcp"); } SetFnCallReturnStatus("readtcp",FNCALL_SUCCESS,NULL,NULL); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallRegList(struct FnCall *fp,struct Rlist *finalargs) { struct Rlist *rp,*list; struct Rval rval; char buffer[CF_BUFSIZE],naked[CF_MAXVARSIZE],rettype; char *regex,*listvar; void *retval; buffer[0] = '\0'; /* begin fn specific content */ listvar = finalargs->item; regex = finalargs->next->item; if (*listvar == '@') { GetNaked(naked,listvar); } else { CfOut(cf_error,"","Function reglist was promised a list called \"%s\" but this was not found\n",listvar); SetFnCallReturnStatus("reglist",FNCALL_FAILURE,"List was not a list found in scope",NULL); rval.item = strdup("!any"); rval.rtype = CF_SCALAR; return rval; } if (GetVariable(CONTEXTID,naked,&retval,&rettype) == cf_notype) { CfOut(cf_error,"","Function REGLIST was promised a list called \"%s\" but this was not found\n",listvar); SetFnCallReturnStatus("reglist",FNCALL_FAILURE,"List was not a list found in scope",NULL); rval.item = strdup("!any"); rval.rtype = CF_SCALAR; return rval; } if (rettype != CF_LIST) { CfOut(cf_error,"","Function reglist was promised a list called \"%s\" but this variable is not a list\n",listvar); SetFnCallReturnStatus("reglist",FNCALL_FAILURE,"Valid list was not found in scope",NULL); rval.item = strdup("!any"); rval.rtype = CF_SCALAR; return rval; } list = (struct Rlist *)retval; for (rp = list; rp != NULL; rp = rp->next) { if (FullTextMatch(regex,rp->item)) { strcpy(buffer,"any"); break; } else { strcpy(buffer,"!any"); } } SetFnCallReturnStatus("reglist",FNCALL_SUCCESS,NULL,NULL); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallRegList"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallRegArray(struct FnCall *fp,struct Rlist *finalargs) { char lval[CF_MAXVARSIZE],scopeid[CF_MAXVARSIZE]; char *regex,*arrayname,match[CF_MAXVARSIZE],buffer[CF_BUFSIZE]; struct Scope *ptr; struct Rval rval; HashIterator i; CfAssoc *assoc; /* begin fn specific content */ arrayname = finalargs->item; regex = finalargs->next->item; /* Locate the array */ if (strstr(arrayname,".")) { scopeid[0] = '\0'; sscanf(arrayname,"%[^.].%s",scopeid,lval); } else { strcpy(lval,arrayname); strcpy(scopeid,CONTEXTID); } if ((ptr = GetScope(scopeid)) == NULL) { CfOut(cf_error,"","Function regarray was promised an array called \"%s\" but this was not found\n",arrayname); SetFnCallReturnStatus("regarray",FNCALL_FAILURE,"Array not found in scope",NULL); rval.item = strdup("!any"); rval.rtype = CF_SCALAR; return rval; } strcpy(buffer,"!any"); i = HashIteratorInit(ptr->hashtable); while ((assoc = HashIteratorNext(&i))) { snprintf(match,CF_MAXVARSIZE,"%s[",lval); if (strncmp(match,assoc->lval,strlen(match)) == 0) { if (FullTextMatch(regex,assoc->rval)) { strcpy(buffer,"any"); break; } } } SetFnCallReturnStatus("regarray",FNCALL_SUCCESS,NULL,NULL); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallRegList"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallGetIndices(struct FnCall *fp,struct Rlist *finalargs) { char lval[CF_MAXVARSIZE],scopeid[CF_MAXVARSIZE]; char *arrayname,index[CF_MAXVARSIZE],match[CF_MAXVARSIZE]; struct Scope *ptr; struct Rval rval; struct Rlist *returnlist = NULL; HashIterator i; CfAssoc *assoc; /* begin fn specific content */ arrayname = finalargs->item; /* Locate the array */ if (strstr(arrayname,".")) { scopeid[0] = '\0'; sscanf(arrayname,"%127[^.].%127s",scopeid,lval); } else { strcpy(lval,arrayname); strcpy(scopeid,CONTEXTID); } if ((ptr = GetScope(scopeid)) == NULL) { CfOut(cf_verbose,"","Function getindices was promised an array called \"%s\" in scope \"%s\" but this was not found\n",lval,scopeid); SetFnCallReturnStatus("getindices",FNCALL_SUCCESS,"Array not found in scope",NULL); IdempAppendRScalar(&returnlist,CF_NULL_VALUE,CF_SCALAR); rval.item = returnlist; rval.rtype = CF_LIST; return rval; } i = HashIteratorInit(ptr->hashtable); while ((assoc = HashIteratorNext(&i))) { snprintf(match,CF_MAXVARSIZE-1,"%.127s[",lval); if (strncmp(match,assoc->lval,strlen(match)) == 0) { char *sp; index[0] = '\0'; sscanf(assoc->lval+strlen(match),"%127[^\n]",index); if ((sp = strchr(index,']'))) { *sp = '\0'; } else { index[strlen(index)-1] = '\0'; } if (strlen(index) > 0) { IdempAppendRScalar(&returnlist,index,CF_SCALAR); } } } if (returnlist == NULL) { IdempAppendRScalar(&returnlist,CF_NULL_VALUE,CF_SCALAR); } SetFnCallReturnStatus("getindices",FNCALL_SUCCESS,NULL,NULL); rval.item = returnlist; /* end fn specific content */ rval.rtype = CF_LIST; return rval; } /*********************************************************************/ static struct Rval FnCallGetValues(struct FnCall *fp,struct Rlist *finalargs) { char lval[CF_MAXVARSIZE],scopeid[CF_MAXVARSIZE]; char *arrayname,match[CF_MAXVARSIZE]; struct Scope *ptr; struct Rval rval; struct Rlist *rp,*returnlist = NULL; HashIterator i; CfAssoc *assoc; /* begin fn specific content */ arrayname = finalargs->item; /* Locate the array */ if (strstr(arrayname,".")) { scopeid[0] = '\0'; sscanf(arrayname,"%127[^.].%127s",scopeid,lval); } else { strcpy(lval,arrayname); strcpy(scopeid,CONTEXTID); } if ((ptr = GetScope(scopeid)) == NULL) { CfOut(cf_verbose,"","Function getvalues was promised an array called \"%s\" in scope \"%s\" but this was not found\n",lval,scopeid); SetFnCallReturnStatus("getvalues",FNCALL_SUCCESS,"Array not found in scope",NULL); IdempAppendRScalar(&returnlist,CF_NULL_VALUE,CF_SCALAR); rval.item = returnlist; rval.rtype = CF_LIST; return rval; } i = HashIteratorInit(ptr->hashtable); while ((assoc = HashIteratorNext(&i))) { snprintf(match,CF_MAXVARSIZE-1,"%.127s[",lval); if (strncmp(match,assoc->lval,strlen(match)) == 0) { switch(assoc->rtype) { case CF_SCALAR: IdempAppendRScalar(&returnlist,assoc->rval,CF_SCALAR); break; case CF_LIST: for (rp = assoc->rval; rp != NULL; rp = rp->next) { IdempAppendRScalar(&returnlist,assoc->rval,CF_SCALAR); } break; } } } if (returnlist == NULL) { IdempAppendRScalar(&returnlist,CF_NULL_VALUE,CF_SCALAR); } SetFnCallReturnStatus("getindices",FNCALL_SUCCESS,NULL,NULL); rval.item = returnlist; /* end fn specific content */ rval.rtype = CF_LIST; return rval; } /*********************************************************************/ static struct Rval FnCallGrep(struct FnCall *fp,struct Rlist *finalargs) { char lval[CF_MAXVARSIZE]; char *name,*regex,scopeid[CF_MAXVARSIZE]; struct Rval rval,rval2; struct Rlist *rp,*returnlist = NULL; struct Scope *ptr; /* begin fn specific content */ regex = finalargs->item; name = finalargs->next->item; /* Locate the array */ if (strstr(name,".")) { scopeid[0] = '\0'; sscanf(name,"%[^127.].%127s",scopeid,lval); } else { strcpy(lval,name); strcpy(scopeid,CONTEXTID); } if ((ptr = GetScope(scopeid)) == NULL) { CfOut(cf_error,"","Function \"grep\" was promised an array in scope \"%s\" but this was not found\n",scopeid); SetFnCallReturnStatus("getindices",FNCALL_FAILURE,"Array not found in scope",NULL); rval.item = NULL; rval.rtype = CF_LIST; return rval; } if (GetVariable(scopeid,lval,&rval2.item,&rval2.rtype) == cf_notype) { CfOut(cf_error,"","Function \"grep\" was promised a list called \"%s\" but this was not found\n",name); SetFnCallReturnStatus("getindices",FNCALL_FAILURE,"Array not found in scope",NULL); rval.item = NULL; rval.rtype = CF_LIST; return rval; } if (rval2.rtype != CF_LIST) { CfOut(cf_error,"","Function grep was promised a list called \"%s\" but this was not found\n",name); SetFnCallReturnStatus("getindices",FNCALL_FAILURE,"Array not found in scope",NULL); rval.item = NULL; rval.rtype = CF_LIST; return rval; } AppendRScalar(&returnlist,CF_NULL_VALUE,CF_SCALAR); for (rp = (struct Rlist *)rval2.item; rp != NULL; rp=rp->next) { if (FullTextMatch(regex,rp->item)) { AppendRScalar(&returnlist,rp->item,CF_SCALAR); } } SetFnCallReturnStatus("grep",FNCALL_SUCCESS,NULL,NULL); rval.item = returnlist; /* end fn specific content */ rval.rtype = CF_LIST; return rval; } /*********************************************************************/ static struct Rval FnCallSum(struct FnCall *fp,struct Rlist *finalargs) { char lval[CF_MAXVARSIZE],buffer[CF_MAXVARSIZE]; char *name,scopeid[CF_MAXVARSIZE]; struct Rval rval,rval2; struct Rlist *rp; struct Scope *ptr; double sum = 0; /* begin fn specific content */ name = finalargs->item; /* Locate the array */ if (strstr(name,".")) { scopeid[0] = '\0'; sscanf(name,"%[^127.].%127s",scopeid,lval); } else { strcpy(lval,name); strcpy(scopeid,CONTEXTID); } if ((ptr = GetScope(scopeid)) == NULL) { CfOut(cf_error,"","Function \"sum\" was promised a list in scope \"%s\" but this was not found\n",scopeid); SetFnCallReturnStatus("sum",FNCALL_FAILURE,"List not found in scope",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } if (GetVariable(scopeid,lval,&rval2.item,&rval2.rtype) == cf_notype) { CfOut(cf_error,"","Function \"sum\" was promised a list called \"%s\" but this was not found\n",name); SetFnCallReturnStatus("sum",FNCALL_FAILURE,"List not found in scope",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } if (rval2.rtype != CF_LIST) { CfOut(cf_error,"","Function \"sum\" was promised a list called \"%s\" but this was not found\n",name); SetFnCallReturnStatus("sum",FNCALL_FAILURE,"Array not found in scope",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } for (rp = (struct Rlist *)rval2.item; rp != NULL; rp=rp->next) { double x; if ((x = Str2Double(rp->item)) == CF_NODOUBLE) { SetFnCallReturnStatus("sum",FNCALL_FAILURE,"Illegal real number",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } else { sum += x; } } snprintf(buffer,CF_MAXVARSIZE,"%lf",sum); SetFnCallReturnStatus("sum",FNCALL_SUCCESS,NULL,NULL); rval.item = strdup(buffer); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallProduct(struct FnCall *fp,struct Rlist *finalargs) { char lval[CF_MAXVARSIZE],buffer[CF_MAXVARSIZE]; char *name,scopeid[CF_MAXVARSIZE]; struct Rval rval,rval2; struct Rlist *rp; struct Scope *ptr; double product = 1.0; /* begin fn specific content */ name = finalargs->item; /* Locate the array */ if (strstr(name,".")) { scopeid[0] = '\0'; sscanf(name,"%[^127.].%127s",scopeid,lval); } else { strcpy(lval,name); strcpy(scopeid,CONTEXTID); } if ((ptr = GetScope(scopeid)) == NULL) { CfOut(cf_error,"","Function \"product\" was promised a list in scope \"%s\" but this was not found\n",scopeid); SetFnCallReturnStatus("product",FNCALL_FAILURE,"List not found in scope",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } if (GetVariable(scopeid,lval,&rval2.item,&rval2.rtype) == cf_notype) { CfOut(cf_error,"","Function \"product\" was promised a list called \"%s\" but this was not found\n",name); SetFnCallReturnStatus("product",FNCALL_FAILURE,"List not found in scope",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } if (rval2.rtype != CF_LIST) { CfOut(cf_error,"","Function \"product\" was promised a list called \"%s\" but this was not found\n",name); SetFnCallReturnStatus("product",FNCALL_FAILURE,"Array not found in scope",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } for (rp = (struct Rlist *)rval2.item; rp != NULL; rp=rp->next) { double x; if ((x = Str2Double(rp->item)) == CF_NODOUBLE) { SetFnCallReturnStatus("product",FNCALL_FAILURE,"Illegal real number",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } else { product *= x; } } snprintf(buffer,CF_MAXVARSIZE,"%lf",product); SetFnCallReturnStatus("product",FNCALL_SUCCESS,NULL,NULL); rval.item = strdup(buffer); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallJoin(struct FnCall *fp,struct Rlist *finalargs) { char lval[CF_MAXVARSIZE],*joined; char *name,*join,scopeid[CF_MAXVARSIZE]; struct Rval rval,rval2; struct Rlist *rp; struct Scope *ptr; int size = 0; /* begin fn specific content */ join = finalargs->item; name = finalargs->next->item; /* Locate the array */ if (strstr(name,".")) { scopeid[0] = '\0'; sscanf(name,"%[^.].%127s",scopeid,lval); } else { strcpy(lval,name); strcpy(scopeid,"this"); } if ((ptr = GetScope(scopeid)) == NULL) { CfOut(cf_error,"","Function \"join\" was promised an array in scope \"%s\" but this was not found\n",scopeid); SetFnCallReturnStatus("join",FNCALL_FAILURE,"Array not found in scope",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } if (GetVariable(scopeid,lval,&rval2.item,&rval2.rtype) == cf_notype) { CfOut(cf_verbose,"","Function \"join\" was promised a list called \"%s.%s\" but this was not (yet) found\n",scopeid,name); SetFnCallReturnStatus("join",FNCALL_FAILURE,"Array not found in scope",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } if (rval2.rtype != CF_LIST) { CfOut(cf_verbose,"","Function \"join\" was promised a list called \"%s\" but this was not (yet) found\n",name); SetFnCallReturnStatus("join",FNCALL_FAILURE,"Array not found in scope",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } for (rp = (struct Rlist *)rval2.item; rp != NULL; rp=rp->next) { if (strcmp(rp->item,CF_NULL_VALUE) == 0) { continue; } size += strlen(rp->item) + strlen(join); } if ((joined = malloc(size)) == NULL) { CfOut(cf_error,"malloc","Function \"join\" was not able to allocate memory\n",name); SetFnCallReturnStatus("join",FNCALL_FAILURE,"Memory error",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } size = 0; for (rp = (struct Rlist *)rval2.item; rp != NULL; rp=rp->next) { if (strcmp(rp->item,CF_NULL_VALUE) == 0) { continue; } strcpy(joined+size,rp->item); if (rp->next != NULL) { strcpy(joined+size+strlen(rp->item),join); size += strlen(rp->item) + strlen(join); } } SetFnCallReturnStatus("grep",FNCALL_SUCCESS,NULL,NULL); rval.item = joined; /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallGetFields(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; struct Rlist *rp,*newlist; char *filename,*regex,*array_lval,*split; char name[CF_MAXVARSIZE],line[CF_BUFSIZE],retval[CF_SMALLBUF]; int lcount = 0,vcount = 0,nopurge = true; FILE *fin; /* begin fn specific content */ regex = finalargs->item; filename = finalargs->next->item; split = finalargs->next->next->item; array_lval = finalargs->next->next->next->item; if ((fin = fopen(filename,"r")) == NULL) { CfOut(cf_error,"fopen"," !! File \"%s\" could not be read in getfields()",filename); SetFnCallReturnStatus("getfields",FNCALL_FAILURE,"File unreadable",NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } while (!feof(fin)) { line[0] = '\0'; fgets(line,CF_BUFSIZE-1,fin); Chop(line); if (feof(fin)) { break; } if (!FullTextMatch(regex,line)) { continue; } if (lcount == 0) { newlist = SplitRegexAsRList(line,split,31,nopurge); vcount = 1; for (rp = newlist; rp != NULL; rp=rp->next) { snprintf(name,CF_MAXVARSIZE-1,"%s[%d]",array_lval,vcount); NewScalar(THIS_BUNDLE,name,rp->item,cf_str); CfOut(cf_verbose,""," -> getfields: defining %s = %s\n",name,rp->item); vcount++; } } lcount++; } fclose(fin); snprintf(retval,CF_SMALLBUF-1,"%d",lcount); SetFnCallReturnStatus("getfields",FNCALL_SUCCESS,NULL,NULL); rval.item = strdup(retval); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallCountLinesMatching(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char *filename,*regex; char line[CF_BUFSIZE],retval[CF_SMALLBUF]; int lcount = 0; FILE *fin; /* begin fn specific content */ regex = finalargs->item; filename = finalargs->next->item; if ((fin = fopen(filename,"r")) == NULL) { CfOut(cf_verbose,"fopen"," !! File \"%s\" could not be read in countlinesmatching()",filename); snprintf(retval,CF_SMALLBUF-1,"0"); SetFnCallReturnStatus("countlinesmatching",FNCALL_SUCCESS,NULL,NULL); rval.item = strdup(retval); rval.rtype = CF_SCALAR; return rval; } while (!feof(fin)) { line[0] = '\0'; fgets(line,CF_BUFSIZE-1,fin); Chop(line); if (feof(fin)) { break; } if (FullTextMatch(regex,line)) { lcount++; CfOut(cf_verbose,""," -> countlinesmatching: matched \"%s\"",line); continue; } } fclose(fin); snprintf(retval,CF_SMALLBUF-1,"%d",lcount); SetFnCallReturnStatus("countlinesmatching",FNCALL_SUCCESS,NULL,NULL); rval.item = strdup(retval); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallSelectServers(struct FnCall *fp,struct Rlist *finalargs) /* ReadTCP(localhost,80,'GET index.html',1000) */ { struct cfagent_connection *conn = NULL; struct Rlist *rp,*hostnameip; struct Rval rval; char buffer[CF_BUFSIZE],naked[CF_MAXVARSIZE],rettype; char *maxbytes,*port,*sendstring,*regex,*array_lval,*listvar; int val = 0, n_read = 0,count = 0; short portnum; struct Attributes attr = {{0}}; void *retval; struct Promise *pp; buffer[0] = '\0'; /* begin fn specific content */ listvar = finalargs->item; port = finalargs->next->item; sendstring = finalargs->next->next->item; regex = finalargs->next->next->next->item; maxbytes = finalargs->next->next->next->next->item; array_lval = finalargs->next->next->next->next->next->item; if (*listvar == '@') { GetNaked(naked,listvar); } else { CfOut(cf_error,"","Function selectservers was promised a list called \"%s\" but this was not found\n",listvar); SetFnCallReturnStatus("selectservers",FNCALL_FAILURE,"Host list was not a list found in scope",NULL); snprintf(buffer,CF_MAXVARSIZE-1,"%d",count); rval.item = strdup(buffer); rval.rtype = CF_SCALAR; return rval; } if (GetVariable(CONTEXTID,naked,&retval,&rettype) == cf_notype) { CfOut(cf_error,"","Function selectservers was promised a list called \"%s\" but this was not found from context %s.%s\n",listvar,CONTEXTID,naked); SetFnCallReturnStatus("selectservers",FNCALL_FAILURE,"Host list was not a list found in scope",NULL); snprintf(buffer,CF_MAXVARSIZE-1,"%d",count); rval.item = strdup(buffer); rval.rtype = CF_SCALAR; return rval; } if (rettype != CF_LIST) { CfOut(cf_error,"","Function selectservers was promised a list called \"%s\" but this variable is not a list\n",listvar); SetFnCallReturnStatus("selectservers",FNCALL_FAILURE,"Valid list was not found in scope",NULL); snprintf(buffer,CF_MAXVARSIZE-1,"%d",count); rval.item = strdup(buffer); rval.rtype = CF_SCALAR; return rval; } hostnameip = (struct Rlist *)retval; val = Str2Int(maxbytes); portnum = (short) Str2Int(port); if (val < 0 || portnum < 0) { SetFnCallReturnStatus("selectservers",FNCALL_FAILURE,"port number or maxbytes out of range",NULL); snprintf(buffer,CF_MAXVARSIZE-1,"%d",count); rval.item = strdup(buffer); rval.rtype = CF_SCALAR; return rval; } rval.item = NULL; rval.rtype = CF_NOPROMISEE; if (val > CF_BUFSIZE-1) { CfOut(cf_error,"","Too many bytes specificed in selectservers",port); val = CF_BUFSIZE - CF_BUFFERMARGIN; } if (THIS_AGENT_TYPE != cf_agent) { snprintf(buffer,CF_MAXVARSIZE-1,"%d",count); rval.item = strdup(buffer); rval.rtype = CF_SCALAR; return rval; } pp = NewPromise("select_server","function"); for (rp = hostnameip; rp != NULL; rp=rp->next) { Debug("Want to read %d bytes from port %d at %s\n",val,portnum, (char *)rp->item); conn = NewAgentConn(); attr.copy.force_ipv4 = false; attr.copy.portnumber = portnum; if (!ServerConnect(conn,rp->item,attr,pp)) { CfOut(cf_inform,"socket","Couldn't open a tcp socket"); DeleteAgentConn(conn); continue; } if (strlen(sendstring) > 0) { if (SendSocketStream(conn->sd,sendstring,strlen(sendstring),0) == -1) { cf_closesocket(conn->sd); DeleteAgentConn(conn); continue; } if ((n_read = recv(conn->sd,buffer,val,0)) == -1) { } if (n_read == -1) { cf_closesocket(conn->sd); DeleteAgentConn(conn); continue; } if (strlen(regex) == 0 || FullTextMatch(regex,buffer)) { CfOut(cf_verbose,"","Host %s is alive and responding correctly\n",rp->item); snprintf(buffer,CF_MAXVARSIZE-1,"%s[%d]",array_lval,count); NewScalar(CONTEXTID,buffer,rp->item,cf_str); count++; } } else { CfOut(cf_verbose,"","Host %s is alive\n",rp->item); snprintf(buffer,CF_MAXVARSIZE-1,"%s[%d]",array_lval,count); NewScalar(CONTEXTID,buffer,rp->item,cf_str); if (IsDefinedClass(CanonifyName(rp->item))) { CfOut(cf_verbose,"","This host is in the list and has promised to join the class %s - joined\n",array_lval); NewClass(array_lval); } count++; } cf_closesocket(conn->sd); DeleteAgentConn(conn); } DeletePromise(pp); /* Return the subset that is alive and responding correctly */ /* Return the number of lines in array */ snprintf(buffer,CF_MAXVARSIZE-1,"%d",count); rval.item = strdup(buffer); SetFnCallReturnStatus("selectservers",FNCALL_SUCCESS,NULL,NULL); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallIsNewerThan(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; struct stat frombuf,tobuf; buffer[0] = '\0'; /* begin fn specific content */ if (cfstat(finalargs->item,&frombuf) == -1) { SetFnCallReturnStatus("isnewerthan",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } else if (cfstat(finalargs->next->item,&tobuf) == -1) { SetFnCallReturnStatus("isnewerthan",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } else if (frombuf.st_mtime > tobuf.st_mtime) { strcpy(buffer,"any"); SetFnCallReturnStatus("isnewerthan",FNCALL_SUCCESS,NULL,NULL); } else { strcpy(buffer,"!any"); SetFnCallReturnStatus("isnewerthan",FNCALL_SUCCESS,strerror(errno),NULL); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallNewerThan"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallIsAccessedBefore(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; struct stat frombuf,tobuf; buffer[0] = '\0'; /* begin fn specific content */ if (cfstat(finalargs->item,&frombuf) == -1) { SetFnCallReturnStatus("isaccessedbefore",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } else if (cfstat(finalargs->next->item,&tobuf) == -1) { SetFnCallReturnStatus("isaccessedbefore",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } else if (frombuf.st_atime < tobuf.st_atime) { strcpy(buffer,"any"); SetFnCallReturnStatus("isaccessedbefore",FNCALL_SUCCESS,NULL,NULL); } else { strcpy(buffer,"!any"); SetFnCallReturnStatus("isaccessedbefore",FNCALL_SUCCESS,NULL,NULL); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallIsAccessedBefore"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallIsChangedBefore(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; struct stat frombuf,tobuf; buffer[0] = '\0'; /* begin fn specific content */ if (cfstat(finalargs->item,&frombuf) == -1) { SetFnCallReturnStatus("changedbefore",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } else if (cfstat(finalargs->next->item,&tobuf) == -1) { SetFnCallReturnStatus("changedbefore",FNCALL_FAILURE,strerror(errno),NULL); strcpy(buffer,"!any"); } else if (frombuf.st_ctime > tobuf.st_ctime) { strcpy(buffer,"any"); SetFnCallReturnStatus("changedbefore",FNCALL_SUCCESS,NULL,NULL); } else { strcpy(buffer,"!any"); SetFnCallReturnStatus("changedbefore",FNCALL_SUCCESS,NULL,NULL); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallChangedBefore"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallFileStat(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; struct stat statbuf; buffer[0] = '\0'; /* begin fn specific content */ if (lstat(finalargs->item,&statbuf) == -1) { if (!strcmp(fp->name, "filesize")) { strcpy(buffer,"-1"); SetFnCallReturnStatus(fp->name,FNCALL_FAILURE,NULL,NULL); } else { strcpy(buffer,"!any"); SetFnCallReturnStatus(fp->name,FNCALL_SUCCESS,NULL,NULL); } } else { strcpy(buffer,"!any"); if (!strcmp(fp->name, "isexecutable")) { if (IsExecutable(finalargs->item)) { strcpy(buffer,"any"); } } else if (!strcmp(fp->name, "isdir")) { if (S_ISDIR(statbuf.st_mode)) { strcpy(buffer,"any"); } } else if (!strcmp(fp->name, "islink")) { if (S_ISLNK(statbuf.st_mode)) { strcpy(buffer,"any"); } } else if (!strcmp(fp->name, "isplain")) { if (S_ISREG(statbuf.st_mode)) { strcpy(buffer,"any"); } } else if (!strcmp(fp->name, "fileexists")) { strcpy(buffer,"any"); } else if (!strcmp(fp->name, "filesize")) { snprintf(buffer,CF_MAXVARSIZE,"%ld",statbuf.st_size); } SetFnCallReturnStatus(fp->name,FNCALL_SUCCESS,NULL,NULL); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallFileStat"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallIPRange(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; struct Item *ip; buffer[0] = '\0'; /* begin fn specific content */ strcpy(buffer,"!any"); if (!FuzzyMatchParse(finalargs->item)) { strcpy(buffer,"!any"); SetFnCallReturnStatus("IPRange",FNCALL_FAILURE,NULL,NULL); } else { SetFnCallReturnStatus("IPRange",FNCALL_SUCCESS,NULL,NULL); for (ip = IPADDRESSES; ip != NULL; ip = ip->next) { Debug("Checking IP Range against RDNS %s\n",VIPADDRESS); if (FuzzySetMatch(finalargs->item,VIPADDRESS) == 0) { Debug("IPRange Matched\n"); strcpy(buffer,"any"); break; } else { Debug("Checking IP Range against iface %s\n",ip->name); if (FuzzySetMatch(finalargs->item,ip->name) == 0) { Debug("IPRange Matched\n"); strcpy(buffer,"any"); break; } } } } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallChangedBefore"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallHostRange(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; buffer[0] = '\0'; /* begin fn specific content */ strcpy(buffer,"!any"); if (!FuzzyHostParse(finalargs->item,finalargs->next->item)) { strcpy(buffer,"!any"); SetFnCallReturnStatus("IPRange",FNCALL_FAILURE,NULL,NULL); } else if (FuzzyHostMatch(finalargs->item,finalargs->next->item,VUQNAME) == 0) { strcpy(buffer,"any"); SetFnCallReturnStatus("IPRange",FNCALL_SUCCESS,NULL,NULL); } else { strcpy(buffer,"!any"); SetFnCallReturnStatus("IPRange",FNCALL_SUCCESS,NULL,NULL); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallChangedBefore"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallHostInNetgroup(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; char *machine, *user, *domain; buffer[0] = '\0'; /* begin fn specific content */ strcpy(buffer,"!any"); setnetgrent(finalargs->item); while (getnetgrent(&machine,&user,&domain)) { if (strcmp(machine,VUQNAME) == 0) { CfOut(cf_verbose,"","Matched %s in netgroup %s\n",machine,finalargs->item); strcpy(buffer,"any"); break; } if (strcmp(machine,VFQNAME) == 0) { CfOut(cf_verbose,"","Matched %s in netgroup %s\n",machine,finalargs->item); strcpy(buffer,"any"); break; } } endnetgrent(); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallChangedBefore"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallIsVariable(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; buffer[0] = '\0'; /* begin fn specific content */ SetFnCallReturnStatus("isvariable",FNCALL_SUCCESS,NULL,NULL); if (DefinedVariable(finalargs->item)) { strcpy(buffer,"any"); } else { strcpy(buffer,"!any"); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallChangedBefore"); } SetFnCallReturnStatus("isvariable",FNCALL_SUCCESS,NULL,NULL); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallStrCmp(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; buffer[0] = '\0'; /* begin fn specific content */ SetFnCallReturnStatus("strcmp",FNCALL_SUCCESS,NULL,NULL); if (strcmp(finalargs->item,finalargs->next->item) == 0) { strcpy(buffer,"any"); } else { strcpy(buffer,"!any"); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallChangedBefore"); } SetFnCallReturnStatus("strcmp",FNCALL_SUCCESS,NULL,NULL); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallTranslatePath(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[MAX_FILENAME]; buffer[0] = '\0'; /* begin fn specific content */ snprintf(buffer, sizeof(buffer), "%s", (char *)finalargs->item); MapName(buffer); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallChangedBefore"); } SetFnCallReturnStatus("translatepath",FNCALL_SUCCESS,NULL,NULL); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallRegistryValue(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; buffer[0] = '\0'; /* begin fn specific content */ if (GetRegistryValue(finalargs->item,finalargs->next->item,buffer,sizeof(buffer))) { SetFnCallReturnStatus("registryvalue",FNCALL_SUCCESS,NULL,NULL); } else { SetFnCallReturnStatus("registryvalue",FNCALL_FAILURE,NULL,NULL); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallRegistrtValue"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallRemoteScalar(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; char *handle,*server; int encrypted; buffer[0] = '\0'; /* begin fn specific content */ handle = finalargs->item; server = finalargs->next->item; encrypted = GetBoolean(finalargs->next->next->item); if (strcmp(server,"localhost") == 0) { /* The only reason for this is testing...*/ server = "127.0.0.1"; } if (THIS_AGENT_TYPE == cf_common) { if ((rval.item = strdup("<remote scalar>")) == NULL) { FatalError("Memory allocation in FnCallRemoteSCalar"); } } else { GetRemoteScalar("VAR",handle,server,encrypted,buffer); if (strncmp(buffer,"BAD:",4) == 0) { if (RetrieveUnreliableValue("remotescalar",handle,buffer)) { SetFnCallReturnStatus("remotescalar",FNCALL_SUCCESS,NULL,NULL); } else { // This function should never fail buffer[0] = '\0'; SetFnCallReturnStatus("remotescalar",FNCALL_SUCCESS,NULL,NULL); } } else { SetFnCallReturnStatus("remotescalar",FNCALL_SUCCESS,NULL,NULL); CacheUnreliableValue("remotescalar",handle,buffer); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallRemoteSCalar"); } } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallHubKnowledge(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; char *handle; buffer[0] = '\0'; /* begin fn specific content */ handle = finalargs->item; if (THIS_AGENT_TYPE != cf_agent) { if ((rval.item = strdup("<inaccessible remote scalar>")) == NULL) { FatalError("Memory allocation in FnCallRemoteSCalar"); } } else { CfOut(cf_verbose,""," -> Accessing hub knowledge bank for \"%s\"",handle); GetRemoteScalar("VAR",handle,POLICY_SERVER,true,buffer); // This should always be successful - and this one doesn't cache if (strncmp(buffer,"BAD:",4) == 0) { snprintf(buffer,CF_MAXVARSIZE,"0"); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallRemoteSCalar"); } } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallRemoteClassesMatching(struct FnCall *fp,struct Rlist *finalargs) { struct Rlist *rp,*classlist; struct Rval rval; char buffer[CF_BUFSIZE],class[CF_MAXVARSIZE]; char *server,*regex,*prefix; int encrypted; buffer[0] = '\0'; /* begin fn specific content */ regex = finalargs->item; server = finalargs->next->item; encrypted = GetBoolean(finalargs->next->next->item); prefix = finalargs->next->next->next->item; if (strcmp(server,"localhost") == 0) { /* The only reason for this is testing...*/ server = "127.0.0.1"; } if (THIS_AGENT_TYPE == cf_common) { if ((rval.item = strdup("<remote classes>")) == NULL) { FatalError("Memory allocation in FnCallRemoteSCalar"); } } else { GetRemoteScalar("CONTEXT",regex,server,encrypted,buffer); if (strncmp(buffer,"BAD:",4) == 0) { SetFnCallReturnStatus("remoteclassesmatching",FNCALL_FAILURE,NULL,NULL); if ((rval.item = strdup("!any")) == NULL) { FatalError("Memory allocation in FnCallRemoteClassesMatching"); } rval.rtype = CF_SCALAR; return rval; } else { SetFnCallReturnStatus("remoteclassesmatching",FNCALL_SUCCESS,NULL,NULL); if ((rval.item = strdup("any")) == NULL) { FatalError("Memory allocation in FnCallRemoteClassesMatching"); } } if ((classlist = SplitStringAsRList(buffer,','))) { for (rp = classlist; rp != NULL; rp=rp->next) { snprintf(class,CF_MAXVARSIZE-1,"%s_%s",prefix,(char *)rp->item); NewBundleClass(class,THIS_BUNDLE); } DeleteRlist(classlist); } } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallPeers(struct FnCall *fp,struct Rlist *finalargs) { struct Rlist *rp,*newlist,*pruned; struct Rval rval; char *split = "\n",buffer[CF_BUFSIZE]; char *filename,*comment,*file_buffer = NULL; int i,found,groupsize,maxent = 100000,maxsize = 100000; buffer[0] = '\0'; /* begin fn specific content */ filename = finalargs->item; comment = (char *)finalargs->next->item; groupsize = Str2Int(finalargs->next->next->item); file_buffer = (char *)CfReadFile(filename,maxsize); if (file_buffer == NULL) { rval.item = NULL; rval.rtype = CF_LIST; SetFnCallReturnStatus("peers",FNCALL_FAILURE,NULL,NULL); return rval; } else { file_buffer = StripPatterns(file_buffer,comment,filename); if (file_buffer == NULL) { rval.item = NULL; rval.rtype = CF_LIST; return rval; } else { newlist = SplitRegexAsRList(file_buffer,split,maxent,true); } } /* Slice up the list and discard everything except our slice */ i = 0; found = false; pruned = NULL; for (rp = newlist; rp != NULL; rp = rp->next) { char s[CF_MAXVARSIZE]; if (EmptyString(rp->item)) { continue; } s[0] = '\0'; sscanf(rp->item,"%s",s); if (strcmp(s,VFQNAME) == 0 || strcmp(s,VUQNAME) == 0) { found = true; } else { PrependRScalar(&pruned,s,CF_SCALAR); } if (i++ % groupsize == groupsize-1) { if (found) { break; } else { DeleteRlist(pruned); pruned = NULL; } } } DeleteRlist(newlist); if (pruned) { SetFnCallReturnStatus("peers",FNCALL_SUCCESS,NULL,NULL); } else { SetFnCallReturnStatus("peers",FNCALL_FAILURE,NULL,NULL); } free(file_buffer); rval.item = pruned; rval.rtype = CF_LIST; return rval; } /*********************************************************************/ static struct Rval FnCallPeerLeader(struct FnCall *fp,struct Rlist *finalargs) { struct Rlist *rp,*newlist; struct Rval rval; char *split = "\n"; char *filename,*comment,*file_buffer = NULL,buffer[CF_MAXVARSIZE]; int i,found,groupsize,maxent = 100000,maxsize = 100000; buffer[0] = '\0'; /* begin fn specific content */ filename = finalargs->item; comment = (char *)finalargs->next->item; groupsize = Str2Int(finalargs->next->next->item); file_buffer = (char *)CfReadFile(filename,maxsize); if (file_buffer == NULL) { rval.item = NULL; rval.rtype = CF_LIST; SetFnCallReturnStatus("peerleader",FNCALL_FAILURE,NULL,NULL); return rval; } else { file_buffer = StripPatterns(file_buffer,comment,filename); if (file_buffer == NULL) { rval.item = NULL; rval.rtype = CF_LIST; return rval; } else { newlist = SplitRegexAsRList(file_buffer,split,maxent,true); } } /* Slice up the list and discard everything except our slice */ i = 0; found = false; buffer[0] = '\0'; for (rp = newlist; rp != NULL; rp = rp->next) { char s[CF_MAXVARSIZE]; if (EmptyString(rp->item)) { continue; } s[0] = '\0'; sscanf(rp->item,"%s",s); if (strcmp(s,VFQNAME) == 0 || strcmp(s,VUQNAME) == 0) { found = true; } if (i % groupsize == 0) { if (found) { if (strcmp(s,VFQNAME) == 0 || strcmp(s,VUQNAME) == 0) { strncpy(buffer,"localhost",CF_MAXVARSIZE-1); } else { strncpy(buffer,s,CF_MAXVARSIZE-1); } break; } } i++; } DeleteRlist(newlist); if (strlen(buffer) > 0) { SetFnCallReturnStatus("peerleader",FNCALL_SUCCESS,NULL,NULL); } else { SetFnCallReturnStatus("peerleader",FNCALL_FAILURE,NULL,NULL); } free(file_buffer); rval.item = strdup(buffer); rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallPeerLeaders(struct FnCall *fp,struct Rlist *finalargs) { struct Rlist *rp,*newlist,*pruned; struct Rval rval; char *split = "\n"; char *filename,*comment,*file_buffer = NULL,buffer[CF_MAXVARSIZE]; int i,found,groupsize,maxent = 100000,maxsize = 100000; buffer[0] = '\0'; /* begin fn specific content */ filename = finalargs->item; comment = (char *)finalargs->next->item; groupsize = Str2Int(finalargs->next->next->item); file_buffer = (char *)CfReadFile(filename,maxsize); if (file_buffer == NULL) { rval.item = NULL; rval.rtype = CF_LIST; SetFnCallReturnStatus("peerleaders",FNCALL_FAILURE,NULL,NULL); return rval; } else { file_buffer = StripPatterns(file_buffer,comment,filename); if (file_buffer == NULL) { rval.item = NULL; rval.rtype = CF_LIST; return rval; } else { newlist = SplitRegexAsRList(file_buffer,split,maxent,true); } } /* Slice up the list and discard everything except our slice */ i = 0; found = false; pruned = NULL; for (rp = newlist; rp != NULL; rp = rp->next) { char s[CF_MAXVARSIZE]; if (EmptyString(rp->item)) { continue; } s[0] = '\0'; sscanf(rp->item,"%s",s); if (i % groupsize == 0) { if (strcmp(s,VFQNAME) == 0 || strcmp(s,VUQNAME) == 0) { PrependRScalar(&pruned,"localhost",CF_SCALAR); } else { PrependRScalar(&pruned,s,CF_SCALAR); } } i++; } DeleteRlist(newlist); if (pruned) { SetFnCallReturnStatus("peerleaders",FNCALL_SUCCESS,NULL,NULL); } else { SetFnCallReturnStatus("peerleaders",FNCALL_FAILURE,NULL,NULL); } free(file_buffer); rval.item = pruned; rval.rtype = CF_LIST; return rval; } /*********************************************************************/ static struct Rval FnCallRegCmp(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; char *argv0,*argv1; buffer[0] = '\0'; /* begin fn specific content */ strcpy(buffer,CF_ANYCLASS); argv0 = finalargs->item; argv1 = finalargs->next->item; if (FullTextMatch(argv0,argv1)) { strcpy(buffer,"any"); } else { strcpy(buffer,"!any"); } SetFnCallReturnStatus("regcmp",FNCALL_SUCCESS,NULL,NULL); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallRegCmp"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallRegExtract(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; char *regex,*data,*arrayname; struct Scope *ptr; buffer[0] = '\0'; /* begin fn specific content */ strcpy(buffer,CF_ANYCLASS); regex = finalargs->item; data = finalargs->next->item; arrayname = finalargs->next->next->item; if (FullTextMatch(regex,data)) { strcpy(buffer,"any"); } else { strcpy(buffer,"!any"); } ptr = GetScope("match"); if (ptr && ptr->hashtable) { HashIterator i = HashIteratorInit(ptr->hashtable); CfAssoc *assoc; while ((assoc = HashIteratorNext(&i))) { char var[CF_MAXVARSIZE]; if (assoc->rtype != CF_SCALAR) { CfOut(cf_error,""," !! Software error: pattern match was non-scalar in regextract (shouldn't happen)"); strcpy(buffer,"!any"); SetFnCallReturnStatus("regextract",FNCALL_FAILURE,NULL,NULL); break; } else { snprintf(var,CF_MAXVARSIZE-1,"%s[%s]",arrayname,assoc->lval); NewScalar(THIS_BUNDLE,var,assoc->rval,cf_str); } } } else { strcpy(buffer,"!any"); } SetFnCallReturnStatus("regextract",FNCALL_SUCCESS,NULL,NULL); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallRegCmp"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallRegLine(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE],line[CF_BUFSIZE]; char *argv0,*argv1; FILE *fin; buffer[0] = '\0'; /* begin fn specific content */ argv0 = finalargs->item; argv1 = finalargs->next->item; strcpy(buffer,"!any"); if ((fin = fopen(argv1,"r")) == NULL) { strcpy(buffer,"!any"); } else { while (!feof(fin)) { line[0] = '\0'; fgets(line,CF_BUFSIZE-1,fin); Chop(line); if (FullTextMatch(argv0,line)) { strcpy(buffer,"any"); break; } } fclose(fin); } SetFnCallReturnStatus("regline",FNCALL_SUCCESS,NULL,NULL); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallRegLine"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallIsLessGreaterThan(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; char *argv0,*argv1; double a = CF_NOVAL,b = CF_NOVAL; buffer[0] = '\0'; SetFnCallReturnStatus(fp->name,FNCALL_SUCCESS,NULL,NULL); argv0 = finalargs->item; argv1 = finalargs->next->item; if (IsRealNumber(argv0) && IsRealNumber(argv1)) { a = Str2Double(argv0); b = Str2Double(argv1); if (a == CF_NODOUBLE || b == CF_NODOUBLE) { SetFnCallReturnStatus("is*than",FNCALL_FAILURE,NULL,NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } /* begin fn specific content */ if ((a != CF_NOVAL) && (b != CF_NOVAL)) { Debug("%s and %s are numerical\n",argv0,argv1); if (!strcmp(fp->name, "isgreaterthan")) { if (a > b) { strcpy(buffer,"any"); } else { strcpy(buffer,"!any"); } } else { if (a < b) { strcpy(buffer,"any"); } else { strcpy(buffer,"!any"); } } } } else if (strcmp(argv0,argv1) > 0) { Debug("%s and %s are NOT numerical\n",argv0,argv1); if (!strcmp(fp->name, "isgreaterthan")) { strcpy(buffer,"any"); } else { strcpy(buffer,"!any"); } } else { if (!strcmp(fp->name, "isgreaterthan")) { strcpy(buffer,"!any"); } else { strcpy(buffer,"any"); } } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallChangedBefore"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallIRange(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; long tmp,from=CF_NOINT,to=CF_NOINT; buffer[0] = '\0'; /* begin fn specific content */ from = Str2Int(finalargs->item); to = Str2Int(finalargs->next->item); if (from == CF_NOINT || to == CF_NOINT) { SetFnCallReturnStatus("irange",FNCALL_FAILURE,NULL,NULL); rval.item = NULL; rval.rtype = CF_SCALAR; return rval; } if (from == CF_NOINT || to == CF_NOINT) { snprintf(buffer,CF_BUFSIZE,"Error reading assumed int values %s=>%d,%s=>%d\n",(char *)(finalargs->item),from,(char *)(finalargs->next->item),to); ReportError(buffer); } if (from > to) { tmp = to; to = from; from = tmp; } snprintf(buffer,CF_BUFSIZE-1,"%ld,%ld",from,to); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallIRange"); } SetFnCallReturnStatus("irange",FNCALL_SUCCESS,NULL,NULL); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallRRange(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; int tmp; double from=CF_NODOUBLE,to=CF_NODOUBLE; buffer[0] = '\0'; /* begin fn specific content */ from = Str2Double((char *)(finalargs->item)); to = Str2Double((char *)(finalargs->next->item)); if (from == CF_NODOUBLE || to == CF_NODOUBLE) { snprintf(buffer,CF_BUFSIZE,"Error reading assumed real values %s=>%lf,%s=>%lf\n",(char *)(finalargs->item),from,(char *)(finalargs->next->item),to); ReportError(buffer); } if (from > to) { tmp = to; to = from; from = tmp; } snprintf(buffer,CF_BUFSIZE-1,"%lf,%lf",from,to); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallRRange"); } SetFnCallReturnStatus("rrange",FNCALL_SUCCESS,NULL,NULL); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallOn(struct FnCall *fp,struct Rlist *finalargs) { struct Rlist *rp; struct Rval rval; char buffer[CF_BUFSIZE]; long d[6]; time_t cftime; struct tm tmv; enum cfdatetemplate i; buffer[0] = '\0'; /* begin fn specific content */ rp = finalargs; for (i = 0; i < 6; i++) { if (rp != NULL) { d[i] = Str2Int(rp->item); rp = rp->next; } } /* (year,month,day,hour,minutes,seconds) */ tmv.tm_year = d[cfa_year] - 1900; tmv.tm_mon = d[cfa_month] -1; tmv.tm_mday = d[cfa_day]; tmv.tm_hour = d[cfa_hour]; tmv.tm_min = d[cfa_min]; tmv.tm_sec = d[cfa_sec]; tmv.tm_isdst= -1; if ((cftime=mktime(&tmv))== -1) { CfOut(cf_inform,"","Illegal time value"); } Debug("Time computed from input was: %s\n",cf_ctime(&cftime)); snprintf(buffer,CF_BUFSIZE-1,"%ld",cftime); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallOn"); } SetFnCallReturnStatus("on",FNCALL_SUCCESS,NULL,NULL); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallOr(struct FnCall *fp, struct Rlist *finalargs) { struct Rval rval; struct Rlist *arg; char id[CF_BUFSIZE]; snprintf(id, CF_BUFSIZE, "built-in FnCall or-arg"); /* We need to check all the arguments, ArgTemplate does not check varadic functions */ for(arg = finalargs; arg; arg = arg->next) { CheckConstraintTypeMatch(id, arg->item, arg->type, cf_str, "", 1); } for(arg = finalargs; arg; arg = arg->next) { if (IsDefinedClass(arg->item)) { SetFnCallReturnStatus("or", FNCALL_SUCCESS, NULL, NULL); rval.item = strdup("any"); rval.rtype = CF_SCALAR; return rval; } } SetFnCallReturnStatus("or", FNCALL_SUCCESS, NULL, NULL); rval.item = strdup("!any"); rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallLaterThan(struct FnCall *fp,struct Rlist *finalargs) { struct Rlist *rp; struct Rval rval; char buffer[CF_BUFSIZE]; long d[6]; time_t cftime,now = time(NULL); struct tm tmv; enum cfdatetemplate i; buffer[0] = '\0'; /* begin fn specific content */ rp = finalargs; for (i = 0; i < 6; i++) { if (rp != NULL) { d[i] = Str2Int(rp->item); rp = rp->next; } } /* (year,month,day,hour,minutes,seconds) */ tmv.tm_year = d[cfa_year] - 1900; tmv.tm_mon = d[cfa_month] -1; tmv.tm_mday = d[cfa_day]; tmv.tm_hour = d[cfa_hour]; tmv.tm_min = d[cfa_min]; tmv.tm_sec = d[cfa_sec]; tmv.tm_isdst= -1; if ((cftime=mktime(&tmv))== -1) { CfOut(cf_inform,"","Illegal time value"); } Debug("Time computed from input was: %s\n",cf_ctime(&cftime)); if (now > cftime) { strcpy(buffer,CF_ANYCLASS); } else { strcpy(buffer,"!any"); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallLaterThan"); } SetFnCallReturnStatus("laterthan",FNCALL_SUCCESS,NULL,NULL); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallAgoDate(struct FnCall *fp,struct Rlist *finalargs) { struct Rlist *rp; struct Rval rval; char buffer[CF_BUFSIZE]; time_t cftime; long d[6]; enum cfdatetemplate i; buffer[0] = '\0'; /* begin fn specific content */ rp = finalargs; for (i = 0; i < 6; i++) { if (rp != NULL) { d[i] = Str2Int(rp->item); rp = rp->next; } } /* (year,month,day,hour,minutes,seconds) */ cftime = CFSTARTTIME; cftime -= d[cfa_sec]; cftime -= d[cfa_min] * 60; cftime -= d[cfa_hour] * 3600; cftime -= d[cfa_day] * 24 * 3600; cftime -= Months2Seconds(d[cfa_month]); cftime -= d[cfa_year] * 365 * 24 * 3600; Debug("Total negative offset = %.1f minutes\n",(double)(CFSTARTTIME-cftime)/60.0); Debug("Time computed from input was: %s\n",cf_ctime(&cftime)); snprintf(buffer,CF_BUFSIZE-1,"%ld",cftime); if (cftime < 0) { Debug("AGO overflowed, truncating at zero\n"); snprintf(buffer,CF_BUFSIZE-1,"%ld",0); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallAgo"); } /* end fn specific content */ SetFnCallReturnStatus("ago",FNCALL_SUCCESS,NULL,NULL); rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallAccumulatedDate(struct FnCall *fp,struct Rlist *finalargs) { struct Rlist *rp; struct Rval rval; char buffer[CF_BUFSIZE]; long d[6], cftime; enum cfdatetemplate i; buffer[0] = '\0'; /* begin fn specific content */ rp = finalargs; for (i = 0; i < 6; i++) { if (rp != NULL) { d[i] = Str2Int(rp->item); rp = rp->next; } } /* (year,month,day,hour,minutes,seconds) */ cftime = 0; cftime += d[cfa_sec]; cftime += d[cfa_min] * 60; cftime += d[cfa_hour] * 3600; cftime += d[cfa_day] * 24 * 3600; cftime += d[cfa_month] * 30 * 24 * 3600; cftime += d[cfa_year] * 365 * 24 * 3600; snprintf(buffer,CF_BUFSIZE-1,"%ld",cftime); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallAgo"); } /* end fn specific content */ SetFnCallReturnStatus("accumulated",FNCALL_SUCCESS,NULL,NULL); rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallNot(struct FnCall *fp, struct Rlist *finalargs) { struct Rval rval; SetFnCallReturnStatus("not", FNCALL_SUCCESS, NULL, NULL); rval.item = strdup(IsDefinedClass(finalargs->item) ? "!any" : "any"); rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallNow(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; time_t cftime; buffer[0] = '\0'; /* begin fn specific content */ cftime = CFSTARTTIME; Debug("Time computed from input was: %s\n",cf_ctime(&cftime)); snprintf(buffer,CF_BUFSIZE-1,"%ld",(long)cftime); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallAgo"); } /* end fn specific content */ SetFnCallReturnStatus("now",FNCALL_SUCCESS,NULL,NULL); rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ /* Read functions */ /*********************************************************************/ static struct Rval FnCallReadFile(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char *filename; int maxsize; /* begin fn specific content */ filename = (char *)(finalargs->item); maxsize = Str2Int(finalargs->next->item); // Read once to validate structure of file in itemlist Debug("Read string data from file %s (up to %d)\n",filename,maxsize); rval.item = CfReadFile(filename,maxsize); if (rval.item) { SetFnCallReturnStatus("readfile",FNCALL_SUCCESS,NULL,NULL); } else { SetFnCallReturnStatus("readfile",FNCALL_FAILURE,NULL,NULL); } rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval ReadList(struct FnCall *fp,struct Rlist *finalargs,enum cfdatatype type) { struct Rlist *rp,*newlist = NULL; struct Rval rval; char *filename,*comment,*split,fnname[CF_MAXVARSIZE]; int maxent,maxsize,noerrors = true,blanks = false; char *file_buffer = NULL; /* begin fn specific content */ /* 5args: filename,comment_regex,split_regex,max number of entries,maxfilesize */ filename = (char *)(finalargs->item); comment = (char *)(finalargs->next->item); split = (char *)(finalargs->next->next->item); maxent = Str2Int(finalargs->next->next->next->item); maxsize = Str2Int(finalargs->next->next->next->next->item); // Read once to validate structure of file in itemlist Debug("Read string data from file %s\n",filename); snprintf(fnname,CF_MAXVARSIZE-1,"read%slist",CF_DATATYPES[type]); file_buffer = (char *)CfReadFile(filename,maxsize); if (file_buffer == NULL) { rval.item = NULL; rval.rtype = CF_LIST; SetFnCallReturnStatus(fnname,FNCALL_FAILURE,NULL,NULL); return rval; } else { file_buffer = StripPatterns(file_buffer,comment,filename); if (file_buffer == NULL) { SetFnCallReturnStatus(fnname,FNCALL_SUCCESS,NULL,NULL); rval.item = NULL; rval.rtype = CF_LIST; return rval; } else { newlist = SplitRegexAsRList(file_buffer,split,maxent,blanks); } } switch(type) { case cf_str: break; case cf_int: for (rp = newlist; rp != NULL; rp=rp->next) { if (Str2Int(rp->item) == CF_NOINT) { CfOut(cf_error,"","Presumed int value \"%s\" read from file %s has no recognizable value",rp->item,filename); noerrors = false; } } break; case cf_real: for (rp = newlist; rp != NULL; rp=rp->next) { if (Str2Double(rp->item) == CF_NODOUBLE) { CfOut(cf_error,"","Presumed real value \"%s\" read from file %s has no recognizable value",rp->item,filename); noerrors = false; } } break; default: FatalError("Software error readstringlist - abused type"); } if (newlist && noerrors) { SetFnCallReturnStatus(fnname,FNCALL_SUCCESS,NULL,NULL); } else { SetFnCallReturnStatus(fnname,FNCALL_FAILURE,NULL,NULL); } free(file_buffer); rval.item = newlist; rval.rtype = CF_LIST; return rval; } static struct Rval FnCallReadStringList(struct FnCall *fp, struct Rlist *args) { return ReadList(fp, args, cf_str); } static struct Rval FnCallReadIntList(struct FnCall *fp, struct Rlist *args) { return ReadList(fp, args, cf_int); } static struct Rval FnCallReadRealList(struct FnCall *fp, struct Rlist *args) { return ReadList(fp, args, cf_real); } /*********************************************************************/ static struct Rval ReadArray(struct FnCall *fp,struct Rlist *finalargs,enum cfdatatype type,int intIndex) /* lval,filename,separator,comment,Max number of bytes */ { struct Rval rval; char *array_lval,*filename,*comment,*split,fnname[CF_MAXVARSIZE]; int maxent,maxsize,entries = 0; char *file_buffer = NULL; /* Arg validation */ if (intIndex) { snprintf(fnname,CF_MAXVARSIZE-1,"read%sarrayidx",CF_DATATYPES[type]); } else { snprintf(fnname,CF_MAXVARSIZE-1,"read%sarray",CF_DATATYPES[type]); } /* begin fn specific content */ /* 6 args: array_lval,filename,comment_regex,split_regex,max number of entries,maxfilesize */ array_lval = (char *)(finalargs->item); filename = (char *)(finalargs->next->item); comment = (char *)(finalargs->next->next->item); split = (char *)(finalargs->next->next->next->item); maxent = Str2Int(finalargs->next->next->next->next->item); maxsize = Str2Int(finalargs->next->next->next->next->next->item); // Read once to validate structure of file in itemlist Debug("Read string data from file %s - , maxent %d, maxsize %d\n",filename,maxent,maxsize); file_buffer = (char *)CfReadFile(filename,maxsize); Debug("FILE: %s\n",file_buffer); if (file_buffer == NULL) { entries = 0; } else { file_buffer = StripPatterns(file_buffer,comment,filename); if (file_buffer == NULL) { entries = 0; } else { entries = BuildLineArray(array_lval,file_buffer,split,maxent,type,intIndex); } } switch(type) { case cf_str: case cf_int: case cf_real: break; default: FatalError("Software error readstringarray - abused type"); } SetFnCallReturnStatus(fnname,FNCALL_SUCCESS,NULL,NULL); /* Return the number of lines in array */ snprintf(fnname,CF_MAXVARSIZE-1,"%d",entries); rval.item = strdup(fnname); free(file_buffer); rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallReadStringArray(struct FnCall *fp, struct Rlist *args) { return ReadArray(fp, args, cf_str, false); } /*********************************************************************/ static struct Rval FnCallReadStringArrayIndex(struct FnCall *fp, struct Rlist *args) { return ReadArray(fp, args, cf_str, true); } /*********************************************************************/ static struct Rval FnCallReadIntArray(struct FnCall *fp, struct Rlist *args) { return ReadArray(fp, args, cf_int, false); } /*********************************************************************/ static struct Rval FnCallReadRealArray(struct FnCall *fp, struct Rlist *args) { return ReadArray(fp, args, cf_real, false); } /*********************************************************************/ static struct Rval ParseArray(struct FnCall *fp,struct Rlist *finalargs,enum cfdatatype type,int intIndex) /* lval,filename,separator,comment,Max number of bytes */ { struct Rval rval; char *array_lval,*instring,*comment,*split,fnname[CF_MAXVARSIZE]; int maxent,maxsize,entries = 0; /* Arg validation */ if (intIndex) { snprintf(fnname,CF_MAXVARSIZE-1,"read%sarrayidx",CF_DATATYPES[type]); } else { snprintf(fnname,CF_MAXVARSIZE-1,"read%sarray",CF_DATATYPES[type]); } /* begin fn specific content */ /* 6 args: array_lval,instring,comment_regex,split_regex,max number of entries,maxfilesize */ array_lval = (char *)(finalargs->item); instring = strdup((char *)(finalargs->next->item)); comment = (char *)(finalargs->next->next->item); split = (char *)(finalargs->next->next->next->item); maxent = Str2Int(finalargs->next->next->next->next->item); maxsize = Str2Int(finalargs->next->next->next->next->next->item); // Read once to validate structure of file in itemlist Debug("Parse string data from string %s - , maxent %d, maxsize %d\n",instring,maxent,maxsize); if (instring == NULL) { entries = 0; } else { instring = StripPatterns(instring,comment,"string argument 2"); if (instring == NULL) { entries = 0; } else { entries = BuildLineArray(array_lval,instring,split,maxent,type,intIndex); } } switch(type) { case cf_str: case cf_int: case cf_real: break; default: FatalError("Software error parsestringarray - abused type"); } SetFnCallReturnStatus(fnname,FNCALL_SUCCESS,NULL,NULL); /* Return the number of lines in array */ snprintf(fnname,CF_MAXVARSIZE-1,"%d",entries); rval.item = strdup(fnname); free(instring); rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallParseStringArray(struct FnCall *fp, struct Rlist *args) { return ParseArray(fp, args, cf_str, false); } /*********************************************************************/ static struct Rval FnCallParseStringArrayIndex(struct FnCall *fp, struct Rlist *args) { return ParseArray(fp, args, cf_str, true); } /*********************************************************************/ static struct Rval FnCallParseIntArray(struct FnCall *fp, struct Rlist *args) { return ParseArray(fp, args, cf_int, false); } /*********************************************************************/ static struct Rval FnCallParseRealArray(struct FnCall *fp, struct Rlist *args) { return ParseArray(fp, args, cf_real, false); } /*********************************************************************/ static struct Rval FnCallSplitString(struct FnCall *fp,struct Rlist *finalargs) { struct Rlist *newlist = NULL; struct Rval rval; char *string,*split; int max = 0; /* begin fn specific content */ /* 2args: string,split_regex,max */ string = (char *)(finalargs->item); split = (char *)(finalargs->next->item); max = Str2Int((char *)(finalargs->next->next->item)); // Read once to validate structure of file in itemlist newlist = SplitRegexAsRList(string,split,max,true); SetFnCallReturnStatus("splitstring",FNCALL_SUCCESS,NULL,NULL); rval.item = newlist; rval.rtype = CF_LIST; return rval; } /*********************************************************************/ static struct Rval FnCallFileSexist(struct FnCall *fp,struct Rlist *finalargs) { char *listvar; struct Rlist *rp,*files; struct Rval rval; char buffer[CF_BUFSIZE],naked[CF_MAXVARSIZE],rettype; void *retval; struct stat sb; buffer[0] = '\0'; /* begin fn specific content */ listvar = finalargs->item; if (*listvar == '@') { GetNaked(naked,listvar); } else { CfOut(cf_error,"","Function filesexist was promised a list called \"%s\" but this was not found\n",listvar); SetFnCallReturnStatus("filesexist",FNCALL_FAILURE,"File list was not a list found in scope",NULL); rval.item = strdup("!any"); rval.rtype = CF_SCALAR; return rval; } if (GetVariable(CONTEXTID,naked,&retval,&rettype) == cf_notype) { CfOut(cf_error,"","Function filesexist was promised a list called \"%s\" but this was not found\n",listvar); SetFnCallReturnStatus("filesexist",FNCALL_FAILURE,"File list was not a list found in scope",NULL); rval.item = strdup("!any"); rval.rtype = CF_SCALAR; return rval; } if (rettype != CF_LIST) { CfOut(cf_error,"","Function filesexist was promised a list called \"%s\" but this variable is not a list\n",listvar); SetFnCallReturnStatus("filesexist",FNCALL_FAILURE,"File list was not a list found in scope",NULL); rval.item = strdup("!any"); rval.rtype = CF_SCALAR; return rval; } files = (struct Rlist *)retval; strcpy(buffer,"any"); for (rp = files; rp != NULL; rp=rp->next) { if (cfstat(rp->item,&sb) == -1) { strcpy(buffer,"!any"); break; } } rval.item = strdup(buffer); SetFnCallReturnStatus("filesexist",FNCALL_SUCCESS,NULL,NULL); /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ /* LDAP Nova features */ /*********************************************************************/ static struct Rval FnCallLDAPValue(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char *uri,*dn,*filter,*name,*scope,*sec; char buffer[CF_BUFSIZE],handle[CF_BUFSIZE]; void *newval = NULL; /* begin fn specific content */ uri = (char *)(finalargs->item); dn = (char *)(finalargs->next->item); filter = (char *)(finalargs->next->next->item); name = (char *)(finalargs->next->next->next->item); scope = (char *)(finalargs->next->next->next->next->item); sec = (char *)(finalargs->next->next->next->next->next->item); snprintf(handle,CF_BUFSIZE,"%s_%s_%s_%s",dn,filter,name,scope); if ((newval = CfLDAPValue(uri,dn,filter,name,scope,sec))) { CacheUnreliableValue("ldapvalue",handle,newval); } else { if (RetrieveUnreliableValue("ldapvalue",handle,buffer)) { newval = strdup(buffer); } } if (newval) { SetFnCallReturnStatus("ldapvalue",FNCALL_SUCCESS,NULL,NULL); } else { newval = strdup("no result"); SetFnCallReturnStatus("ldapvalue",FNCALL_FAILURE,NULL,NULL); } rval.item = newval; rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallLDAPArray(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char *array,*uri,*dn,*filter,*scope,*sec; void *newval; /* begin fn specific content */ array = (char *)(finalargs->item); uri = (char *)(finalargs->next->item); dn = (char *)(finalargs->next->next->item); filter = (char *)(finalargs->next->next->next->item); scope = (char *)(finalargs->next->next->next->next->item); sec = (char *)(finalargs->next->next->next->next->next->item); if ((newval = CfLDAPArray(array,uri,dn,filter,scope,sec))) { SetFnCallReturnStatus("ldaparray",FNCALL_SUCCESS,NULL,NULL); } else { SetFnCallReturnStatus("ldaparray",FNCALL_FAILURE,NULL,NULL); } rval.item = newval; rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallLDAPList(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char *uri,*dn,*filter,*name,*scope,*sec; void *newval; /* begin fn specific content */ uri = (char *)(finalargs->item); dn = (char *)(finalargs->next->item); filter = (char *)(finalargs->next->next->item); name = (char *)(finalargs->next->next->next->item); scope = (char *)(finalargs->next->next->next->next->item); sec = (char *)(finalargs->next->next->next->next->next->item); if ((newval = CfLDAPList(uri,dn,filter,name,scope,sec))) { SetFnCallReturnStatus("ldaplist",FNCALL_SUCCESS,NULL,NULL); } else { SetFnCallReturnStatus("ldaplist",FNCALL_FAILURE,NULL,NULL); } rval.item = newval; rval.rtype = CF_LIST; return rval; } /*********************************************************************/ static struct Rval FnCallRegLDAP(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char *uri,*dn,*filter,*name,*scope,*regex,*sec; void *newval; /* begin fn specific content */ uri = (char *)(finalargs->item); dn = (char *)(finalargs->next->item); filter = (char *)(finalargs->next->next->item); name = (char *)(finalargs->next->next->next->item); scope = (char *)(finalargs->next->next->next->next->item); regex = (char *)(finalargs->next->next->next->next->next->item); sec = (char *)(finalargs->next->next->next->next->next->next->item); if ((newval = CfRegLDAP(uri,dn,filter,name,scope,regex,sec))) { SetFnCallReturnStatus("regldap",FNCALL_SUCCESS,NULL,NULL); } else { SetFnCallReturnStatus("regldap",FNCALL_FAILURE,NULL,NULL); } rval.item = newval; rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval FnCallDiskFree(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; off_t df; buffer[0] = '\0'; df = GetDiskUsage((char *)finalargs->item, cfabs); if (df == CF_INFINITY) { df = 0; } snprintf(buffer,CF_BUFSIZE-1,"%lld", df); if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallGetGid"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } #ifndef MINGW /*******************************************************************/ /* Unix implementations */ /*******************************************************************/ static struct Rval Unix_FnCallUserExists(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; struct passwd *pw; uid_t uid = -1; char *arg = finalargs->item; buffer[0] = '\0'; /* begin fn specific content */ strcpy(buffer,CF_ANYCLASS); if (IsNumber(arg)) { uid = Str2Uid(arg,NULL,NULL); if (uid < 0) { SetFnCallReturnStatus("userexists",FNCALL_FAILURE,"Illegal user id",NULL); } else { SetFnCallReturnStatus("userexists",FNCALL_SUCCESS,NULL,NULL); } if ((pw = getpwuid(uid)) == NULL) { strcpy(buffer,"!any"); } } else if ((pw = getpwnam(arg)) == NULL) { strcpy(buffer,"!any"); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallUserExists"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } /*********************************************************************/ static struct Rval Unix_FnCallGroupExists(struct FnCall *fp,struct Rlist *finalargs) { struct Rval rval; char buffer[CF_BUFSIZE]; struct group *gr; gid_t gid = -1; char *arg = finalargs->item; buffer[0] = '\0'; /* begin fn specific content */ strcpy(buffer,CF_ANYCLASS); if (isdigit((int)*arg)) { gid = Str2Gid(arg,NULL,NULL); if (gid < 0) { SetFnCallReturnStatus("groupexists",FNCALL_FAILURE,"Illegal group id",NULL); } else { SetFnCallReturnStatus("groupexists",FNCALL_SUCCESS,NULL,NULL); } if ((gr = getgrgid(gid)) == NULL) { strcpy(buffer,"!any"); } } else if ((gr = getgrnam(arg)) == NULL) { strcpy(buffer,"!any"); } if ((rval.item = strdup(buffer)) == NULL) { FatalError("Memory allocation in FnCallGroupExists"); } /* end fn specific content */ rval.rtype = CF_SCALAR; return rval; } #endif /* NOT MINGW */ /*********************************************************************/ /* Level */ /*********************************************************************/ void *CfReadFile(char *filename,int maxsize) { struct stat sb; char *result = NULL; FILE *fp; size_t size; int i,newlines = 0; if (cfstat(filename,&sb) == -1) { if (THIS_AGENT_TYPE == cf_common) { Debug("Could not examine file %s in readfile on this system",filename); } else { if (IsCf3VarString(filename)) { CfOut(cf_verbose,"","Cannot converge/reduce variable \"%s\" yet .. assuming it will resolve later",filename); } else { CfOut(cf_inform,"stat"," !! Could not examine file \"%s\" in readfile",filename); } } return NULL; } if (sb.st_size > maxsize) { CfOut(cf_inform,"","Truncating long file %s in readfile to max limit %d",filename,maxsize); size = maxsize; } else { size = sb.st_size; } if (size == 0) { CfOut(cf_verbose,"","Aborting read: file %s has zero bytes",filename); return NULL; } result = malloc(size+1); if (result == NULL) { CfOut(cf_error,"malloc","Could not allocate file %s in readfile",filename); return NULL; } if ((fp = fopen(filename,"r")) == NULL) { CfOut(cf_verbose,"fopen","Could not open file \"%s\" in readfile",filename); free(result); return NULL; } if (fread(result,size,1,fp) != 1) { CfOut(cf_verbose,"fread","Could not read expected amount from file %s in readfile",filename); fclose(fp); free(result); return NULL; } result[size] = '\0'; for (i = 0; i < size-1; i++) { if (result[i] == '\n' || result[i] == '\r') { newlines++; } } if (newlines == 0 && (result[size-1] == '\n' || result[size-1] == '\r')) { result[size-1] = '\0'; } fclose(fp); return (void *)result; } /*********************************************************************/ static char *StripPatterns(char *file_buffer,char *pattern,char *filename) { int start,end; int count = 0; if(!EMPTY(pattern)) { while(BlockTextMatch(pattern,file_buffer,&start,&end)) { CloseStringHole(file_buffer,start,end); if (count++ > strlen(file_buffer)) { CfOut(cf_error,""," !! Comment regex \"%s\" was irreconcilable reading input \"%s\" probably because it legally matches nothing",pattern,filename); return file_buffer; } } } return file_buffer; } /*********************************************************************/ static void CloseStringHole(char *s,int start,int end) { int off = end - start; char *sp; if (off <= 0) { return; } for (sp = s + start; *(sp+off) != '\0'; sp++) { *sp = *(sp+off); } *sp = '\0'; } /*********************************************************************/ static int BuildLineArray(char *array_lval,char *file_buffer,char *split,int maxent,enum cfdatatype type,int intIndex) { char *sp,linebuf[CF_BUFSIZE],name[CF_MAXVARSIZE],first_one[CF_MAXVARSIZE]; struct Rlist *rp,*newlist = NULL; int allowblanks = true, vcount,hcount,lcount = 0; int lineLen; memset(linebuf,0,CF_BUFSIZE); hcount = 0; for (sp = file_buffer; hcount < maxent && *sp != '\0'; sp++) { linebuf[0] = '\0'; sscanf(sp,"%1023[^\n]",linebuf); lineLen = strlen(linebuf); if (lineLen == 0) { continue; } else if (lineLen == 1 && linebuf[0] == '\r') { continue; } if (linebuf[lineLen - 1] == '\r') { linebuf[lineLen - 1] = '\0'; } if (lcount++ > CF_HASHTABLESIZE) { CfOut(cf_error,""," !! Array is too big to be read into Cfengine (max 4000)"); break; } newlist = SplitRegexAsRList(linebuf,split,maxent,allowblanks); vcount = 0; first_one[0] = '\0'; for (rp = newlist; rp != NULL; rp=rp->next) { char this_rval[CF_MAXVARSIZE]; long ival; double rval; switch (type) { case cf_str: strncpy(this_rval,rp->item,CF_MAXVARSIZE-1); break; case cf_int: ival = Str2Int(rp->item); snprintf(this_rval,CF_MAXVARSIZE,"%d",(int)ival); break; case cf_real: rval = Str2Int(rp->item); sscanf(rp->item,"%255s",this_rval); break; default: FatalError("Software error readstringarray - abused type"); } if (strlen(first_one) == 0) { strncpy(first_one,this_rval,CF_MAXVARSIZE-1); } if (intIndex) { snprintf(name,CF_MAXVARSIZE,"%s[%d][%d]",array_lval,hcount,vcount); } else { snprintf(name,CF_MAXVARSIZE,"%s[%s][%d]",array_lval,first_one,vcount); } NewScalar(THIS_BUNDLE,name,this_rval,type); vcount++; } hcount++; sp += lineLen; if (*sp == '\0') // either \n or \0 { break; } } /* Don't free data - goes into vars */ return hcount; } /*********************************************************************/ static int ExecModule(char *command) { FILE *pp; char *sp,line[CF_BUFSIZE]; int print = false; if ((pp = cf_popen(command,"r")) == NULL) { CfOut(cf_error,"cf_popen","Couldn't open pipe from %s\n",command); return false; } while (!feof(pp)) { if (ferror(pp)) /* abortable */ { CfOut(cf_error,"","Shell command pipe %s\n",command); break; } CfReadLine(line,CF_BUFSIZE,pp); if (strlen(line) > CF_BUFSIZE - 80) { CfOut(cf_error,"","Line from module %s is too long to be sensible\n",command); break; } if (ferror(pp)) /* abortable */ { CfOut(cf_error,"","Shell command pipe %s\n",command); break; } print = false; for (sp = line; *sp != '\0'; sp++) { if (! isspace((int)*sp)) { print = true; break; } } ModuleProtocol(command,line,print); } cf_pclose(pp); return true; } /*********************************************************************/ /* Level */ /*********************************************************************/ void ModuleProtocol(char *command,char *line,int print) { char name[CF_BUFSIZE],content[CF_BUFSIZE],context[CF_BUFSIZE]; char arg0[CF_BUFSIZE]; char *filename; /* Infer namespace from script name */ snprintf(arg0, CF_BUFSIZE, "%s", GetArg0(command)); filename = basename(arg0); /* Canonicalize filename into acceptable namespace name*/ CanonifyNameInPlace(filename); strcpy(context,filename); CfOut(cf_verbose, "", "Module context: %s\n", context); NewScope(context); name[0] = '\0'; content[0] = '\0'; switch (*line) { case '+': CfOut(cf_verbose,"","Activated classes: %s\n",line+1); if (CheckID(line+1)) { NewClass(line+1); } break; case '-': CfOut(cf_verbose,"","Deactivated classes: %s\n",line+1); if (CheckID(line+1)) { NegateClassesFromString(line+1,&VNEGHEAP); } break; case '=': content[0] = '\0'; sscanf(line+1,"%[^=]=%[^\n]",name,content); if (CheckID(name)) { CfOut(cf_verbose,"","Defined variable: %s in context %s with value: %s\n",name,context,content); NewScalar(context,name,content,cf_str); } break; case '@': content[0] = '\0'; sscanf(line+1,"%[^=]=%[^\n]",name,content); if (CheckID(name)) { CfOut(cf_verbose,"","Defined variable: %s in context %s with value: %s\n",name,context,content); struct Rlist *list = ParseShownRlist(content); NewList(context,name,list,cf_slist); } break; default: if (print) { CfOut(cf_cmdout,"","M \"%s\": %s\n",command,line); } break; } } /*********************************************************************/ /* Level */ /*********************************************************************/ static int CheckID(char *id) { char *sp; for (sp = id; *sp != '\0'; sp++) { if (!isalnum((int)*sp) && (*sp != '_')) { CfOut(cf_error,"","Module protocol contained an illegal character \'%c\' in class/variable identifier \'%s\'.",*sp,id); return false; } } return true; } /*********************************************************************/ struct Rval CallFunction(FnCallType *function, struct FnCall *fp, struct Rlist *expargs) { ArgTemplate(fp, function->args, expargs); return (*function->impl)(fp, expargs); } /*********************************************************/ /* Function prototypes */ /*********************************************************/ struct FnCallArg ACCESSEDBEFORE_ARGS[] = { {CF_ABSPATHRANGE,cf_str,"Newer filename"}, {CF_ABSPATHRANGE,cf_str,"Older filename"}, {NULL,cf_notype,NULL} }; struct FnCallArg ACCUM_ARGS[] = { {"0,1000",cf_int,"Years"}, {"0,1000",cf_int,"Months"}, {"0,1000",cf_int,"Days"}, {"0,1000",cf_int,"Hours"}, {"0,1000",cf_int,"Minutes"}, {"0,40000",cf_int,"Seconds"}, {NULL,cf_notype,NULL} }; struct FnCallArg AND_ARGS[] = { {NULL,cf_notype,NULL} }; struct FnCallArg AGO_ARGS[] = { {"0,1000",cf_int,"Years"}, {"0,1000",cf_int,"Months"}, {"0,1000",cf_int,"Days"}, {"0,1000",cf_int,"Hours"}, {"0,1000",cf_int,"Minutes"}, {"0,40000",cf_int,"Seconds"}, {NULL,cf_notype,NULL} }; struct FnCallArg LATERTHAN_ARGS[] = { {"0,1000",cf_int,"Years"}, {"0,1000",cf_int,"Months"}, {"0,1000",cf_int,"Days"}, {"0,1000",cf_int,"Hours"}, {"0,1000",cf_int,"Minutes"}, {"0,40000",cf_int,"Seconds"}, {NULL,cf_notype,NULL} }; struct FnCallArg CANONIFY_ARGS[] = { {CF_ANYSTRING,cf_str,"String containing non-identifier characters"}, {NULL,cf_notype,NULL} }; struct FnCallArg CHANGEDBEFORE_ARGS[] = { {CF_ABSPATHRANGE,cf_str,"Newer filename"}, {CF_ABSPATHRANGE,cf_str,"Older filename"}, {NULL,cf_notype,NULL} }; struct FnCallArg CLASSIFY_ARGS[] = { {CF_ANYSTRING,cf_str,"Input string"}, {NULL,cf_notype,NULL} }; struct FnCallArg CLASSMATCH_ARGS[] = { {CF_ANYSTRING,cf_str,"Regular expression"}, {NULL,cf_notype,NULL} }; struct FnCallArg CONCAT_ARGS[] = { {NULL,cf_notype,NULL} }; struct FnCallArg COUNTCLASSESMATCHING_ARGS[] = { {CF_ANYSTRING,cf_str,"Regular expression"}, {NULL,cf_notype,NULL} }; struct FnCallArg COUNTLINESMATCHING_ARGS[] = { {CF_ANYSTRING,cf_str,"Regular expression"}, {CF_ABSPATHRANGE,cf_str,"Filename"}, {NULL,cf_notype,NULL} }; struct FnCallArg DISKFREE_ARGS[] = { {CF_ABSPATHRANGE,cf_str,"File system directory"}, {NULL,cf_notype,NULL} }; struct FnCallArg ESCAPE_ARGS[] = { {CF_ANYSTRING,cf_str,"IP address or string to escape"}, {NULL,cf_notype,NULL} }; struct FnCallArg EXECRESULT_ARGS[] = { {CF_ABSPATHRANGE,cf_str,"Fully qualified command path"}, {"useshell,noshell",cf_opts,"Shell encapsulation option"}, {NULL,cf_notype,NULL} }; // fileexists, isdir,isplain,islink struct FnCallArg FILESTAT_ARGS[] = { {CF_ABSPATHRANGE,cf_str,"File object name"}, {NULL,cf_notype,NULL} }; struct FnCallArg FILESEXIST_ARGS[] = { {CF_NAKEDLRANGE,cf_str,"Array identifier containing list"}, {NULL,cf_notype,NULL} }; struct FnCallArg GETFIELDS_ARGS[] = { {CF_ANYSTRING,cf_str,"Regular expression to match line"}, {CF_ABSPATHRANGE,cf_str,"Filename to read"}, {CF_ANYSTRING,cf_str,"Regular expression to split fields"}, {CF_ANYSTRING,cf_str,"Return array name"}, {NULL,cf_notype,NULL} }; struct FnCallArg GETINDICES_ARGS[] = { {CF_IDRANGE,cf_str,"Cfengine array identifier"}, {NULL,cf_notype,NULL} }; struct FnCallArg GETUSERS_ARGS[] = { {CF_ANYSTRING,cf_str,"Comma separated list of User names"}, {CF_ANYSTRING,cf_str,"Comma separated list of UserID numbers"}, {NULL,cf_notype,NULL} }; struct FnCallArg GETENV_ARGS[] = { {CF_IDRANGE,cf_str,"Name of environment variable"}, {CF_VALRANGE,cf_int,"Maximum number of characters to read "}, {NULL,cf_notype,NULL} }; struct FnCallArg GETGID_ARGS[] = { {CF_ANYSTRING,cf_str,"Group name in text"}, {NULL,cf_notype,NULL} }; struct FnCallArg GETUID_ARGS[] = { {CF_ANYSTRING,cf_str,"User name in text"}, {NULL,cf_notype,NULL} }; struct FnCallArg GREP_ARGS[] = { {CF_ANYSTRING,cf_str,"Regular expression"}, {CF_IDRANGE,cf_str,"Cfengine array identifier"}, {NULL,cf_notype,NULL} }; struct FnCallArg GROUPEXISTS_ARGS[] = { {CF_ANYSTRING,cf_str,"Group name or identifier"}, {NULL,cf_notype,NULL} }; struct FnCallArg HASH_ARGS[] = { {CF_ANYSTRING,cf_str,"Input text"}, {"md5,sha1,sha256,sha512,sha384,crypt",cf_opts,"Hash or digest algorithm"}, {NULL,cf_notype,NULL} }; struct FnCallArg HASHMATCH_ARGS[] = { {CF_ABSPATHRANGE,cf_str,"Filename to hash"}, {"md5,sha1,crypt,cf_sha224,cf_sha256,cf_sha384,cf_sha512",cf_opts,"Hash or digest algorithm"}, {CF_IDRANGE,cf_str,"ASCII representation of hash for comparison"}, {NULL,cf_notype,NULL} }; struct FnCallArg HOST2IP_ARGS[] = { {CF_ANYSTRING,cf_str,"Host name in ascii"}, {NULL,cf_notype,NULL} }; struct FnCallArg IP2HOST_ARGS[] = { {CF_ANYSTRING,cf_str,"IP address (IPv4 or IPv6)"}, {NULL,cf_notype,NULL} }; struct FnCallArg HOSTINNETGROUP_ARGS[] = { {CF_ANYSTRING,cf_str,"Host name"}, {NULL,cf_notype,NULL} }; struct FnCallArg HOSTRANGE_ARGS[] = { {CF_ANYSTRING,cf_str,"Hostname prefix"}, {CF_ANYSTRING,cf_str,"Enumerated range"}, {NULL,cf_notype,NULL} }; struct FnCallArg HOSTSSEEN_ARGS[] = { {CF_VALRANGE,cf_int,"Horizon since last seen in hours"}, {"lastseen,notseen",cf_opts,"Complements for selection policy"}, {"name,address",cf_opts,"Type of return value desired"}, {NULL,cf_notype,NULL} }; struct FnCallArg IPRANGE_ARGS[] = { {CF_ANYSTRING,cf_str,"IP address range syntax"}, {NULL,cf_notype,NULL} }; struct FnCallArg IRANGE_ARGS[] = { {CF_INTRANGE,cf_int,"Integer"}, {CF_INTRANGE,cf_int,"Integer"}, {NULL,cf_notype,NULL} }; struct FnCallArg ISGREATERTHAN_ARGS[] = { {CF_ANYSTRING,cf_str,"Larger string or value"}, {CF_ANYSTRING,cf_str,"Smaller string or value"}, {NULL,cf_notype,NULL} }; struct FnCallArg ISLESSTHAN_ARGS[] = { {CF_ANYSTRING,cf_str,"Smaller string or value"}, {CF_ANYSTRING,cf_str,"Larger string or value"}, {NULL,cf_notype,NULL} }; struct FnCallArg ISNEWERTHAN_ARGS[] = { {CF_ABSPATHRANGE,cf_str,"Newer file name"}, {CF_ABSPATHRANGE,cf_str,"Older file name"}, {NULL,cf_notype,NULL} }; struct FnCallArg ISVARIABLE_ARGS[] = { {CF_IDRANGE,cf_str,"Variable identifier"}, {NULL,cf_notype,NULL} }; struct FnCallArg JOIN_ARGS[] = { {CF_ANYSTRING,cf_str,"Join glue-string"}, {CF_IDRANGE,cf_str,"Cfengine array identifier"}, {NULL,cf_notype,NULL} }; struct FnCallArg LASTNODE_ARGS[] = { {CF_ANYSTRING,cf_str,"Input string"}, {CF_ANYSTRING,cf_str,"Link separator, e.g. /,:"}, {NULL,cf_notype,NULL} }; struct FnCallArg LDAPARRAY_ARGS[] = { {CF_ANYSTRING,cf_str,"Array name"}, {CF_ANYSTRING,cf_str,"URI"}, {CF_ANYSTRING,cf_str,"Distinguished name"}, {CF_ANYSTRING,cf_str,"Filter"}, {CF_ANYSTRING,cf_str,"Record name"}, {"subtree,onelevel,base",cf_opts,"Search scope policy"}, {"none,ssl,sasl",cf_opts,"Security level"}, {NULL,cf_notype,NULL} }; struct FnCallArg LDAPLIST_ARGS[] = { {CF_ANYSTRING,cf_str,"URI"}, {CF_ANYSTRING,cf_str,"Distinguished name"}, {CF_ANYSTRING,cf_str,"Filter"}, {CF_ANYSTRING,cf_str,"Record name"}, {"subtree,onelevel,base",cf_opts,"Search scope policy"}, {"none,ssl,sasl",cf_opts,"Security level"}, {NULL,cf_notype,NULL} }; struct FnCallArg LDAPVALUE_ARGS[] = { {CF_ANYSTRING,cf_str,"URI"}, {CF_ANYSTRING,cf_str,"Distinguished name"}, {CF_ANYSTRING,cf_str,"Filter"}, {CF_ANYSTRING,cf_str,"Record name"}, {"subtree,onelevel,base",cf_opts,"Search scope policy"}, {"none,ssl,sasl",cf_opts,"Security level"}, {NULL,cf_notype,NULL} }; struct FnCallArg NOT_ARGS[] = { {CF_ANYSTRING,cf_str,"Class value"}, {NULL,cf_notype,NULL} }; struct FnCallArg NOW_ARGS[] = { {NULL,cf_notype,NULL} }; struct FnCallArg OR_ARGS[] = { {NULL,cf_notype,NULL} }; struct FnCallArg SUM_ARGS[] = { {CF_IDRANGE,cf_str,"A list of arbitrary real values"}, {NULL,cf_notype,NULL} }; struct FnCallArg PRODUCT_ARGS[] = { {CF_IDRANGE,cf_str,"A list of arbitrary real values"}, {NULL,cf_notype,NULL} }; struct FnCallArg DATE_ARGS[] = { {"1970,3000",cf_int,"Year"}, {"1,12",cf_int,"Month"}, {"1,31",cf_int,"Day"}, {"0,23",cf_int,"Hour"}, {"0,59",cf_int,"Minute"}, {"0,59",cf_int,"Second"}, {NULL,cf_notype,NULL} }; struct FnCallArg PEERS_ARGS[] = { {CF_ABSPATHRANGE,cf_str,"File name of host list"}, {CF_ANYSTRING,cf_str,"Comment regex pattern"}, {CF_VALRANGE,cf_int,"Peer group size"}, {NULL,cf_notype,NULL} }; struct FnCallArg PEERLEADER_ARGS[] = { {CF_ABSPATHRANGE,cf_str,"File name of host list"}, {CF_ANYSTRING,cf_str,"Comment regex pattern"}, {CF_VALRANGE,cf_int,"Peer group size"}, {NULL,cf_notype,NULL} }; struct FnCallArg PEERLEADERS_ARGS[] = { {CF_ABSPATHRANGE,cf_str,"File name of host list"}, {CF_ANYSTRING,cf_str,"Comment regex pattern"}, {CF_VALRANGE,cf_int,"Peer group size"}, {NULL,cf_notype,NULL} }; struct FnCallArg RANDOMINT_ARGS[] = { {CF_INTRANGE,cf_int,"Lower inclusive bound"}, {CF_INTRANGE,cf_int,"Upper inclusive bound"}, {NULL,cf_notype,NULL} }; struct FnCallArg READFILE_ARGS[] = { {CF_ABSPATHRANGE,cf_str,"File name"}, {CF_VALRANGE,cf_int,"Maximum number of bytes to read"}, {NULL,cf_notype,NULL} }; struct FnCallArg READSTRINGARRAY_ARGS[] = { {CF_IDRANGE,cf_str,"Array identifier to populate"}, {CF_ABSPATHRANGE,cf_str,"File name to read"}, {CF_ANYSTRING,cf_str,"Regex matching comments"}, {CF_ANYSTRING,cf_str,"Regex to split data"}, {CF_VALRANGE,cf_int,"Maximum number of entries to read"}, {CF_VALRANGE,cf_int,"Maximum bytes to read"}, {NULL,cf_notype,NULL} }; struct FnCallArg PARSESTRINGARRAY_ARGS[] = { {CF_IDRANGE,cf_str,"Array identifier to populate"}, {CF_ABSPATHRANGE,cf_str,"A string to parse for input data"}, {CF_ANYSTRING,cf_str,"Regex matching comments"}, {CF_ANYSTRING,cf_str,"Regex to split data"}, {CF_VALRANGE,cf_int,"Maximum number of entries to read"}, {CF_VALRANGE,cf_int,"Maximum bytes to read"}, {NULL,cf_notype,NULL} }; struct FnCallArg READSTRINGARRAYIDX_ARGS[] = { {CF_IDRANGE,cf_str,"Array identifier to populate"}, {CF_ABSPATHRANGE,cf_str,"A string to parse for input data"}, {CF_ANYSTRING,cf_str,"Regex matching comments"}, {CF_ANYSTRING,cf_str,"Regex to split data"}, {CF_VALRANGE,cf_int,"Maximum number of entries to read"}, {CF_VALRANGE,cf_int,"Maximum bytes to read"}, {NULL,cf_notype,NULL} }; struct FnCallArg PARSESTRINGARRAYIDX_ARGS[] = { {CF_IDRANGE,cf_str,"Array identifier to populate"}, {CF_ABSPATHRANGE,cf_str,"File name to read"}, {CF_ANYSTRING,cf_str,"Regex matching comments"}, {CF_ANYSTRING,cf_str,"Regex to split data"}, {CF_VALRANGE,cf_int,"Maximum number of entries to read"}, {CF_VALRANGE,cf_int,"Maximum bytes to read"}, {NULL,cf_notype,NULL} }; struct FnCallArg READSTRINGLIST_ARGS[] = { {CF_ABSPATHRANGE,cf_str,"File name to read"}, {CF_ANYSTRING,cf_str,"Regex matching comments"}, {CF_ANYSTRING,cf_str,"Regex to split data"}, {CF_VALRANGE,cf_int,"Maximum number of entries to read"}, {CF_VALRANGE,cf_int,"Maximum bytes to read"}, {NULL,cf_notype,NULL} }; struct FnCallArg READTCP_ARGS[] = { {CF_ANYSTRING,cf_str,"Host name or IP address of server socket"}, {CF_VALRANGE,cf_int,"Port number"}, {CF_ANYSTRING,cf_str,"Protocol query string"}, {CF_VALRANGE,cf_int,"Maximum number of bytes to read"}, {NULL,cf_notype,NULL} }; struct FnCallArg REGARRAY_ARGS[] = { {CF_IDRANGE,cf_str,"Cfengine array identifier"}, {CF_ANYSTRING,cf_str,"Regular expression"}, {NULL,cf_notype,NULL} }; struct FnCallArg REGCMP_ARGS[] = { {CF_ANYSTRING,cf_str,"Regular expression"}, {CF_ANYSTRING,cf_str,"Match string"}, {NULL,cf_notype,NULL} }; struct FnCallArg REGEXTRACT_ARGS[] = { {CF_ANYSTRING,cf_str,"Regular expression"}, {CF_ANYSTRING,cf_str,"Match string"}, {CF_IDRANGE,cf_str,"Identifier for back-references"}, {NULL,cf_notype,NULL} }; struct FnCallArg REGISTRYVALUE_ARGS[] = { {CF_ANYSTRING,cf_str,"Windows registry key"}, {CF_ANYSTRING,cf_str,"Windows registry value-id"}, {NULL,cf_notype,NULL} }; struct FnCallArg REGLINE_ARGS[] = { {CF_ANYSTRING,cf_str,"Regular expression"}, {CF_ANYSTRING,cf_str,"Filename to search"}, {NULL,cf_notype,NULL} }; struct FnCallArg REGLIST_ARGS[] = { {CF_NAKEDLRANGE,cf_str,"Cfengine list identifier"}, {CF_ANYSTRING,cf_str,"Regular expression"}, {NULL,cf_notype,NULL} }; struct FnCallArg REGLDAP_ARGS[] = { {CF_ANYSTRING,cf_str,"URI"}, {CF_ANYSTRING,cf_str,"Distinguished name"}, {CF_ANYSTRING,cf_str,"Filter"}, {CF_ANYSTRING,cf_str,"Record name"}, {"subtree,onelevel,base",cf_opts,"Search scope policy"}, {CF_ANYSTRING,cf_str,"Regex to match results"}, {"none,ssl,sasl",cf_opts,"Security level"}, {NULL,cf_notype,NULL} }; struct FnCallArg REMOTESCALAR_ARGS[] = { {CF_IDRANGE,cf_str,"Variable identifier"}, {CF_ANYSTRING,cf_str,"Hostname or IP address of server"}, {CF_BOOL,cf_opts,"Use enryption"}, {NULL,cf_notype,NULL} }; struct FnCallArg HUB_KNOWLEDGE_ARGS[] = { {CF_IDRANGE,cf_str,"Variable identifier"}, {NULL,cf_notype,NULL} }; struct FnCallArg REMOTECLASSESMATCHING_ARGS[] = { {CF_ANYSTRING,cf_str,"Regular expression"}, {CF_ANYSTRING,cf_str,"Server name or address"}, {CF_BOOL,cf_opts,"Use encryption"}, {CF_IDRANGE,cf_str,"Return class prefix"}, {NULL,cf_notype,NULL} }; struct FnCallArg RETURNSZERO_ARGS[] = { {CF_ABSPATHRANGE,cf_str,"Fully qualified command path"}, {"useshell,noshell",cf_opts,"Shell encapsulation option"}, {NULL,cf_notype,NULL} }; struct FnCallArg RRANGE_ARGS[] = { {CF_REALRANGE,cf_real,"Real number"}, {CF_REALRANGE,cf_real,"Real number"}, {NULL,cf_notype,NULL} }; struct FnCallArg SELECTSERVERS_ARGS[] = { {CF_NAKEDLRANGE,cf_str,"The identifier of a cfengine list of hosts or addresses to contact"}, {CF_VALRANGE,cf_int,"The port number"}, {CF_ANYSTRING,cf_str,"A query string"}, {CF_ANYSTRING,cf_str,"A regular expression to match success"}, {CF_VALRANGE,cf_int,"Maximum number of bytes to read from server"}, {CF_IDRANGE,cf_str,"Name for array of results"}, {NULL,cf_notype,NULL} }; struct FnCallArg SPLAYCLASS_ARGS[] = { {CF_ANYSTRING,cf_str,"Input string for classification"}, {"daily,hourly",cf_opts,"Splay time policy"}, {NULL,cf_notype,NULL} }; struct FnCallArg SPLITSTRING_ARGS[] = { {CF_ANYSTRING,cf_str,"A data string"}, {CF_ANYSTRING,cf_str,"Regex to split on"}, {CF_VALRANGE,cf_int,"Maximum number of pieces"}, {NULL,cf_notype,NULL} }; struct FnCallArg STRCMP_ARGS[] = { {CF_ANYSTRING,cf_str,"String"}, {CF_ANYSTRING,cf_str,"String"}, {NULL,cf_notype,NULL} }; struct FnCallArg TRANSLATEPATH_ARGS[] = { {CF_ABSPATHRANGE,cf_str,"Unix style path"}, {NULL,cf_notype,NULL} }; struct FnCallArg USEMODULE_ARGS[] = { {CF_ANYSTRING,cf_str,"Name of module command"}, {CF_ANYSTRING,cf_str,"Argument string for the module"}, {NULL,cf_notype,NULL} }; struct FnCallArg USEREXISTS_ARGS[] = { {CF_ANYSTRING,cf_str,"User name or identifier"}, {NULL,cf_notype,NULL} }; /*********************************************************/ /* FnCalls are rvalues in certain promise constraints */ /*********************************************************/ /* see cf3.defs.h enum fncalltype */ struct FnCallType CF_FNCALL_TYPES[] = { {"accessedbefore",cf_class,2,ACCESSEDBEFORE_ARGS,&FnCallIsAccessedBefore,"True if arg1 was accessed before arg2 (atime)"}, {"accumulated",cf_int,6,ACCUM_ARGS,&FnCallAccumulatedDate,"Convert an accumulated amount of time into a system representation"}, {"ago",cf_int,6,AGO_ARGS,&FnCallAgoDate,"Convert a time relative to now to an integer system representation"}, {"and",cf_str,CF_VARARGS,AND_ARGS,&FnCallAnd,"Calculate whether all arguments evaluate to true"}, {"canonify",cf_str,1,CANONIFY_ARGS,&FnCallCanonify,"Convert an abitrary string into a legal class name"}, {"concat",cf_str,CF_VARARGS,CONCAT_ARGS,&FnCallConcat,"Concatenate all arguments into string"}, {"changedbefore",cf_class,2,CHANGEDBEFORE_ARGS,&FnCallIsChangedBefore,"True if arg1 was changed before arg2 (ctime)"}, {"classify",cf_class,1,CLASSIFY_ARGS,&FnCallClassify,"True if the canonicalization of the argument is a currently defined class"}, {"classmatch",cf_class,1,CLASSMATCH_ARGS,&FnCallClassMatch,"True if the regular expression matches any currently defined class"}, {"countclassesmatching",cf_int,1,COUNTCLASSESMATCHING_ARGS,&FnCallCountClassesMatching,"Count the number of defined classes matching regex arg1"}, {"countlinesmatching",cf_int,2,COUNTLINESMATCHING_ARGS,&FnCallCountLinesMatching,"Count the number of lines matching regex arg1 in file arg2"}, {"diskfree",cf_int,1,DISKFREE_ARGS,&FnCallDiskFree,"Return the free space (in KB) available on the directory's current partition (0 if not found)"}, {"escape",cf_str,1,ESCAPE_ARGS,&FnCallEscape,"Escape regular expression characters in a string"}, {"execresult",cf_str,2,EXECRESULT_ARGS,&FnCallExecResult,"Execute named command and assign output to variable"}, {"fileexists",cf_class,1,FILESTAT_ARGS,&FnCallFileStat,"True if the named file can be accessed"}, {"filesexist",cf_class,1,FILESEXIST_ARGS,&FnCallFileSexist,"True if the named list of files can ALL be accessed"}, {"filesize",cf_int,1,FILESTAT_ARGS,&FnCallFileStat,"Returns the size in bytes of the file"}, {"getenv",cf_str,2,GETENV_ARGS,&FnCallGetEnv,"Return the environment variable named arg1, truncated at arg2 characters"}, {"getfields",cf_int,4,GETFIELDS_ARGS,&FnCallGetFields,"Get an array of fields in the lines matching regex arg1 in file arg2, split on regex arg3 as array name arg4"}, {"getgid",cf_int,1,GETGID_ARGS,&FnCallGetGid,"Return the integer group id of the named group on this host"}, {"getindices",cf_slist,1,GETINDICES_ARGS,&FnCallGetIndices,"Get a list of keys to the array whose id is the argument and assign to variable"}, {"getuid",cf_int,1,GETUID_ARGS,&FnCallGetUid,"Return the integer user id of the named user on this host"}, {"getusers",cf_slist,2,GETUSERS_ARGS,&FnCallGetUsers,"Get a list of all system users defined, minus those names defined in args 1 and uids in args"}, {"getvalues",cf_slist,1,GETINDICES_ARGS,&FnCallGetValues,"Get a list of values corresponding to the right hand sides in an array whose id is the argument and assign to variable"}, {"grep",cf_slist,2,GREP_ARGS,&FnCallGrep,"Extract the sub-list if items matching the regular expression in arg1 of the list named in arg2"}, {"groupexists",cf_class,1,GROUPEXISTS_ARGS,&FnCallGroupExists,"True if group or numerical id exists on this host"}, {"hash",cf_str,2,HASH_ARGS,&FnCallHash,"Return the hash of arg1, type arg2 and assign to a variable"}, {"hashmatch",cf_class,3,HASHMATCH_ARGS,&FnCallHashMatch,"Compute the hash of arg1, of type arg2 and test if it matches the value in arg 3"}, {"host2ip",cf_str,1,HOST2IP_ARGS,&FnCallHost2IP,"Returns the primary name-service IP address for the named host"}, {"ip2host",cf_str,1,IP2HOST_ARGS,&FnCallIP2Host,"Returns the primary name-service host name for the IP address"}, {"hostinnetgroup",cf_class,1,HOSTINNETGROUP_ARGS,&FnCallHostInNetgroup,"True if the current host is in the named netgroup"}, {"hostrange",cf_class,2,HOSTRANGE_ARGS,&FnCallHostRange,"True if the current host lies in the range of enumerated hostnames specified"}, {"hostsseen",cf_slist,3,HOSTSSEEN_ARGS,&FnCallHostsSeen,"Extract the list of hosts last seen/not seen within the last arg1 hours"}, {"hubknowledge",cf_str,1,HUB_KNOWLEDGE_ARGS,&FnCallHubKnowledge,"Read global knowledge from the hub host by id (commercial extension)"}, {"iprange",cf_class,1,IPRANGE_ARGS,&FnCallIPRange,"True if the current host lies in the range of IP addresses specified"}, {"irange",cf_irange,2,IRANGE_ARGS,&FnCallIRange,"Define a range of integer values for cfengine internal use"}, {"isdir",cf_class,1,FILESTAT_ARGS,&FnCallFileStat,"True if the named object is a directory"}, {"isexecutable",cf_class,1,FILESTAT_ARGS,&FnCallFileStat,"True if the named object has execution rights for the current user"}, {"isgreaterthan",cf_class,2,ISGREATERTHAN_ARGS,&FnCallIsLessGreaterThan,"True if arg1 is numerically greater than arg2, else compare strings like strcmp"}, {"islessthan",cf_class,2,ISLESSTHAN_ARGS,&FnCallIsLessGreaterThan,"True if arg1 is numerically less than arg2, else compare strings like NOT strcmp"}, {"islink",cf_class,1,FILESTAT_ARGS,&FnCallFileStat,"True if the named object is a symbolic link"}, {"isnewerthan",cf_class,2,ISNEWERTHAN_ARGS,&FnCallIsNewerThan,"True if arg1 is newer (modified later) than arg2 (mtime)"}, {"isplain",cf_class,1,FILESTAT_ARGS,&FnCallFileStat,"True if the named object is a plain/regular file"}, {"isvariable",cf_class,1,ISVARIABLE_ARGS,&FnCallIsVariable,"True if the named variable is defined"}, {"join",cf_str,2,JOIN_ARGS,&FnCallJoin,"Join the items of arg2 into a string, using the conjunction in arg1"}, {"lastnode",cf_str,2,LASTNODE_ARGS,&FnCallLastNode,"Extract the last of a separated string, e.g. filename from a path"}, {"laterthan",cf_class,6,LATERTHAN_ARGS,&FnCallLaterThan,"True if the current time is later than the given date"}, {"ldaparray",cf_class,6,LDAPARRAY_ARGS,&FnCallLDAPArray,"Extract all values from an ldap record"}, {"ldaplist",cf_slist,6,LDAPLIST_ARGS,&FnCallLDAPList,"Extract all named values from multiple ldap records"}, {"ldapvalue",cf_str,6,LDAPVALUE_ARGS,&FnCallLDAPValue,"Extract the first matching named value from ldap"}, {"not",cf_str,1,NOT_ARGS,&FnCallNot,"Calculate whether argument is false"}, {"now",cf_int,0,NOW_ARGS,&FnCallNow,"Convert the current time into system representation"}, {"on",cf_int,6,DATE_ARGS,&FnCallOn,"Convert an exact date/time to an integer system representation"}, {"or",cf_str,CF_VARARGS,OR_ARGS,&FnCallOr,"Calculate whether any argument evaluates to true"}, {"parseintarray",cf_int,6,PARSESTRINGARRAY_ARGS,&FnCallParseIntArray,"Read an array of integers from a file and assign the dimension to a variable"}, {"parserealarray",cf_int,6,PARSESTRINGARRAY_ARGS,&FnCallParseRealArray,"Read an array of real numbers from a file and assign the dimension to a variable"}, {"parsestringarray",cf_int,6,PARSESTRINGARRAY_ARGS,&FnCallParseStringArray,"Read an array of strings from a file and assign the dimension to a variable"}, {"parsestringarrayidx",cf_int,6,PARSESTRINGARRAYIDX_ARGS,&FnCallParseStringArrayIndex,"Read an array of strings from a file and assign the dimension to a variable with integer indeces"}, {"peers",cf_slist,3,PEERS_ARGS,&FnCallPeers,"Get a list of peers (not including ourself) from the partition to which we belong"}, {"peerleader",cf_str,3,PEERLEADER_ARGS,&FnCallPeerLeader,"Get the assigned peer-leader of the partition to which we belong"}, {"peerleaders",cf_slist,3,PEERLEADERS_ARGS,&FnCallPeerLeaders,"Get a list of peer leaders from the named partitioning"}, {"product",cf_real,1,PRODUCT_ARGS,&FnCallProduct,"Return the product of a list of reals"}, {"randomint",cf_int,2,RANDOMINT_ARGS,&FnCallRandomInt,"Generate a random integer between the given limits"}, {"readfile",cf_str,2,READFILE_ARGS,&FnCallReadFile,"Read max number of bytes from named file and assign to variable"}, {"readintarray",cf_int,6,READSTRINGARRAY_ARGS,&FnCallReadIntArray,"Read an array of integers from a file and assign the dimension to a variable"}, {"readintlist",cf_ilist,5,READSTRINGLIST_ARGS,&FnCallReadIntList,"Read and assign a list variable from a file of separated ints"}, {"readrealarray",cf_int,6,READSTRINGARRAY_ARGS,&FnCallReadRealArray,"Read an array of real numbers from a file and assign the dimension to a variable"}, {"readreallist",cf_rlist,5,READSTRINGLIST_ARGS,&FnCallReadRealList,"Read and assign a list variable from a file of separated real numbers"}, {"readstringarray",cf_int,6,READSTRINGARRAY_ARGS,&FnCallReadStringArray,"Read an array of strings from a file and assign the dimension to a variable"}, {"readstringarrayidx",cf_int,6,READSTRINGARRAYIDX_ARGS,&FnCallReadStringArrayIndex,"Read an array of strings from a file and assign the dimension to a variable with integer indeces"}, {"readstringlist",cf_slist,5,READSTRINGLIST_ARGS,&FnCallReadStringList,"Read and assign a list variable from a file of separated strings"}, {"readtcp",cf_str,4,READTCP_ARGS,&FnCallReadTcp,"Connect to tcp port, send string and assign result to variable"}, {"regarray",cf_class,2,REGARRAY_ARGS,&FnCallRegArray,"True if arg1 matches any item in the associative array with id=arg2"}, {"regcmp",cf_class,2,REGCMP_ARGS,&FnCallRegCmp,"True if arg1 is a regular expression matching that matches string arg2"}, {"regextract",cf_class,3,REGEXTRACT_ARGS,&FnCallRegExtract,"True if the regular expression in arg 1 matches the string in arg2 and sets a non-empty array of backreferences named arg3"}, {"registryvalue",cf_str,2,REGISTRYVALUE_ARGS,&FnCallRegistryValue, "Returns a value for an MS-Win registry key,value pair"}, {"regline",cf_class,2,REGLINE_ARGS,&FnCallRegLine,"True if the regular expression in arg1 matches a line in file arg2"}, {"reglist",cf_class,2,REGLIST_ARGS,&FnCallRegList,"True if the regular expression in arg2 matches any item in the list whose id is arg1"}, {"regldap",cf_class,7,REGLDAP_ARGS,&FnCallRegLDAP,"True if the regular expression in arg6 matches a value item in an ldap search"}, {"remotescalar",cf_str,3,REMOTESCALAR_ARGS,&FnCallRemoteScalar,"Read a scalar value from a remote cfengine server"}, {"remoteclassesmatching",cf_class,4,REMOTECLASSESMATCHING_ARGS,&FnCallRemoteClassesMatching,"Read persistent classes matching a regular expression from a remote cfengine server and add them into local context with prefix"}, {"returnszero",cf_class,2,RETURNSZERO_ARGS,&FnCallReturnsZero,"True if named shell command has exit status zero"}, {"rrange",cf_rrange,2,RRANGE_ARGS,&FnCallRRange,"Define a range of real numbers for cfengine internal use"}, {"selectservers",cf_int,6,SELECTSERVERS_ARGS,&FnCallSelectServers,"Select tcp servers which respond correctly to a query and return their number, set array of names"}, {"splayclass",cf_class,2,SPLAYCLASS_ARGS,&FnCallSplayClass,"True if the first argument's time-slot has arrived, according to a policy in arg2"}, {"splitstring",cf_slist,3,SPLITSTRING_ARGS,&FnCallSplitString,"Convert a string in arg1 into a list of max arg3 strings by splitting on a regular expression in arg2"}, {"strcmp",cf_class,2,STRCMP_ARGS,&FnCallStrCmp,"True if the two strings match exactly"}, {"sum",cf_real,1,SUM_ARGS,&FnCallSum,"Return the sum of a list of reals"}, {"translatepath",cf_str,1,TRANSLATEPATH_ARGS,&FnCallTranslatePath,"Translate path separators from Unix style to the host's native"}, {"usemodule",cf_class,2,USEMODULE_ARGS,&FnCallUseModule,"Execute cfengine module script and set class if successful"}, {"userexists",cf_class,1,USEREXISTS_ARGS,&FnCallUserExists,"True if user name or numerical id exists on this host"}, {NULL,cf_notype,0,NULL,NULL} }; ����������������������������cfengine-3.2.4/src/cf.events.h����������������������������������������������������������������������0000644�0001750�0001750�00000006630�11707771422�013067� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#ifndef CFENGINE_CF_EVENTS_H #define CFENGINE_CF_EVENTS_H // cf.events.mc: Definition of logging events for windows. // This file is used to generate cf.events.h and cf.events.dll as follows: // mc cf.events.mc // rc cf.events.rc // link -dll -noentry cf.events.res /MACHINE:X86 # or X64 // Save to cf.events.i686.dll or cf.events.x86_64.dll respectively // mc and rc are available from windows sdk, link from visual studio. // NOTE: Registry entry "TypesSupported" needs to be changed if the // number of messages below are changed - see EVENT_COUNT in cf.nova.h. // MessageId: EV's "Event" column // Severity: Informational / Warning / Error // // Values are 32 bit values laid out as follows: // // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 // +---+-+-+-----------------------+-------------------------------+ // |Sev|C|R| Facility | Code | // +---+-+-+-----------------------+-------------------------------+ // // where // // Sev - is the severity code // // 00 - Success // 01 - Informational // 10 - Warning // 11 - Error // // C - is the Customer code flag // // R - is a reserved bit // // Facility - is the facility code // // Code - is the facility's status code // // // Define the facility codes // // // Define the severity codes // // // MessageId: EVMSG_PROMISE_KEPT // // MessageText: // // %1A promise by %2 to %3 was already kept. Details follow.%r%r // %4%r%r // This message was generated by %5. // #define EVMSG_PROMISE_KEPT 0x40000064L // // MessageId: EVMSG_PROMISE_REPAIRED // // MessageText: // // %1A promise by %2 to %3 has been repaired. Details follow.%r%r // %4%r%r // This message was generated by %5. // #define EVMSG_PROMISE_REPAIRED 0x40000065L // // MessageId: EVMSG_PROMISE_NOT_REPAIRED_POLICY // // MessageText: // // %1A promise by %2 to %3 was not kept and has not been repaired due to // policy reasons (dry-run or action_policy set to warn). Details follow.%r%r // %4%r%r // This message was generated by %5. // #define EVMSG_PROMISE_NOT_REPAIRED_POLICY 0xC0000066L // // MessageId: EVMSG_PROMISE_NOT_REPAIRED // // MessageText: // // %1A promise by %2 to %3 was not kept and has not been repaired. Details follow.%r%r // %4%r%r // This message was generated by %5. // #define EVMSG_PROMISE_NOT_REPAIRED 0xC0000067L // // MessageId: EVMSG_REPORT // // MessageText: // // %1A report-promise follows.%r%r // %2%r%r // This message was generated by %3. // #define EVMSG_REPORT 0x40000068L // // MessageId: EVMSG_DEFAULT_INFO // // MessageText: // // %1%2%r%r // This message was generated by %3. // #define EVMSG_DEFAULT_INFO 0x40000069L // // MessageId: EVMSG_DEFAULT_VERBOSE // // MessageText: // // %1%2%r%r // This message was generated by %3. // #define EVMSG_DEFAULT_VERBOSE 0x4000006AL // // MessageId: EVMSG_DEFAULT_WARN // // MessageText: // // %1%2%r%r // This message was generated by %3. // #define EVMSG_DEFAULT_WARN 0x8000006BL // // MessageId: EVMSG_DEFAULT_ERROR // // MessageText: // // %1%2%r%r // This message was generated by %3. // #define EVMSG_DEFAULT_ERROR 0xC000006CL #endif ��������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/cfstream.c�����������������������������������������������������������������������0000644�0001750�0001750�00000027247�11715232734�012777� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ /* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /*****************************************************************************/ /* */ /* File: cfstream.c */ /* */ /*****************************************************************************/ #include "cf3.defs.h" #include "cf3.extern.h" #include <stdarg.h> /*****************************************************************************/ static void MakeReport(struct Item *mess,int prefix); static void FileReport(struct Item *mess,int prefix,char *filename); static void MakeLog(struct Item *mess,enum cfreport level); #ifndef MINGW static void Unix_MakeLog(struct Item *mess,enum cfreport level); #endif /* NOT MINGW */ /*****************************************************************************/ void CfFOut(char *filename,enum cfreport level,char *errstr,char *fmt, ...) { va_list ap; char buffer[CF_BUFSIZE],output[CF_BUFSIZE],expand[CF_EXPANDSIZE]; struct Item *mess = NULL; if ((fmt == NULL) || (strlen(fmt) == 0)) { return; } memset(output,0,CF_BUFSIZE); va_start(ap,fmt); vsnprintf(buffer,CF_BUFSIZE-1,fmt,ap); va_end(ap); ExpandThis(level,buffer,expand); Chop(expand); AppendItem(&mess,expand,NULL); if ((errstr == NULL) || (strlen(errstr) > 0)) { snprintf(output,CF_BUFSIZE-1," !!! System reports error for %s: \"%s\"",errstr,GetErrorStr()); AppendItem(&mess,output,NULL); } switch(level) { case cf_inform: if (INFORM || VERBOSE || DEBUG) { FileReport(mess,VERBOSE,filename); } break; case cf_verbose: if (VERBOSE || DEBUG) { FileReport(mess,VERBOSE,filename); } break; case cf_error: case cf_reporting: case cf_cmdout: FileReport(mess,VERBOSE,filename); MakeLog(mess,level); break; case cf_log: if (VERBOSE || DEBUG) { FileReport(mess,VERBOSE,filename); } MakeLog(mess,cf_verbose); break; default: FatalError("Report level unknown"); break; } DeleteItemList(mess); } /*****************************************************************************/ void CfOut(enum cfreport level, const char *errstr, const char *fmt, ...) { va_list ap; char buffer[CF_BUFSIZE],output[CF_BUFSIZE],expand[CF_EXPANDSIZE]; struct Item *mess = NULL; if ((fmt == NULL) || (strlen(fmt) == 0)) { return; } memset(output,0,CF_BUFSIZE); va_start(ap,fmt); vsnprintf(buffer,CF_BUFSIZE-1,fmt,ap); va_end(ap); ExpandThis(level,buffer,expand); Chop(expand); AppendItem(&mess,expand,NULL); if ((errstr == NULL) || (strlen(errstr) > 0)) { snprintf(output,CF_BUFSIZE-1," !!! System error for %s: \"%s\"",errstr,GetErrorStr()); AppendItem(&mess,output,NULL); } switch(level) { case cf_inform: if (INFORM || VERBOSE || DEBUG) { MakeReport(mess,VERBOSE); } break; case cf_verbose: if (VERBOSE || DEBUG) { MakeReport(mess,VERBOSE); } break; case cf_error: case cf_reporting: case cf_cmdout: MakeReport(mess,VERBOSE); MakeLog(mess,level); break; case cf_log: if (VERBOSE || DEBUG) { MakeReport(mess,VERBOSE); } MakeLog(mess,cf_verbose); break; default: FatalError("Report level unknown"); break; } DeleteItemList(mess); } /*****************************************************************************/ void cfPS(enum cfreport level,char status,char *errstr,struct Promise *pp,struct Attributes attr,char *fmt, ...) { va_list ap; char rettype,*sp,buffer[CF_BUFSIZE],output[CF_BUFSIZE],*v,handle[CF_MAXVARSIZE],expand[CF_EXPANDSIZE]; struct Item *ip,*mess = NULL; int verbose; struct Rlist *rp; void *retval; if ((fmt == NULL) || (strlen(fmt) == 0)) { return; } va_start(ap,fmt); vsnprintf(buffer,CF_BUFSIZE-1,fmt,ap); va_end(ap); ExpandThis(status,buffer,expand); Chop(expand); AppendItem(&mess,expand,NULL); if ((errstr == NULL) || (strlen(errstr) > 0)) { snprintf(output,CF_BUFSIZE-1," !!! System reports error for %s: \"%s\"",errstr,GetErrorStr()); AppendItem(&mess,output,NULL); } if (level == cf_error) { if (GetVariable("control_common","version",&retval,&rettype) != cf_notype) { v = (char *)retval; } else { v = "not specified"; } if ((sp = GetConstraint("handle",pp,CF_SCALAR)) || (sp = PromiseID(pp))) { strncpy(handle,sp,CF_MAXVARSIZE-1); } else { strcpy(handle,"(unknown)"); } if (INFORM || VERBOSE || DEBUG) { snprintf(output,CF_BUFSIZE-1,"I: Report relates to a promise with handle \"%s\"",handle); AppendItem(&mess,output,NULL); } if (pp && pp->audit) { snprintf(output,CF_BUFSIZE-1,"I: Made in version \'%s\' of \'%s\' near line %d",v,pp->audit->filename,pp->lineno); } else { snprintf(output,CF_BUFSIZE-1,"I: Promise is made internally by cfengine"); } AppendItem(&mess,output,NULL); if (pp != NULL) { switch (pp->petype) { case CF_SCALAR: snprintf(output,CF_BUFSIZE-1,"I: The promise was made to: \'%s\'\n",pp->promisee); AppendItem(&mess,output,NULL); break; case CF_LIST: CfOut(level,"","I: The promise was made to: \n"); for (rp = (struct Rlist *)pp->promisee; rp != NULL; rp=rp->next) { snprintf(output,CF_BUFSIZE-1,"I: \'%s\'\n",rp->item); AppendItem(&mess,output,NULL); } break; } if (pp->ref) { snprintf(output,CF_BUFSIZE-1,"I: Comment: %s\n",pp->ref); AppendItem(&mess,output,NULL); } } } verbose = (attr.transaction.report_level == cf_verbose) || VERBOSE; switch(level) { case cf_inform: if (INFORM || verbose || DEBUG || attr.transaction.report_level == cf_inform) { MakeReport(mess,verbose); } if (attr.transaction.log_level == cf_inform) { MakeLog(mess,level); } break; case cf_reporting: case cf_cmdout: if (attr.report.to_file) { FileReport(mess,verbose,attr.report.to_file); } else { MakeReport(mess,verbose); } if (attr.transaction.log_level == cf_inform) { MakeLog(mess,level); } break; case cf_verbose: if (verbose || DEBUG) { MakeReport(mess,verbose); } if (attr.transaction.log_level == cf_verbose) { MakeLog(mess,level); } break; case cf_error: if (attr.report.to_file) { FileReport(mess,verbose,attr.report.to_file); } else { MakeReport(mess,verbose); } if (attr.transaction.log_level == cf_error) { MakeLog(mess,level); } break; case cf_log: MakeLog(mess,level); break; default: break; } #ifdef MINGW if(pp != NULL) { NovaWin_LogPromiseResult(pp->promiser, pp->petype, pp->promisee, status, attr.transaction.log_level, mess); } #endif /* Now complete the exits status classes and auditing */ if (pp != NULL) { for (ip = mess; ip != NULL; ip = ip->next) { ClassAuditLog(pp,attr,ip->name,status,buffer); } } DeleteItemList(mess); } /*********************************************************************************/ void CfFile(FILE *fp,char *fmt, ...) { va_list ap; char buffer[CF_BUFSIZE]; if ((fmt == NULL) || (strlen(fmt) == 0)) { return; } va_start(ap,fmt); vsnprintf(buffer,CF_BUFSIZE-1,fmt,ap); va_end(ap); if (!ThreadLock(cft_output)) { return; } fprintf(fp,"%s> %s",VPREFIX,buffer); ThreadUnlock(cft_output); } /*********************************************************************************/ /* Level */ /*********************************************************************************/ static void MakeReport(struct Item *mess,int prefix) { struct Item *ip; for (ip = mess; ip != NULL; ip = ip->next) { ThreadLock(cft_report); if (prefix) { printf("%s> %s\n",VPREFIX,ip->name); } else { printf("%s\n",ip->name); } ThreadUnlock(cft_report); } } /*********************************************************************************/ static void FileReport(struct Item *mess,int prefix,char *filename) { struct Item *ip; FILE *fp; if ((fp = fopen(filename,"a")) == NULL) { CfOut(cf_error,"fopen","Could not open log file %s\n",filename); fp = stdout; } for (ip = mess; ip != NULL; ip = ip->next) { ThreadLock(cft_output); if (prefix) { fprintf(fp,"%s> %s\n",VPREFIX,ip->name); } else { fprintf(fp,"%s\n",ip->name); } ThreadUnlock(cft_output); } if (fp != stdout) { fclose(fp); } } /*********************************************************************************/ char *GetErrorStr(void) { #ifdef MINGW return NovaWin_GetErrorStr(); #else return Unix_GetErrorStr(); #endif } /*********************************************************************************/ static void MakeLog(struct Item *mess,enum cfreport level) { #ifdef MINGW NovaWin_MakeLog(mess, level); #else Unix_MakeLog(mess, level); #endif } /*********************************************************************************/ #ifndef MINGW static void Unix_MakeLog(struct Item *mess,enum cfreport level) { struct Item *ip; if (!IsPrivileged() || DONTDO) { return; } /* If we can't mutex it could be dangerous to proceed with threaded file descriptors */ if (!ThreadLock(cft_output)) { return; } for (ip = mess; ip != NULL; ip = ip->next) { switch (level) { case cf_inform: case cf_reporting: case cf_cmdout: syslog(LOG_NOTICE," %s",ip->name); break; case cf_verbose: syslog(LOG_INFO," %s",ip->name); break; case cf_error: syslog(LOG_ERR," %s",ip->name); break; default: break; } } ThreadUnlock(cft_output); } #endif /* NOT MINGW */ ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/src/logic_expressions.c��������������������������������������������������������������0000644�0001750�0001750�00000014556�11715232734�014731� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifdef HAVE_CONFIG_H # include <conf.h> #endif #include <stdlib.h> #include "bool.h" #include "logic_expressions.h" #include "cf3.defs.h" #include "prototypes3.h" /* <primary> */ static ParseResult ParsePrimary(const char *expr, int start, int end) { if (start < end && expr[start] == '(') { ParseResult res = ParseExpression(expr, start + 1, end); if (res.result) { /* Check there is a matching ')' at the end */ if (res.position < end && expr[res.position] == ')') { return (ParseResult){ res.result, res.position + 1 }; } else { /* Didn't find a matching bracket. Give up */ FreeExpression(res.result); return (ParseResult) { NULL, res.position }; } } else { return res; } } else { StringParseResult strres = ParseStringExpression(expr, start, end); if (strres.result) { Expression *res = calloc(1, sizeof(Expression)); res->op = EVAL; res->val.eval.name = strres.result; return (ParseResult) { res, strres.position }; } else { return (ParseResult) { NULL, strres.position }; } } } /* <not-expr> */ static ParseResult ParseNotExpression(const char *expr, int start, int end) { if (start < end && expr[start] == '!') { ParseResult primres = ParsePrimary(expr, start + 1, end); if (primres.result) { Expression *res = calloc(1, sizeof(Expression)); res->op = NOT; res->val.not.arg = primres.result; return (ParseResult) { res, primres.position }; } else { return primres; } } else { return ParsePrimary(expr, start, end); } } /* <and-expr> */ static ParseResult ParseAndExpression(const char *expr, int start, int end) { ParseResult lhs, rhs; Expression *res; lhs = ParseNotExpression(expr, start, end); if (!lhs.result) { return lhs; } if (lhs.position == end || (expr[lhs.position] != '.' && expr[lhs.position] != '&')) { return lhs; } rhs = ParseAndExpression(expr, lhs.position + 1, end); if (!rhs.result) { FreeExpression(lhs.result); return rhs; } res = calloc(1, sizeof(Expression)); res->op = AND; res->val.andor.lhs = lhs.result; res->val.andor.rhs = rhs.result; return (ParseResult){ res, rhs.position }; } /* <or-expr> */ ParseResult ParseExpression(const char *expr, int start, int end) { ParseResult lhs, rhs; Expression *res; int position; lhs = ParseAndExpression(expr, start, end); if (!lhs.result) { return lhs; } /* End of left-hand side expression */ position = lhs.position; if (position == end || expr[position] != '|') { return lhs; } /* Skip second '|' in 'lhs||rhs' */ if (position + 1 < end && expr[position + 1] == '|') { position++; } rhs = ParseExpression(expr, position + 1, end); if (!rhs.result) { FreeExpression(lhs.result); return rhs; } res = calloc(1, sizeof(Expression)); res->op = OR; res->val.andor.lhs = lhs.result; res->val.andor.rhs = rhs.result; return (ParseResult) { res, rhs.position }; } /* Evaluation */ ExpressionValue EvalExpression(const Expression *expr, NameEvaluator nameevalfn, VarRefEvaluator varrefevalfn, void *param) { switch (expr->op) { case OR: case AND: { ExpressionValue lhs = EvalExpression(expr->val.andor.lhs, nameevalfn, varrefevalfn, param); if (lhs == EXP_ERROR) { return EXP_ERROR; } ExpressionValue rhs = EvalExpression(expr->val.andor.rhs, nameevalfn, varrefevalfn, param); if (rhs == EXP_ERROR) { return EXP_ERROR; } if (expr->op == OR) { return lhs || rhs; } else { return lhs && rhs; } } case NOT: { ExpressionValue arg = EvalExpression(expr->val.not.arg, nameevalfn, varrefevalfn, param); if (arg == EXP_ERROR) { return EXP_ERROR; } else { return !arg; } } case EVAL: { char *name = EvalStringExpression(expr->val.eval.name, varrefevalfn, param); if (name == NULL) { return EXP_ERROR; } ExpressionValue ret = (*nameevalfn)(name, param); free(name); return ret; } default: FatalError("Unexpected class expression type is found: %d", expr->op); } } /* Freeing results */ void FreeExpression(Expression *e) { if (!e) { return; } switch (e->op) { case OR: case AND: FreeExpression(e->val.andor.lhs); FreeExpression(e->val.andor.rhs); break; case NOT: FreeExpression(e->val.not.arg); break; case EVAL: FreeStringExpression(e->val.eval.name); break; default: FatalError("Unknown logic expression type encountered in" "FreeExpression: %d", e->op); } free(e); } ��������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/ylwrap�������������������������������������������������������������������������������0000755�0001750�0001750�00000014357�11715232775�011507� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#! /bin/sh # ylwrap - wrapper for lex/yacc invocations. scriptversion=2011-08-25.18; # UTC # Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, # 2007, 2009, 2010, 2011 Free Software Foundation, Inc. # # Written by Tom Tromey <tromey@cygnus.com>. # # 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 <http://www.gnu.org/licenses/>. # 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 <bug-automake@gnu.org> or send patches to # <automake-patches@gnu.org>. 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 <bug-automake@gnu.org>. 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$$ do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 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: ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/Makefile.am��������������������������������������������������������������������������0000644�0001750�0001750�00000003612�11715232733�012261� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AUTOMAKE_OPTIONS = foreign SUBDIRS = pub $(NOVA_SUBDIR) $(CONSTELLATION_SUBDIR) src docs examples masterfiles $(CFMOD_SUBDIR) DIST_SUBDIRS = pub src docs examples masterfiles # Set explicitly to avoid picking up {nova,constellation,galaxy}/*.m4 DIST_COMMON = README Makefile.am Makefile.in configure AUTHORS aclocal.m4 \ ChangeLog INSTALL config.guess config.sub depcomp install-sh \ ltmain.sh missing ylwrap m4/acinclude.m4 m4/libtool.m4 m4/ltoptions.m4 \ m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 m4/cf3_with_library.m4 \ configure.ac autogen.sh EXTRA_DIST = ChangeLog INSTALL README LICENSE docdir = @docdir@ doc_DATA = README ChangeLog # # Some basic clean ups # MOSTLYCLEANFILES = *~ # # Get everything removed down to where rebuilding requires: # "make; make install" # CLEANFILES = # # Get everything removed down to where rebuilding requires: # "configure; make; make install" # DISTCLEANFILES = # # Get everything removed down to where rebuilding requires: # "aclocal; autoconf; autoheader; automake --add-missing" # "configure; make; make install" # MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.sub \ configure install-sh missing mkinstalldirs depcomp ylwrap \ ltmain.sh mdate-sh # # Pass proper flags to aclocal to pick up Libtool macros # ACLOCAL_AMFLAGS = -I m4 check: @echo "In order to run testsuite, you need to run the following command:" @echo " cd tests; ./testall --agent=\$workdir/bin/cf-agent" @echo "where \$workdir is the work directory for CFEngine (/var/cfengine by default)." @echo @echo "You need to have sudo to run testsuite (in order to test functionality which" @echo "is only available to root). Refer to $(srcdir)/tests/README for further info." dist-hook: mkdir $(distdir)/tests (cd $(srcdir)/tests && find . -name README -o -name testall -o -name '*.cf*' -a \! -path '*succeeded*' | tar -c -f - -T-) | tar -x -C $(distdir)/tests -v -f - ����������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/config.sub���������������������������������������������������������������������������0000755�0001750�0001750�00000104606�11715232774�012222� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#! /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, # 2011 Free Software Foundation, Inc. timestamp='2011-03-23' # 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 <config-patches@gnu.org>. 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 <config-patches@gnu.org>." 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, 2011 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-android* | 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 \ | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | 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 \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-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 ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-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-* \ | 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-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | 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-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile-* | tilegx-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | 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 ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; 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 | 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 ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; 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 | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) 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 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; 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 ;; # 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 ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; 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-android* \ | -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 ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) 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: ��������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/autogen.sh���������������������������������������������������������������������������0000755�0001750�0001750�00000001405�11715232733�012224� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/sh srcdir=$(dirname $0) test -z "$srcdir" && srcdir=. ORIGDIR=$(pwd) cd $srcdir if [ -z "$NO_SUBPROJECTS" ]; then # # Include nova/constellation # if [ -d ${srcdir}/../nova ]; then if [ -h ${srcdir}/nova ]; then rm -f ${srcdir}/nova fi ln -sf ${srcdir}/../nova ${srcdir}/nova fi if [ -d ${srcdir}/../constellation ]; then if [ -h ${srcdir}/constellation ]; then rm -f ${srcdir}/constellation fi ln -sf ${srcdir}/../constellation ${srcdir}/constellation fi else # # Clean up just in case # rm -f ${srcdir}/nova rm -f ${srcdir}/constellation fi autoreconf --force -v --install -I m4 || exit 1 cd $ORIGDIR || exit $? if [ -z "$NO_CONFIGURE" ]; then $srcdir/configure --enable-maintainer-mode "$@" fi �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/README�������������������������������������������������������������������������������0000644�0001750�0001750�00000000605�11715232733�011104� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ PLEASE READ THIS CAREFULLY This is version of cfengine 3. Please read the documentation carefully before installing it. This software is NOT a drop-in upgrade for cfengine 2 installations. It is a significantly more powerful version of cfengine which offers a path to upgrading gradually while supporting an existing cfengine 2 base. Please see the INSTALL file for build instructions. ���������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/aclocal.m4���������������������������������������������������������������������������0000644�0001750�0001750�00000112704�11715232772�012073� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# generated automatically by aclocal 1.11.2 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009, 2010, 2011 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.68],, [m4_warning([this file was generated for autoconf 2.68. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 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_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.2], [], [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.2])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, 2011 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 # 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, # 2010, 2011 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 12 # 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'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 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 ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --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='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 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, 2011 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_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]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering # Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008, # 2011 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_MAINTAINER_MODE([DEFAULT-MODE]) # ---------------------------------- # Control maintainer-specific portions of Makefiles. # Default is to disable them, unless `enable' is passed literally. # For symmetry, `disable' may be passed as well. Anyway, the user # can override the default with the --enable/--disable switch. AC_DEFUN([AM_MAINTAINER_MODE], [m4_case(m4_default([$1], [disable]), [enable], [m4_define([am_maintainer_other], [disable])], [disable], [m4_define([am_maintainer_other], [enable])], [m4_define([am_maintainer_other], [enable]) m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) dnl maintainer-mode's default is 'disable' unless 'enable' is passed AC_ARG_ENABLE([maintainer-mode], [ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful (and sometimes confusing) to the casual installer], [USE_MAINTAINER_MODE=$enableval], [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) AC_MSG_RESULT([$USE_MAINTAINER_MODE]) AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) MAINT=$MAINTAINER_MODE_TRUE AC_SUBST([MAINT])dnl ] ) AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) # 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 ]) # 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, 2011 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_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, 2010 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_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])]) # 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, 2011 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_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, 2010 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 3 # _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 <conftest.tar]) grep GrepMe conftest.dir/file >/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/acinclude.m4]) m4_include([m4/cf3_with_library.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]) ������������������������������������������������������������cfengine-3.2.4/depcomp������������������������������������������������������������������������������0000755�0001750�0001750�00000047556�11715232775�011627� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2011-12-04.11; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, # 2011 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 <http://www.gnu.org/licenses/>. # 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 <oliva@dcc.unicamp.br>. case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to <bug-automake@gnu.org>. 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 if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi 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. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -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" ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test "$stat" = 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/ \1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/ / G p }' >> "$depfile" rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$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" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 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: ��������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/Makefile.in��������������������������������������������������������������������������0000644�0001750�0001750�00000067606�11715232775�012315� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Makefile.in generated by automake 1.11.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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@ target_triplet = @target@ DIST_COMMON = README AUTHORS ChangeLog INSTALL Makefile.am Makefile.in \ aclocal.m4 autogen.sh config.guess config.sub configure \ configure.ac depcomp install-sh ltmain.sh m4/acinclude.m4 \ m4/cf3_with_library.m4 m4/libtool.m4 m4/ltoptions.m4 \ m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 missing ylwrap subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \ $(top_srcdir)/m4/cf3_with_library.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 = $(top_builddir)/src/conf.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' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(docdir)" DATA = $(doc_DATA) 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 am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BERKELEYDB_CFLAGS = @BERKELEYDB_CFLAGS@ BERKELEYDB_LDFLAGS = @BERKELEYDB_LDFLAGS@ BERKELEYDB_LIBS = @BERKELEYDB_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EIGHTBIT = @EIGHTBIT@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GCC_CFLAG = @GCC_CFLAG@ GETCONF = @GETCONF@ GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ GREP = @GREP@ HOSTNAME = @HOSTNAME@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ KMEM_GROUP = @KMEM_GROUP@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_SELINUX = @LIB_SELINUX@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MYSQL_CFLAGS = @MYSQL_CFLAGS@ MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@ MYSQL_LDFLAGS = @MYSQL_LDFLAGS@ MYSQL_LIBS = @MYSQL_LIBS@ MYSQL_PATH = @MYSQL_PATH@ NEED_SETGID = @NEED_SETGID@ NM = @NM@ NMEDIT = @NMEDIT@ NOWRAP = @NOWRAP@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_CPPFLAGS = @OPENSSL_CPPFLAGS@ OPENSSL_LDFLAGS = @OPENSSL_LDFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OPENSSL_PATH = @OPENSSL_PATH@ 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@ PCRE_CFLAGS = @PCRE_CFLAGS@ PCRE_CPPFLAGS = @PCRE_CPPFLAGS@ PCRE_LDFLAGS = @PCRE_LDFLAGS@ PCRE_LIBS = @PCRE_LIBS@ PCRE_PATH = @PCRE_PATH@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_CPPFLAGS = @POSTGRESQL_CPPFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_LIBS = @POSTGRESQL_LIBS@ POSTGRESQL_PATH = @POSTGRESQL_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ TOKYOCABINET_CFLAGS = @TOKYOCABINET_CFLAGS@ TOKYOCABINET_CPPFLAGS = @TOKYOCABINET_CPPFLAGS@ TOKYOCABINET_LDFLAGS = @TOKYOCABINET_LDFLAGS@ TOKYOCABINET_LIBS = @TOKYOCABINET_LIBS@ TOKYOCABINET_PATH = @TOKYOCABINET_PATH@ 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_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ workdir = @workdir@ AUTOMAKE_OPTIONS = foreign SUBDIRS = pub $(NOVA_SUBDIR) $(CONSTELLATION_SUBDIR) src docs examples masterfiles $(CFMOD_SUBDIR) DIST_SUBDIRS = pub src docs examples masterfiles EXTRA_DIST = ChangeLog INSTALL README LICENSE doc_DATA = README ChangeLog # # Some basic clean ups # MOSTLYCLEANFILES = *~ # # Get everything removed down to where rebuilding requires: # "make; make install" # CLEANFILES = # # Get everything removed down to where rebuilding requires: # "configure; make; make install" # DISTCLEANFILES = # # Get everything removed down to where rebuilding requires: # "aclocal; autoconf; autoheader; automake --add-missing" # "configure; make; make install" # MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.sub \ configure install-sh missing mkinstalldirs depcomp ylwrap \ ltmain.sh mdate-sh # # Pass proper flags to aclocal to pick up Libtool macros # ACLOCAL_AMFLAGS = -I m4 all: all-recursive .SUFFIXES: am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt install-docDATA: $(doc_DATA) @$(NORMAL_INSTALL) test -z "$(docdir)" || $(MKDIR_P) "$(DESTDIR)$(docdir)" @list='$(doc_DATA)'; test -n "$(docdir)" || 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)$(docdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ done uninstall-docDATA: @$(NORMAL_UNINSTALL) @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) # 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) $(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 $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook -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=$${BZIP2--9} bzip2 -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_OPT=$${XZ_OPT--e} 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 a+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" \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(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: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile $(DATA) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(docdir)"; 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) 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) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) 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 "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) 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-libtool \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-docDATA 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 $(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-docDATA .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 am--refresh check check-am clean clean-generic \ clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \ dist-gzip dist-hook dist-lzma dist-shar dist-tarZ dist-xz \ dist-zip distcheck distclean distclean-generic \ 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-docDATA 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 uninstall-docDATA check: @echo "In order to run testsuite, you need to run the following command:" @echo " cd tests; ./testall --agent=\$workdir/bin/cf-agent" @echo "where \$workdir is the work directory for CFEngine (/var/cfengine by default)." @echo @echo "You need to have sudo to run testsuite (in order to test functionality which" @echo "is only available to root). Refer to $(srcdir)/tests/README for further info." dist-hook: mkdir $(distdir)/tests (cd $(srcdir)/tests && find . -name README -o -name testall -o -name '*.cf*' -a \! -path '*succeeded*' | tar -c -f - -T-) | tar -x -C $(distdir)/tests -v -f - # 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: ��������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/INSTALL������������������������������������������������������������������������������0000644�0001750�0001750�00000004052�11715232733�011255� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PREREQUISITES ------------- In order to build CFEngine you need the following tools and libraries installed: * gcc >= 3.0 [CFEngine uses several C99 constructs, so gcc 2.95 is not up to the task anymore] * GNU make * OpenSSL library * PCRE library * POSIX threads (pthreads) library, if not provided by the operating system * - Berkeley DB, or - Tokyo Cabinet, or - QDBM * MySQL client library (optional) * PostgreSQL client library (optional) * SELinux library (optional) In order to build CFEngine checked out from Subversion, you need the following additional tools to regenerate build scripts and generate source code files: * GNU Automake * GNU Autoconf >= 2.59 * GNU Libtool >= 1.5.4 * Yacc * Lex Latest stable versions of the tools and libraries are generally advised. OPERATING SYSTEMS ----------------- CFEngine is regularely built and tested on the following operating systems: * GNU/Linux (many distributions) * FreeBSD * NetBSD * Solaris HARDWARE PLATFORMS ------------------ CFEngine is regularely built and tested on the following CPU architectures: * x86 * x86-64 * SPARC OTHER CONFIGURATIONS -------------------- In case you have succesfully compiled CFEngine on a different OS and/or using different tools or versions of tools, please report it to help-cfengine@ mailing list[1]. Please consider running a testsuite (see below), and posting results to mailing list too. [1] https://cfengine.org/mailman/listinfo/help-cfengine BUILD INSTRUCTIONS ------------------ From tarball: $ ./configure [configure options] $ make [-jN] From Subversion checkout: $ ./autogen.sh [configure options] $ make [-jN] See the available configure options: $ ./configure --help or $ ./autogen.sh --help RUNNING TESTSUITE ----------------- $ ./configure --prefix=/var/cfengine $ make [-jN] $ sudo make install $ cd tests $ ./testall In meantime testsuite needs sudo permissions to run (due to testing various functionality available only for superuser). This might change in future. Results are generated in test.log (short) and testresult.log (detailed) files. ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/ltmain.sh����������������������������������������������������������������������������0000644�0001750�0001750�00001052022�11715232770�012046� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ # libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010, 2011 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 # --no-quiet, --no-silent # print informational messages (default) # --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed 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. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # 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.4.2 Debian-2.4.2-1 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to <bug-libtool@gnu.org>. # GNU libtool home page: <http://www.gnu.org/software/libtool/>. # General help using GNU software: <http://www.gnu.org/gethelp/>. PROGRAM=libtool PACKAGE=libtool VERSION="2.4.2 Debian-2.4.2-1" TIMESTAMP="" package_revision=1.3337 # 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 # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. 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 LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # 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" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${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 file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # 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 "${1}" | $SED -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 "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # 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 "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # 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=${PATH_SEPARATOR-:} 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' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|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: ${opt_mode+$opt_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_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_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 "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED '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 "$my_tmpdir" } # 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 "$1" | $SED "$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 "$1" | $SED \ -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_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$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 () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print 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-automake} --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # 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= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_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 $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/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 } # 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 } # 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 # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_warning=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg 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 shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-warning|--no-warn) opt_warning=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" 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_preserve_dup_deps ;; esac $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 # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_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=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # 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_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # 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_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$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_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` 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 "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # 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_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # 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 <<EOF # $write_libobj - a libtool object file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # Name of the PIC object. pic_object=$write_lobj # Name of the non-PIC object non_pic_object=$write_oldobj EOF $MV "${write_libobj}T" "${write_libobj}" } } ################################################## # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # ################################################## # func_convert_core_file_wine_to_w32 ARG # Helper function used by file name conversion functions when $build is *nix, # and $host is mingw, cygwin, or some other w32 environment. Relies on a # correctly configured wine environment available, with the winepath program # in $build's $PATH. # # ARG is the $build file name to be converted to w32 format. # Result is available in $func_convert_core_file_wine_to_w32_result, and will # be empty on error (or when ARG is empty) func_convert_core_file_wine_to_w32 () { $opt_debug func_convert_core_file_wine_to_w32_result="$1" if test -n "$1"; then # 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_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # 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. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # 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_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # 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_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && 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 "$srcfile" | $SED 's%^.*/%%; 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 func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result 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 func_append 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 func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append 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 "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_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 build PIC objects only -prefer-non-pic try to build 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 -Wc,FLAG pass FLAG directly to the compiler 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-dir 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 -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -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 -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 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 \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # 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 $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # 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 func_append 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 -* | *.la | *.lo ) ;; *) # 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_append_quoted args "$file" 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 "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 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" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 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" 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 "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test "$opt_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. case $nonopt in *shtool*) :;; *) false;; esac; 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" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_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 -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi 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. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # 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 "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -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 "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "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_shared_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" && func_append 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 "$lib" | $SED '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 "$relink_command" | $SED '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 "$file$stripped_ext" | $SED "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_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_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 "$opt_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 #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #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 "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $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" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen <import library>. $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac 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 >/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; 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) ;; *) func_append 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 "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "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 "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "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. # Despite the name, also deal with 64 bit binaries. 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 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $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_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # 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" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi 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 | sort | $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 | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # 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=${1-no} $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. 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 file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED '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 \"\$file\" | $SED '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 \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_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 \"\$thisdir\" | $SED '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" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # 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 \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${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\ " } # 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 <<EOF /* $cwrappersource - temporary wrapper executable 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 executable should never be moved out of the build directory. If it is, it will not operate correctly. */ EOF cat <<"EOF" #ifdef _MSC_VER # define _CRT_SECURE_NO_DEPRECATE 1 #endif #include <stdio.h> #include <stdlib.h> #ifdef _MSC_VER # include <direct.h> # include <process.h> # include <io.h> #else # include <unistd.h> # include <stdint.h> # ifdef __CYGWIN__ # include <io.h> # endif #endif #include <malloc.h> #include <stdarg.h> #include <assert.h> #include <string.h> #include <ctype.h> #include <errno.h> #include <fcntl.h> #include <sys/stat.h> /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #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 /* path handling portability macros */ #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 */ #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) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 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_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); 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_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <<EOF volatile const char * MAGIC_EXE = "$magic_exe"; const char * LIB_PATH_VARNAME = "$shlibpath_var"; EOF if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then func_to_host_path "$temp_rpath" cat <<EOF const char * LIB_PATH_VALUE = "$func_to_host_path_result"; EOF else cat <<"EOF" const char * LIB_PATH_VALUE = ""; EOF fi if test -n "$dllsearchpath"; then func_to_host_path "$dllsearchpath:" cat <<EOF const char * EXE_PATH_VARNAME = "PATH"; const char * EXE_PATH_VALUE = "$func_to_host_path_result"; EOF else cat <<"EOF" const char * EXE_PATH_VARNAME = ""; const char * EXE_PATH_VALUE = ""; EOF fi if test "$fast_install" = yes; then cat <<EOF const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ EOF else cat <<EOF const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ EOF fi cat <<"EOF" #define LTWRAPPER_OPTION_PREFIX "--lt-" static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; int main (int argc, char *argv[]) { char **newargz; int newargc; char *tmp_pathspec; char *actual_cwrapper_path; char *actual_cwrapper_name; char *target_name; char *lt_argv_zero; intptr_t rval = 127; int i; program_name = (char *) xstrdup (base_name (argv[0])); newargz = XMALLOC (char *, argc + 1); /* very simple arg parsing; don't want to rely on getopt * also, copy all non cwrapper options to newargz, except * argz[0], which is handled differently */ newargc=0; for (i = 1; i < argc; i++) { if (strcmp (argv[i], dumpscript_opt) == 0) { EOF case "$host" in *mingw* | *cygwin* ) # make stdout use "unix" line endings echo " setmode(1,_O_BINARY);" ;; esac cat <<"EOF" lt_dump_script (stdout); return 0; } if (strcmp (argv[i], debug_opt) == 0) { lt_debug = 1; continue; } if (strcmp (argv[i], ltwrapper_option_prefix) == 0) { /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX namespace, but it is not one of the ones we know about and have already dealt with, above (inluding dump-script), then report an error. Otherwise, targets might begin to believe they are allowed to use options in the LTWRAPPER_OPTION_PREFIX namespace. The first time any user complains about this, we'll need to make LTWRAPPER_OPTION_PREFIX a configure-time option or a configure.ac-settable value. */ lt_fatal (__FILE__, __LINE__, "unrecognized %s option: '%s'", ltwrapper_option_prefix, argv[i]); } /* otherwise ... */ newargz[++newargc] = xstrdup (argv[i]); } newargz[++newargc] = NULL; EOF cat <<EOF /* The GNU banner must be the first non-error debug message */ lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); EOF cat <<"EOF" lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); tmp_pathspec = find_executable (argv[0]); if (tmp_pathspec == NULL) lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); lt_debugprintf (__FILE__, __LINE__, "(main) found exe (before symlink chase) at: %s\n", tmp_pathspec); actual_cwrapper_path = chase_symlinks (tmp_pathspec); lt_debugprintf (__FILE__, __LINE__, "(main) found exe (after symlink chase) at: %s\n", actual_cwrapper_path); XFREE (tmp_pathspec); actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); strendzap (actual_cwrapper_path, actual_cwrapper_name); /* wrapper name transforms */ strendzap (actual_cwrapper_name, ".exe"); tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); XFREE (actual_cwrapper_name); actual_cwrapper_name = tmp_pathspec; tmp_pathspec = 0; /* target_name transforms -- use actual target program name; might have lt- prefix */ target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); strendzap (target_name, ".exe"); tmp_pathspec = lt_extend_str (target_name, ".exe", 1); XFREE (target_name); target_name = tmp_pathspec; tmp_pathspec = 0; lt_debugprintf (__FILE__, __LINE__, "(main) libtool target name: %s\n", target_name); EOF cat <<EOF newargz[0] = XMALLOC (char, (strlen (actual_cwrapper_path) + strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); strcpy (newargz[0], actual_cwrapper_path); strcat (newargz[0], "$objdir"); strcat (newargz[0], "/"); EOF cat <<"EOF" /* stop here, and copy so we don't have to do this twice */ tmp_pathspec = xstrdup (newargz[0]); /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ strcat (newargz[0], actual_cwrapper_name); /* DO want the lt- prefix here if it exists, so use target_name */ lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); XFREE (tmp_pathspec); tmp_pathspec = NULL; EOF case $host_os in mingw*) cat <<"EOF" { char* p; while ((p = strchr (newargz[0], '\\')) != NULL) { *p = '/'; } while ((p = strchr (lt_argv_zero, '\\')) != NULL) { *p = '/'; } } EOF ;; esac cat <<"EOF" XFREE (target_name); XFREE (actual_cwrapper_path); XFREE (actual_cwrapper_name); lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ lt_setenv ("DUALCASE", "1"); /* for MSK sh */ /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) because on Windows, both *_VARNAMEs are PATH but uninstalled libraries must come first. */ lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", nonnull (lt_argv_zero)); for (i = 0; i < newargc; i++) { lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", i, nonnull (newargz[i])); } EOF case $host_os in mingw*) cat <<"EOF" /* execv doesn't actually work on mingw as expected on unix */ newargz = prepare_spawn (newargz); rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); if (rval == -1) { /* failed to start process */ lt_debugprintf (__FILE__, __LINE__, "(main) failed to launch target \"%s\": %s\n", lt_argv_zero, nonnull (strerror (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 (__FILE__, __LINE__, "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; lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", nonempty (path)); 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; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); 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; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); 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 (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); 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 (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); 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) { lt_debugprintf (__FILE__, __LINE__, "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 { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "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; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (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; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (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) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (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 case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # 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 bindir= 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 bindir) bindir="$arg" prev= continue ;; 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 func_append dlfiles " $arg" else func_append 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 "*) ;; *) func_append 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 # func_append 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 func_append 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. func_append 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 "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append 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 ;; -bindir) prev=bindir 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" if test -z "$func_stripname_result"; 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 func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # 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 "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append 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* | *-*-haiku*) # 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 func_append 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 func_append 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|--sysroot) func_append 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|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append 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_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append 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" func_append arg " $func_quote_for_eval_result" func_append 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" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append 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" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append 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 func_append 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. func_append 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. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" 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 \"\${$shlibpath_var}\" \| \$SED \'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" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # 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_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append 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 "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append 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= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append 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|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append 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 "*) ;; * ) func_append 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" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_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" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$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 \"$deplib\"" 2>/dev/null | $SED 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. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append 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 "$inherited_linker_flags" | $SED '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 "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED '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" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append 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. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append 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= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi 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. func_append dlprefiles " $lib $dependency_libs" else func_append 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 "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$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 func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append 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 case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append 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" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append 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" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac 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 func_append 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" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_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_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append 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:"*) ;; *) func_append 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 "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append 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 func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append 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 "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append 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 "$opt_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$absdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append 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:"*) ;; *) func_append 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:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_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:"*) ;; *) func_append 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 [\\/]*) func_append 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 "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append 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" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" 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_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result 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 func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append 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 " $new_inherited_linker_flags" | $SED '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 "*) ;; *) func_append 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 "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append 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 func_append 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" func_append 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!" func_append 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 # correct linux to gnu/linux during the next big refactor 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|qnx|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) # correct to gnu/linux during the next big refactor 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. func_append 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" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_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 func_append 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 func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "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 func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append 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 "*) ;; *) func_append 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 "*) ;; *) func_append 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* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append 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 func_append 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 <<EOF int main() { return 0; } EOF $opt_dry_run || $RM conftest if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then ldd_output=`ldd conftest` for i in $deplibs; do case $i in -l*) func_stripname -l '' "$i" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $i "*) func_append newdeplibs " $i" i="" ;; esac fi if test -n "$i" ; then libname=`eval "\\$ECHO \"$libname_spec\""` deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` set dummy $deplib_matches; shift deplib_match=$1 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then func_append newdeplibs " $i" else droppeddeps=yes echo $ECHO "*** Warning: dynamic linker does not accept needed library $i." 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 I believe you do not have" echo "*** because a test_compile did reveal that the linker did not use it for" echo "*** its dynamic dependency list that programs get resolved with at runtime." fi fi ;; *) func_append newdeplibs " $i" ;; esac done else # Error occurred in the first compile. Let's try to salvage # the situation: Compile a separate program for each library. for i in $deplibs; do case $i in -l*) func_stripname -l '' "$i" name=$func_stripname_result $opt_dry_run || $RM conftest if $LTCC $LTCFLAGS -o conftest conftest.c $i; then ldd_output=`ldd conftest` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $i "*) func_append newdeplibs " $i" i="" ;; esac fi if test -n "$i" ; then libname=`eval "\\$ECHO \"$libname_spec\""` deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` set dummy $deplib_matches; shift deplib_match=$1 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then func_append newdeplibs " $i" else droppeddeps=yes echo $ECHO "*** Warning: dynamic linker does not accept needed library $i." 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 a test_compile did reveal that the linker did not use this one" echo "*** as a dynamic dependency that programs can get resolved with at runtime." fi fi else droppeddeps=yes echo $ECHO "*** Warning! Library $i is needed by this library but I was not able to" echo "*** make it link in! You will probably need to install it or some" echo "*** library that it depends on before this library will be fully" echo "*** functional. Installing it before continuing would be even better." fi ;; *) func_append newdeplibs " $i" ;; esac done fi ;; file_magic*) set dummy $deplibs_check_method; shift file_magic_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 "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` if test -n "$file_magic_glob"; then libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` else libnameglob=$libname fi test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do if test "$want_nocaseglob" = yes; then shopt -s nocaseglob potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi 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 "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append 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. func_append 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 "*) func_append 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 \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append 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. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; 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 " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) 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 ;; esac ;; 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 " $newdeplibs" | $SED '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 " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED '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 "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append 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 # Remove ${wl} instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$opt_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 func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result 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"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append 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 func_append 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 "$opt_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 func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$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" func_append 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 cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs 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 "$include_expsyms" | $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 func_append 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 "*) ;; *) func_append 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" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append 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\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_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 func_basename "$output" output_la=$func_basename_result # 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 func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result 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 func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 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. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$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~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append 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 "$opt_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 "$include_expsyms" | $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 func_append 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" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append 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 "$opt_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 "$opt_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 "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $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 " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED '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]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED '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 "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append 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 "*) ;; *) func_append 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"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append 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;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append 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"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append 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 "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$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 *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) 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 "$compile_command" | $SED '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=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # 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 func_append 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 func_append 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 "$link_command" | $SED '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 $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi 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 "$compile_var$compile_command$compile_rpath" | $SED '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 "$link_command" | $SED '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 $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # 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 "$relink_command" | $SED "$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 func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append 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" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append 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" func_append 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" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result 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 elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" 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 "$relink_command" | $SED "$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" func_resolve_sysroot "$deplib" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append 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" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append 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" func_append newdlprefiles " ${lt_sysroot:+=}$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 func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; 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 "$opt_mode" = link || test "$opt_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) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; 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 func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${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 func_append 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 func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_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 func_append 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 func_append 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 func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$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 func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_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 ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/configure����������������������������������������������������������������������������0000755�0001750�0001750�00002132010�11715232773�012135� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68. # # # 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. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH 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 -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || 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. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} 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'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 </dev/null exec 6>&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= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= PACKAGE_URL= ac_unique_file="src/cfpromises.c" # Factoring default headers for most tests. ac_includes_default="\ #include <stdio.h> #ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif #ifdef STDC_HEADERS # include <stdlib.h> # include <stddef.h> #else # ifdef HAVE_STDLIB_H # include <stdlib.h> # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include <memory.h> # endif # include <string.h> #endif #ifdef HAVE_STRINGS_H # include <strings.h> #endif #ifdef HAVE_INTTYPES_H # include <inttypes.h> #endif #ifdef HAVE_STDINT_H # include <stdint.h> #endif #ifdef HAVE_UNISTD_H # include <unistd.h> #endif" ac_config_libobj_dir=pub ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS HOSTNAME GCC_CFLAG NOWRAP EIGHTBIT workdir XNU_FALSE XNU_TRUE NETBSD_FALSE NETBSD_TRUE FREEBSD_FALSE FREEBSD_TRUE HPUX_FALSE HPUX_TRUE AIX_FALSE AIX_TRUE NT_FALSE NT_TRUE SOLARIS_FALSE SOLARIS_TRUE LINUX_FALSE LINUX_TRUE LIB_SELINUX PCRE_LIBS PCRE_LDFLAGS PCRE_CFLAGS PCRE_CPPFLAGS PCRE_PATH OPENSSL_LIBS OPENSSL_LDFLAGS OPENSSL_CFLAGS OPENSSL_CPPFLAGS OPENSSL_PATH BERKELEYDB_LIBS BERKELEYDB_CFLAGS BERKELEYDB_LDFLAGS TOKYOCABINET_LIBS TOKYOCABINET_LDFLAGS TOKYOCABINET_CFLAGS TOKYOCABINET_CPPFLAGS TOKYOCABINET_PATH HAVE_GALAXY_FALSE HAVE_GALAXY_TRUE HAVE_CONSTELLATION_FALSE HAVE_CONSTELLATION_TRUE HAVE_NOVA_FALSE HAVE_NOVA_TRUE MYSQL_LIBS MYSQL_LDFLAGS MYSQL_CFLAGS MYSQL_CPPFLAGS MYSQL_PATH POSTGRESQL_LIBS POSTGRESQL_LDFLAGS POSTGRESQL_CFLAGS POSTGRESQL_CPPFLAGS POSTGRESQL_PATH CROSS_COMPILING_FALSE CROSS_COMPILING_TRUE GETCONF GETLOADAVG_LIBS KMEM_GROUP NEED_SETGID LIBOBJS YFLAGS YACC LEXLIB LEX_OUTPUT_ROOT LEX CPP OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR AR DLLTOOL OBJDUMP LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP EGREP GREP SED LIBTOOL PTHREAD_CFLAGS PTHREAD_LIBS PTHREAD_CC acx_pthread_config am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC AM_BACKSLASH AM_DEFAULT_VERBOSITY MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_os target_vendor target_cpu target host_os host_vendor host_cpu host build_os build_vendor build_cpu build 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_maintainer_mode enable_silent_rules enable_dependency_tracking enable_static enable_shared with_pic enable_fast_install with_gnu_ld with_sysroot enable_libtool_lock with_diagnostics with_sql with_postgresql with_mysql with_tokyocabinet with_sqlite3 with_qdbm with_berkeleydb with_openssl with_pcre enable_largefile enable_selinux with_workdir ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP YACC YFLAGS' # 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}' 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 this package 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/PACKAGE] --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] --target=TARGET configure for building compilers for TARGET [HOST] _ACEOF fi if test -n "$ac_init_help"; then 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] --disable-maintainer-mode disable make rules and dependencies not useful (and sometimes confusing) to the casual installer --enable-silent-rules less verbose build output (undo: `make V=1') --disable-silent-rules verbose build output (undo: `make V=0') --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --enable-static[=PKGS] build static libraries [default=no] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --disable-largefile omit support for large files --enable-selinux Enable SELinux support Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-diagnostics enable test suite --with-sql[=PATH] Enable SQL database connectors (deprecated, use --with[[out]]-postgresql and --with[[out]]-mysql instead) --with-postgresql[=PATH] Enable PostgreSQL connector --with-mysql[=PATH] Enable MySQL connector --with-tokyocabinet[=PATH] use Tokyo Cabinet to store runtime data --with-sqlite3[=PATH] use SQLite 3 to store runtime data (EXPERIMENTAL, BROKEN) --with-qdbm[=PATH] use QDBM to store runtime data --with-berkeleydb[=PATH] directory where BerkeleyDB exists --with-openssl[=PATH] Specify OpenSSL path --with-pcre[=PATH] Specify PCRE path --with-workdir=WORKDIR default internal for trusted cache Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a nonstandard directory <lib dir> LIBS libraries to pass to the linker, e.g. -l<library> CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> CPP C preprocessor YACC The `Yet Another Compiler 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. 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 configure generated by GNU Autoconf 2.68 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; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $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; ${as_lineno_stack:+:} 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 \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case <limits.h> declares $2. For example, HP-UX 11i <limits.h> declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer <limits.h> to <assert.h> if __STDC__ is defined, since <limits.h> exists even on freestanding compilers. */ #ifdef __STDC__ # include <limits.h> #else # include <assert.h> #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES # ---------------------------------------------------- # Tries to find if the field MEMBER exists in type AGGR, after including # INCLUDES, setting cache variable VAR accordingly. ac_fn_c_check_member () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 $as_echo_n "checking for $2.$3... " >&6; } if eval \${$4+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main () { static $2 ac_aggr; if (ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$4=yes" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main () { static $2 ac_aggr; if (sizeof ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$4=yes" else eval "$4=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 eval ac_res=\$$4 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES # --------------------------------------------- # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR # accordingly. ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 $as_echo_n "checking whether $as_decl_name is declared... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { #ifndef $as_decl_name #ifdef __cplusplus (void) $as_decl_use; #else (void) $as_decl_name; #endif #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl 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 $as_me, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_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. # 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 ${ac_cv_build+:} false; 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 ${ac_cv_host+:} false; 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 { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } if ${ac_cv_target+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; *) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' set x $ac_cv_target shift target_cpu=$1 target_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: target_os=$* IFS=$ac_save_IFS case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac # The aliases save the names the user supplied, while $host etc. # will get canonicalized. test -n "$target_alias" && test "$program_prefix$program_suffix$program_transform_name" = \ NONENONEs,x,x, && program_prefix=${target_alias}- am__api_version='1.11' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { 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 ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null 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=cfengine VERSION=3.2.4 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"} am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then : enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval else USE_MAINTAINER_MODE=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 $as_echo "$USE_MAINTAINER_MODE" >&6; } if test $USE_MAINTAINER_MODE = yes; then MAINTAINER_MODE_TRUE= MAINTAINER_MODE_FALSE='#' else MAINTAINER_MODE_TRUE='#' MAINTAINER_MODE_FALSE= fi MAINT=$MAINTAINER_MODE_TRUE $as_echo "#define BUILD_YEAR 2012" >>confdefs.h # 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='\' ac_config_headers="$ac_config_headers src/conf.h" DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 <stdio.h> int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <stdarg.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> /* 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 ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 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 ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi 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 acx_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5 $as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; } 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 pthread_join (); int main () { return pthread_join (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : acx_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5 $as_echo "$acx_pthread_ok" >&6; } if test x"$acx_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config pthreadGC2" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: 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 # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case "${host_cpu}-${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: acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" ;; esac if test x"$acx_pthread_ok" = xno; then for flag in $acx_pthread_flags; do case $flag in none) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5 $as_echo_n "checking whether pthreads work without any flags... " >&6; } ;; -*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5 $as_echo_n "checking whether pthreads work with $flag... " >&6; } PTHREAD_CFLAGS="$flag" ;; pthread-config) # Extract the first word of "pthread-config", so it can be a program name with args. set dummy pthread-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 ${ac_cv_prog_acx_pthread_config+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$acx_pthread_config"; then ac_cv_prog_acx_pthread_config="$acx_pthread_config" # 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_acx_pthread_config="yes" $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 test -z "$ac_cv_prog_acx_pthread_config" && ac_cv_prog_acx_pthread_config="no" fi fi acx_pthread_config=$ac_cv_prog_acx_pthread_config if test -n "$acx_pthread_config"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_config" >&5 $as_echo "$acx_pthread_config" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test x"$acx_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5 $as_echo_n "checking for the pthreads library -l$flag... " >&6; } PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <pthread.h> int main () { 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); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : acx_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5 $as_echo "$acx_pthread_ok" >&6; } if test "x$acx_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$acx_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5 $as_echo_n "checking for joinable pthread attribute... " >&6; } attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <pthread.h> int main () { int attr=$attr; return attr; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : attr_name=$attr; break fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext done { $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5 $as_echo "$attr_name" >&6; } if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then cat >>confdefs.h <<_ACEOF #define PTHREAD_CREATE_JOINABLE $attr_name _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5 $as_echo_n "checking if more special flags are required for pthreads... " >&6; } flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5 $as_echo "${flag}" >&6; } if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: must compile with xlc_r or cc_r if test x"$GCC" != xyes; then for ac_prog in xlc_r cc_r do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PTHREAD_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PTHREAD_CC"; then ac_cv_prog_PTHREAD_CC="$PTHREAD_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_PTHREAD_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 PTHREAD_CC=$ac_cv_prog_PTHREAD_CC if test -n "$PTHREAD_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5 $as_echo "$PTHREAD_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PTHREAD_CC" && break done test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}" else PTHREAD_CC=$CC fi else PTHREAD_CC="$CC" fi # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$acx_pthread_ok" = xyes; then $as_echo "#define HAVE_PTHREAD 1" >>confdefs.h : else acx_pthread_ok=no 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="$PTHREAD_CC" CFLAGS="$PTHREAD_CFLAGS $CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <stdarg.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> /* 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 ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 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 ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi # Use either new LT_INIT or old AC_DISABLE_STATIC/AC_PROG_LIBTOOL macros 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.4.2' macro_revision='1.3337' ltmain="$ac_aux_dir/ltmain.sh" # Backslashify 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' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case "$ECHO" in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $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 ${ac_cv_path_SED+:} false; 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 ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { 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 ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { 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 ${ac_cv_path_FGREP+:} false; 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 ${lt_cv_path_LD+:} false; 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 </dev/null` in *GNU* | *'with BFD'*) test "$with_gnu_ld" != no && break ;; *) test "$with_gnu_ld" != yes && break ;; esac fi done IFS="$lt_save_ifs" else lt_cv_path_LD="$LD" # Let the user override the test with a path. fi fi LD="$lt_cv_path_LD" if test -n "$LD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&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 ${lt_cv_prog_gnu_ld+:} false; 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 </dev/null` in *GNU* | *'with BFD'*) lt_cv_prog_gnu_ld=yes ;; *) lt_cv_prog_gnu_ld=no ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&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 ${lt_cv_path_NM+:} false; 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 "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; 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 "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; 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 case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac 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 ${lt_cv_nm_interface+:} false; 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:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: 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 ${lt_cv_sys_max_cmd_len+:} false; 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; ;; mint*) # On MiNT this can take a long time and run out of memory. 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 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; 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"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$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%"$_lt_dummy"}, \ = c,a/b,b/c, \ && 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 how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $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 ${lt_cv_ld_reload_flag+:} false; 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 cygwin* | mingw* | pw32* | cegcc*) if test "$GCC" != yes; then reload_cmds=false fi ;; 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 ${ac_cv_prog_OBJDUMP+:} false; 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 ${ac_cv_prog_ac_ct_OBJDUMP+:} false; 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 ${lt_cv_deplibs_check_method+:} false; 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. # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. if ( test "$lt_cv_nm_interface" = "BSD nm" && 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 # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' 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 ;; haiku*) 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])(-bit)?( [LM]SB)? 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 glibc/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_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi 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}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # 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_DLLTOOL="${ac_tool_prefix}dlltool" $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 DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # 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_DLLTOOL="dlltool" $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_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="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 DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; 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$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 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 test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; 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="$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_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 test -n "$ac_ct_AR" && break done 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 fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { 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 ${ac_cv_prog_RANLIB+:} false; 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 ${ac_cv_prog_ac_ct_RANLIB+:} false; 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 \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # 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 ${lt_cv_sys_global_symbol_pipe+:} false; 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};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /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 lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # 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 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #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. */ LT_DLSYM_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_globsym_save_LIBS=$LIBS lt_globsym_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_globsym_save_LIBS CFLAGS=$lt_globsym_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 # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 $as_echo "${with_sysroot}" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } # 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 '$LINENO' "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 ${lt_cv_cc_needs_belf+:} false; 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 ;; *-*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*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) 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" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # 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_MANIFEST_TOOL="${ac_tool_prefix}mt" $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 MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # 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_MANIFEST_TOOL="mt" $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_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" 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 MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi 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 ${ac_cv_prog_DSYMUTIL+:} false; 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 ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; 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 ${ac_cv_prog_NMEDIT+:} false; 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 ${ac_cv_prog_ac_ct_NMEDIT+:} false; 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 ${ac_cv_prog_LIPO+:} false; 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 ${ac_cv_prog_ac_ct_LIPO+:} false; 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 ${ac_cv_prog_OTOOL+:} false; 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 ${ac_cv_prog_ac_ct_OTOOL+:} false; 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 ${ac_cv_prog_OTOOL64+:} false; 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 ${ac_cv_prog_ac_ct_OTOOL64+:} false; 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 ${lt_cv_apple_cc_single_mod+:} false; 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 there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 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 ${lt_cv_ld_exported_symbols_list+:} false; 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; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&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" != ":" && test "$lt_cv_ld_force_load" = "no"; 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 ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since # <limits.h> 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 <limits.h> #else # include <assert.h> #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 <ac_nonexistent.h> _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 <limits.h> to <assert.h> if __STDC__ is defined, since # <limits.h> 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 <limits.h> #else # include <assert.h> #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 <ac_nonexistent.h> _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 ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <stdlib.h> #include <stdarg.h> #include <string.h> #include <float.h> 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 <string.h> _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 <stdlib.h> _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 <ctype.h> #include <stdlib.h> #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" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options # 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=no fi 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 --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac 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 ${lt_cv_objdir+:} false; 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 # 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 "$cc_temp" | $SED "s%.*/%%; 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 ${lt_cv_path_MAGIC_CMD+:} false; 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 ${lt_cv_path_MAGIC_CMD+:} false; 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 case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $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 ${lt_cv_prog_compiler_rtti_exceptions+:} false; 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:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $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 "$_lt_compiler_boilerplate" | $SED '/^$/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= 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' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; 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 case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; 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' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # 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* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # 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='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; 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* | sunf77* | sunf90* | sunf95*) 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}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # 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 ${lt_cv_prog_compiler_pic_works+:} false; 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:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $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 "$_lt_compiler_boilerplate" | $SED '/^$/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 ${lt_cv_prog_compiler_static_works+:} false; 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 "$_lt_linker_boilerplate" | $SED '/^$/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 ${lt_cv_prog_compiler_c_o+:} false; 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:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $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 "$_lt_compiler_boilerplate" | $SED '/^$/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 ${lt_cv_prog_compiler_c_o+:} false; 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:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $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 "$_lt_compiler_boilerplate" | $SED '/^$/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_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 | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = 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.19, 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 install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _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 <jrb3@best.com> 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' export_dynamic_flag_spec='${wl}--export-all-symbols' 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/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' 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 ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs=yes ;; 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=' $pic_flag' 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; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # 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; func_echo_all \"$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]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes ;; 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; func_echo_all \"$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* | bgf* | bgxlf* | mpixlf*) # 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='${wl}-rpath ${wl}$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_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 $linker_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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $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 # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". 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") || (\$ 2 == "W")) && (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. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else 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 } }' lt_cv_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 "$lt_cv_aix_libpath_"; then lt_cv_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 "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ 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 func_echo_all "${wl}${allow_undefined_flag}"; 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. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else 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 } }' lt_cv_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 "$lt_cv_aix_libpath_"; then lt_cv_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 "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ 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' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi 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. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # 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 $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper 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 `func_echo_all "$deplibs" | $SED '\''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' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi 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=func_echo_all 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 ;; # 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 $pic_flag -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 $pic_flag ${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 && test "$with_gnu_ld" = no; then archive_cmds='$CC -shared $pic_flag ${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_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 && test "$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 $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag ${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' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -b" 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 "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test x"$lt_cv_prog_compiler__b" = xyes; then archive_cmds='$CC -b ${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 ;; 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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else 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) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=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_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test "$lt_cv_irix_exported_symbol" = yes; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -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" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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" && func_echo_all "-set_version $verstring"` -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} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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" && func_echo_all "-set_version $verstring"` -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 "-set_version $verstring"` -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 $pic_flag ${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 $pic_flag ${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; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $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 lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; 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 case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # 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 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # 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; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([A-Za-z]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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<name>.so # instead of lib<name>.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=`func_echo_all "$lib" | $SED '\''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 # correct to gnu/linux during the next big refactor 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,$cc_basename in yes,*) # gcc 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="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; 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 dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. 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 # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # 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' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # 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 # correct to gnu/linux during the next big refactor 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 ;; 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[23].*) 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 # correct to gnu/linux during the next big refactor 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 ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" 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=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' 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' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor 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 if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no 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 : lt_cv_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 fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # 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;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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 ${ac_cv_lib_dl_dlopen+:} false; 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" = xyes; 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" = xyes; 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 ${ac_cv_lib_dld_shl_load+:} false; 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" = xyes; 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" = xyes; 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 ${ac_cv_lib_dl_dlopen+:} false; 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" = xyes; 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 ${ac_cv_lib_svld_dlopen+:} false; 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" = xyes; 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 ${ac_cv_lib_dld_dld_link+:} false; 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" = xyes; 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 ${lt_cv_dlopen_self+:} false; 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 $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include <dlfcn.h> #endif #include <stdio.h> #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 /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 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; else puts (dlerror ()); } /* 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 ${lt_cv_dlopen_self_static+:} false; 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 $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include <dlfcn.h> #endif #include <stdio.h> #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 /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 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; else puts (dlerror ()); } /* 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: 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 ${ac_cv_prog_LEX+:} false; 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 ${ac_cv_prog_lex_root+:} false; 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 ${ac_cv_lib_lex+:} false; 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 ${ac_cv_prog_lex_yytext_pointer+:} false; 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 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 ${ac_cv_prog_YACC+:} false; 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" ac_have_func=no # yes means we've found a way to get the load average. # Make sure getloadavg.c is where it belongs, at configure-time. test -f "$srcdir/$ac_config_libobj_dir/getloadavg.c" || as_fn_error $? "$srcdir/$ac_config_libobj_dir/getloadavg.c is missing" "$LINENO" 5 ac_save_LIBS=$LIBS # Check for getloadavg, but be sure not to touch the cache variable. (ac_fn_c_check_func "$LINENO" "getloadavg" "ac_cv_func_getloadavg" if test "x$ac_cv_func_getloadavg" = xyes; then : exit 0 else exit 1 fi ) && ac_have_func=yes # On HPUX9, an unprivileged user can get load averages through this function. for ac_func in pstat_getdynamic do : ac_fn_c_check_func "$LINENO" "pstat_getdynamic" "ac_cv_func_pstat_getdynamic" if test "x$ac_cv_func_pstat_getdynamic" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PSTAT_GETDYNAMIC 1 _ACEOF fi done # Solaris has libkstat which does not require root. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kstat_open in -lkstat" >&5 $as_echo_n "checking for kstat_open in -lkstat... " >&6; } if ${ac_cv_lib_kstat_kstat_open+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lkstat $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 kstat_open (); int main () { return kstat_open (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_kstat_kstat_open=yes else ac_cv_lib_kstat_kstat_open=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_kstat_kstat_open" >&5 $as_echo "$ac_cv_lib_kstat_kstat_open" >&6; } if test "x$ac_cv_lib_kstat_kstat_open" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBKSTAT 1 _ACEOF LIBS="-lkstat $LIBS" fi test $ac_cv_lib_kstat_kstat_open = yes && ac_have_func=yes # Some systems with -lutil have (and need) -lkvm as well, some do not. # On Solaris, -lkvm requires nlist from -lelf, so check that first # to get the right answer into the cache. # For kstat on solaris, we need libelf to force the definition of SVR4 below. if test $ac_have_func = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_begin in -lelf" >&5 $as_echo_n "checking for elf_begin in -lelf... " >&6; } if ${ac_cv_lib_elf_elf_begin+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lelf $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 elf_begin (); int main () { return elf_begin (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_elf_elf_begin=yes else ac_cv_lib_elf_elf_begin=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_elf_elf_begin" >&5 $as_echo "$ac_cv_lib_elf_elf_begin" >&6; } if test "x$ac_cv_lib_elf_elf_begin" = xyes; then : LIBS="-lelf $LIBS" fi fi if test $ac_have_func = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kvm_open in -lkvm" >&5 $as_echo_n "checking for kvm_open in -lkvm... " >&6; } if ${ac_cv_lib_kvm_kvm_open+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lkvm $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 kvm_open (); int main () { return kvm_open (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_kvm_kvm_open=yes else ac_cv_lib_kvm_kvm_open=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_kvm_kvm_open" >&5 $as_echo "$ac_cv_lib_kvm_kvm_open" >&6; } if test "x$ac_cv_lib_kvm_kvm_open" = xyes; then : LIBS="-lkvm $LIBS" fi # Check for the 4.4BSD definition of getloadavg. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getloadavg in -lutil" >&5 $as_echo_n "checking for getloadavg in -lutil... " >&6; } if ${ac_cv_lib_util_getloadavg+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lutil $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 getloadavg (); int main () { return getloadavg (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_util_getloadavg=yes else ac_cv_lib_util_getloadavg=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_util_getloadavg" >&5 $as_echo "$ac_cv_lib_util_getloadavg" >&6; } if test "x$ac_cv_lib_util_getloadavg" = xyes; then : LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes fi fi if test $ac_have_func = no; then # There is a commonly available library for RS/6000 AIX. # Since it is not a standard part of AIX, it might be installed locally. ac_getloadavg_LIBS=$LIBS LIBS="-L/usr/local/lib $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getloadavg in -lgetloadavg" >&5 $as_echo_n "checking for getloadavg in -lgetloadavg... " >&6; } if ${ac_cv_lib_getloadavg_getloadavg+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgetloadavg $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 getloadavg (); int main () { return getloadavg (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_getloadavg_getloadavg=yes else ac_cv_lib_getloadavg_getloadavg=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_getloadavg_getloadavg" >&5 $as_echo "$ac_cv_lib_getloadavg_getloadavg" >&6; } if test "x$ac_cv_lib_getloadavg_getloadavg" = xyes; then : LIBS="-lgetloadavg $LIBS" else LIBS=$ac_getloadavg_LIBS fi fi # Make sure it is really in the library, if we think we found it, # otherwise set up the replacement function. for ac_func in getloadavg do : ac_fn_c_check_func "$LINENO" "getloadavg" "ac_cv_func_getloadavg" if test "x$ac_cv_func_getloadavg" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETLOADAVG 1 _ACEOF else case " $LIBOBJS " in *" getloadavg.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getloadavg.$ac_objext" ;; esac $as_echo "#define C_GETLOADAVG 1" >>confdefs.h # Figure out what our getloadavg.c needs. ac_have_func=no ac_fn_c_check_header_mongrel "$LINENO" "sys/dg_sys_info.h" "ac_cv_header_sys_dg_sys_info_h" "$ac_includes_default" if test "x$ac_cv_header_sys_dg_sys_info_h" = xyes; then : ac_have_func=yes $as_echo "#define DGUX 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dg_sys_info in -ldgc" >&5 $as_echo_n "checking for dg_sys_info in -ldgc... " >&6; } if ${ac_cv_lib_dgc_dg_sys_info+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldgc $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 dg_sys_info (); int main () { return dg_sys_info (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dgc_dg_sys_info=yes else ac_cv_lib_dgc_dg_sys_info=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_dgc_dg_sys_info" >&5 $as_echo "$ac_cv_lib_dgc_dg_sys_info" >&6; } if test "x$ac_cv_lib_dgc_dg_sys_info" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDGC 1 _ACEOF LIBS="-ldgc $LIBS" fi fi ac_fn_c_check_header_mongrel "$LINENO" "locale.h" "ac_cv_header_locale_h" "$ac_includes_default" if test "x$ac_cv_header_locale_h" = xyes; then : fi for ac_func in setlocale do : ac_fn_c_check_func "$LINENO" "setlocale" "ac_cv_func_setlocale" if test "x$ac_cv_func_setlocale" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SETLOCALE 1 _ACEOF fi done # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it # uses stabs), but it is still SVR4. We cannot check for <elf.h> because # Irix 4.0.5F has the header but not the library. if test $ac_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes \ && test "$ac_cv_lib_kvm_kvm_open" = yes; then ac_have_func=yes $as_echo "#define SVR4 1" >>confdefs.h fi if test $ac_have_func = no; then ac_fn_c_check_header_mongrel "$LINENO" "inq_stats/cpustats.h" "ac_cv_header_inq_stats_cpustats_h" "$ac_includes_default" if test "x$ac_cv_header_inq_stats_cpustats_h" = xyes; then : ac_have_func=yes $as_echo "#define UMAX 1" >>confdefs.h $as_echo "#define UMAX4_3 1" >>confdefs.h fi fi if test $ac_have_func = no; then ac_fn_c_check_header_mongrel "$LINENO" "sys/cpustats.h" "ac_cv_header_sys_cpustats_h" "$ac_includes_default" if test "x$ac_cv_header_sys_cpustats_h" = xyes; then : ac_have_func=yes; $as_echo "#define UMAX 1" >>confdefs.h fi fi if test $ac_have_func = no; then for ac_header in mach/mach.h do : ac_fn_c_check_header_mongrel "$LINENO" "mach/mach.h" "ac_cv_header_mach_mach_h" "$ac_includes_default" if test "x$ac_cv_header_mach_mach_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MACH_MACH_H 1 _ACEOF fi done fi for ac_header in nlist.h do : ac_fn_c_check_header_mongrel "$LINENO" "nlist.h" "ac_cv_header_nlist_h" "$ac_includes_default" if test "x$ac_cv_header_nlist_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NLIST_H 1 _ACEOF ac_fn_c_check_member "$LINENO" "struct nlist" "n_un.n_name" "ac_cv_member_struct_nlist_n_un_n_name" "#include <nlist.h> " if test "x$ac_cv_member_struct_nlist_n_un_n_name" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_NLIST_N_UN_N_NAME 1 _ACEOF $as_echo "#define NLIST_NAME_UNION 1" >>confdefs.h fi fi done fi done # Some definitions of getloadavg require that the program be installed setgid. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getloadavg requires setgid" >&5 $as_echo_n "checking whether getloadavg requires setgid... " >&6; } if ${ac_cv_func_getloadavg_setgid+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include "$srcdir/$ac_config_libobj_dir/getloadavg.c" #ifdef LDAV_PRIVILEGED Yowza Am I SETGID yet #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "Yowza Am I SETGID yet" >/dev/null 2>&1; then : ac_cv_func_getloadavg_setgid=yes else ac_cv_func_getloadavg_setgid=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getloadavg_setgid" >&5 $as_echo "$ac_cv_func_getloadavg_setgid" >&6; } if test $ac_cv_func_getloadavg_setgid = yes; then NEED_SETGID=true $as_echo "#define GETLOADAVG_PRIVILEGED 1" >>confdefs.h else NEED_SETGID=false fi if test $ac_cv_func_getloadavg_setgid = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking group of /dev/kmem" >&5 $as_echo_n "checking group of /dev/kmem... " >&6; } if ${ac_cv_group_kmem+:} false; then : $as_echo_n "(cached) " >&6 else # On Solaris, /dev/kmem is a symlink. Get info on the real file. ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null` # If we got an error (system does not support symlinks), try without -L. test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem` ac_cv_group_kmem=`$as_echo "$ac_ls_output" \ | sed -ne 's/[ ][ ]*/ /g; s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/; / /s/.* //;p;'` fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_group_kmem" >&5 $as_echo "$ac_cv_group_kmem" >&6; } KMEM_GROUP=$ac_cv_group_kmem fi if test "x$ac_save_LIBS" = x; then GETLOADAVG_LIBS=$LIBS else GETLOADAVG_LIBS=`$as_echo "$LIBS" | sed "s|$ac_save_LIBS||"` fi LIBS=$ac_save_LIBS # Extract the first word of "getconf", so it can be a program name with args. set dummy getconf; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_GETCONF+:} false; then : $as_echo_n "(cached) " >&6 else case $GETCONF in [\\/]* | ?:[\\/]*) ac_cv_path_GETCONF="$GETCONF" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_dummy="$PATH:$prefix/bin:/usr/bin:/usr/local/bin:/sw/bin" for as_dir in $as_dummy 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_GETCONF="$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 test -z "$ac_cv_path_GETCONF" && ac_cv_path_GETCONF="false" ;; esac fi GETCONF=$ac_cv_path_GETCONF if test -n "$GETCONF"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GETCONF" >&5 $as_echo "$GETCONF" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$cross_compiling" = "xyes"; then CROSS_COMPILING_TRUE= CROSS_COMPILING_FALSE='#' else CROSS_COMPILING_TRUE='#' CROSS_COMPILING_FALSE= fi # # Add to the default list of places in CPPFLAGS to match LDFLAGS above # Don't add if cross-compiling (setting host), to avoid using native libs. # if test "x$cross_compiling" = "xno"; then for x in /usr/local/include /usr/local/gnu/include /opt/dce/include /sw/include /usr/pkg/include /usr/X11R7/include do if test -d "$x"; then y=`expr " $CPPFLAGS " : ".* -I$x "` if test $y -eq 0; then CPPFLAGS="$CPPFLAGS -I$x" fi fi done fi # Check whether --with-diagnostics was given. if test "${with_diagnostics+set}" = set; then : withval=$with_diagnostics; else with_diagnostics=no fi if test "x$with_diagnostics" != xno; then $as_echo "#define BUILD_TESTSUITE 1" >>confdefs.h fi # Check whether --with-sql was given. if test "${with_sql+set}" = set; then : withval=$with_sql; with_postgresql=$with_sql; with_mysql=$with_sql fi # Check whether --with-postgresql was given. if test "${with_postgresql+set}" = set; then : withval=$with_postgresql; else with_postgresql=check fi if test "x$with_postgresql" != "xno"; then if test "x$with_postgresql" != xyes && test "x$with_postgresql" != xcheck; then PG_CONFIG=$with_postgresql/bin/pg_config else PG_CONFIG=pg_config fi # pg_config is only for native builds if test "x$cross_compiling" = "xno"; then if test x`which $PG_CONFIG` != x ; then CPPFLAGS="$CPPFLAGS -I`$PG_CONFIG --includedir`" fi fi # # Populate ${LIBRARY}_{PATH,CFLAGS,LDFLAGS} according to arguments # if test "x$with_postgresql" != xyes && test "x$with_postgresql" != xcheck; then POSTGRESQL_PATH="$with_postgresql" if test "x$with_postgresql" != x/usr && test "x$with_postgresql" != x/; then POSTGRESQL_CFLAGS="-I$with_postgresql/include" POSTGRESQL_LDFLAGS="-L$with_postgresql/lib" fi else POSTGRESQL_PATH="default path" fi save_CFLAGS="$CFLAGS" save_CPPFLAGS="$CPPFLAGS" save_LDFLAGS="$LDFLAGS" save_LIBS="$LIBS" CFLAGS="$CFLAGS $POSTGRESQL_CFLAGS" CPPFLAGS="$CPPFLAGS $POSTGRESQL_CFLAGS" LDFLAGS="$LDFLAGS $POSTGRESQL_LDFLAGS" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PQconnectdb in -lpq" >&5 $as_echo_n "checking for PQconnectdb in -lpq... " >&6; } if ${ac_cv_lib_pq_PQconnectdb+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpq $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 PQconnectdb (); int main () { return PQconnectdb (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pq_PQconnectdb=yes else ac_cv_lib_pq_PQconnectdb=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_pq_PQconnectdb" >&5 $as_echo "$ac_cv_lib_pq_PQconnectdb" >&6; } if test "x$ac_cv_lib_pq_PQconnectdb" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPQ 1 _ACEOF LIBS="-lpq $LIBS" else if test "x$with_postgresql" != xcheck; then as_fn_error $? "Cannot find PostgreSQL client library" "$LINENO" 5; fi fi for ac_header in libpq-fe.h do : ac_fn_c_check_header_mongrel "$LINENO" "libpq-fe.h" "ac_cv_header_libpq_fe_h" "$ac_includes_default" if test "x$ac_cv_header_libpq_fe_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPQ_FE_H 1 _ACEOF else if test "x$with_postgresql" != xcheck; then as_fn_error $? "Cannot find PostgreSQL client library" "$LINENO" 5; fi fi done # # Pick up any libraries added by tests # POSTGRESQL_LIBS="$LIBS" # # libtool understands -R$path, but we are not using libtool in configure # snippets, so -R$path goes to $pkg_LDFLAGS only after autoconf tests # if test "x$with_postgresql" != xyes && test "x$with_postgresql" != xcheck; then if test "x$with_postgresql" != x/usr && test "x$with_postgresql" != x/; then POSTGRESQL_LDFLAGS="$POSTGRESQL_LDFLAGS -R$with_postgresql/lib" fi fi # # Restore pristine environment # CFLAGS="$save_CFLAGS" CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" fi # Check whether --with-mysql was given. if test "${with_mysql+set}" = set; then : withval=$with_mysql; else with_mysql=check fi if test "x$with_mysql" != "xno"; then if test "x$with_mysql" != xyes && test "x$with_mysql" != xcheck; then MYSQL_CONFIG=$with_mysql/bin/mysql_config else MYSQL_CONFIG=mysql_config fi # mysql_config is only for native builds if test "x$cross_compiling" = "xno"; then if test x`which $MYSQL_CONFIG` != x ; then CPPFLAGS="$CPPFLAGS `$MYSQL_CONFIG --include`" fi fi # # Populate ${LIBRARY}_{PATH,CFLAGS,LDFLAGS} according to arguments # if test "x$with_mysql" != xyes && test "x$with_mysql" != xcheck; then MYSQL_PATH="$with_mysql" if test "x$with_mysql" != x/usr && test "x$with_mysql" != x/; then MYSQL_CFLAGS="-I$with_mysql/include" MYSQL_LDFLAGS="-L$with_mysql/lib" fi else MYSQL_PATH="default path" fi save_CFLAGS="$CFLAGS" save_CPPFLAGS="$CPPFLAGS" save_LDFLAGS="$LDFLAGS" save_LIBS="$LIBS" CFLAGS="$CFLAGS $MYSQL_CFLAGS" CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS" LDFLAGS="$LDFLAGS $MYSQL_LDFLAGS" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql_real_connect in -lmysqlclient" >&5 $as_echo_n "checking for mysql_real_connect in -lmysqlclient... " >&6; } if ${ac_cv_lib_mysqlclient_mysql_real_connect+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lmysqlclient $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 mysql_real_connect (); int main () { return mysql_real_connect (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_mysqlclient_mysql_real_connect=yes else ac_cv_lib_mysqlclient_mysql_real_connect=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_mysqlclient_mysql_real_connect" >&5 $as_echo "$ac_cv_lib_mysqlclient_mysql_real_connect" >&6; } if test "x$ac_cv_lib_mysqlclient_mysql_real_connect" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBMYSQLCLIENT 1 _ACEOF LIBS="-lmysqlclient $LIBS" else if test "x$with_mysql" != xcheck; then as_fn_error $? "Cannot find MySQL client library" "$LINENO" 5; fi fi for ac_header in mysql.h do : ac_fn_c_check_header_mongrel "$LINENO" "mysql.h" "ac_cv_header_mysql_h" "$ac_includes_default" if test "x$ac_cv_header_mysql_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MYSQL_H 1 _ACEOF else if test "x$with_mysql" != xcheck; then as_fn_error $? "Cannot find MySQL client library" "$LINENO" 5; fi fi done # # Pick up any libraries added by tests # MYSQL_LIBS="$LIBS" # # libtool understands -R$path, but we are not using libtool in configure # snippets, so -R$path goes to $pkg_LDFLAGS only after autoconf tests # if test "x$with_mysql" != xyes && test "x$with_mysql" != xcheck; then if test "x$with_mysql" != x/usr && test "x$with_mysql" != x/; then MYSQL_LDFLAGS="$MYSQL_LDFLAGS -R$with_mysql/lib" fi fi # # Restore pristine environment # CFLAGS="$save_CFLAGS" CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" fi if test "x$with_nova" != xno && test -d ${srcdir}/nova; then HAVE_NOVA_TRUE= HAVE_NOVA_FALSE='#' else HAVE_NOVA_TRUE='#' HAVE_NOVA_FALSE= fi if test "x$with_constellation" != xno && test -d ${srcdir}/constellation; then HAVE_CONSTELLATION_TRUE= HAVE_CONSTELLATION_FALSE='#' else HAVE_CONSTELLATION_TRUE='#' HAVE_CONSTELLATION_FALSE= fi if test "x$with_galaxy" != xno && test -d ${srcdir}/galaxy; then HAVE_GALAXY_TRUE= HAVE_GALAXY_FALSE='#' else HAVE_GALAXY_TRUE='#' HAVE_GALAXY_FALSE= fi # Check whether --with-tokyocabinet was given. if test "${with_tokyocabinet+set}" = set; then : withval=$with_tokyocabinet; fi if test -n "$with_tokyocabinet" && test "x$with_tokyocabinet" != "xno"; then : WITH_TOKYO=1 else WITH_TOKYO=0 fi if test $WITH_TOKYO = 1; then # # Populate ${LIBRARY}_{PATH,CFLAGS,LDFLAGS} according to arguments # if test "x$with_tokyocabinet" != xyes && test "x$with_tokyocabinet" != xcheck; then TOKYOCABINET_PATH="$with_tokyocabinet" if test "x$with_tokyocabinet" != x/usr && test "x$with_tokyocabinet" != x/; then TOKYOCABINET_CFLAGS="-I$with_tokyocabinet/include" TOKYOCABINET_LDFLAGS="-L$with_tokyocabinet/lib" fi else TOKYOCABINET_PATH="default path" fi save_CFLAGS="$CFLAGS" save_CPPFLAGS="$CPPFLAGS" save_LDFLAGS="$LDFLAGS" save_LIBS="$LIBS" CFLAGS="$CFLAGS $TOKYOCABINET_CFLAGS" CPPFLAGS="$CPPFLAGS $TOKYOCABINET_CFLAGS" LDFLAGS="$LDFLAGS $TOKYOCABINET_LDFLAGS" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tchdbnew in -ltokyocabinet" >&5 $as_echo_n "checking for tchdbnew in -ltokyocabinet... " >&6; } if ${ac_cv_lib_tokyocabinet_tchdbnew+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltokyocabinet $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 tchdbnew (); int main () { return tchdbnew (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_tokyocabinet_tchdbnew=yes else ac_cv_lib_tokyocabinet_tchdbnew=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_tokyocabinet_tchdbnew" >&5 $as_echo "$ac_cv_lib_tokyocabinet_tchdbnew" >&6; } if test "x$ac_cv_lib_tokyocabinet_tchdbnew" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBTOKYOCABINET 1 _ACEOF LIBS="-ltokyocabinet $LIBS" else as_fn_error $? "Cannot find Tokyo Cabinet" "$LINENO" 5 fi for ac_header in tcutil.h do : ac_fn_c_check_header_mongrel "$LINENO" "tcutil.h" "ac_cv_header_tcutil_h" "$ac_includes_default" if test "x$ac_cv_header_tcutil_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_TCUTIL_H 1 _ACEOF else as_fn_error $? "Cannot find Tokyo Cabinet" "$LINENO" 5 fi done for ac_header in tchdb.h do : ac_fn_c_check_header_mongrel "$LINENO" "tchdb.h" "ac_cv_header_tchdb_h" "$ac_includes_default" if test "x$ac_cv_header_tchdb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_TCHDB_H 1 _ACEOF else as_fn_error $? "Cannot find Tokyo Cabinet" "$LINENO" 5 fi done $as_echo "#define TCDB 1" >>confdefs.h # # Pick up any libraries added by tests # TOKYOCABINET_LIBS="$LIBS" # # libtool understands -R$path, but we are not using libtool in configure # snippets, so -R$path goes to $pkg_LDFLAGS only after autoconf tests # if test "x$with_tokyocabinet" != xyes && test "x$with_tokyocabinet" != xcheck; then if test "x$with_tokyocabinet" != x/usr && test "x$with_tokyocabinet" != x/; then TOKYOCABINET_LDFLAGS="$TOKYOCABINET_LDFLAGS -R$with_tokyocabinet/lib" fi fi # # Restore pristine environment # CFLAGS="$save_CFLAGS" CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" fi # Check whether --with-sqlite3 was given. if test "${with_sqlite3+set}" = set; then : withval=$with_sqlite3; fi if test "x$with_sqlite3" = "xyes"; then : WITH_SQLITE3=1 else WITH_SQLITE3=0 fi if test $WITH_SQLITE3 = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking SQLite 3" >&5 $as_echo_n "checking SQLite 3... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_open in -lsqlite3" >&5 $as_echo_n "checking for sqlite3_open in -lsqlite3... " >&6; } if ${ac_cv_lib_sqlite3_sqlite3_open+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite3 $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 sqlite3_open (); int main () { return sqlite3_open (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_sqlite3_sqlite3_open=yes else ac_cv_lib_sqlite3_sqlite3_open=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_sqlite3_sqlite3_open" >&5 $as_echo "$ac_cv_lib_sqlite3_sqlite3_open" >&6; } if test "x$ac_cv_lib_sqlite3_sqlite3_open" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSQLITE3 1 _ACEOF LIBS="-lsqlite3 $LIBS" else as_fn_error $? "Cannot find SQLite 3" "$LINENO" 5 fi for ac_header in sqlite3.h do : ac_fn_c_check_header_mongrel "$LINENO" "sqlite3.h" "ac_cv_header_sqlite3_h" "$ac_includes_default" if test "x$ac_cv_header_sqlite3_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SQLITE3_H 1 _ACEOF fi done $as_echo "#define SQLITE3 1" >>confdefs.h fi # Check whether --with-qdbm was given. if test "${with_qdbm+set}" = set; then : withval=$with_qdbm; fi if test "x$with_qdbm" = "xyes"; then : WITH_QDBM=1 else WITH_QDBM=0 fi if test $WITH_QDBM = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for QDBM" >&5 $as_echo_n "checking for QDBM... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lqdbm" >&5 $as_echo_n "checking for main in -lqdbm... " >&6; } if ${ac_cv_lib_qdbm_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lqdbm $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_qdbm_main=yes else ac_cv_lib_qdbm_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_qdbm_main" >&5 $as_echo "$ac_cv_lib_qdbm_main" >&6; } if test "x$ac_cv_lib_qdbm_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBQDBM 1 _ACEOF LIBS="-lqdbm $LIBS" else as_fn_error $? "Cannot find Quick Database Manager" "$LINENO" 5 fi for ac_header in depot.h do : ac_fn_c_check_header_mongrel "$LINENO" "depot.h" "ac_cv_header_depot_h" "$ac_includes_default" if test "x$ac_cv_header_depot_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DEPOT_H 1 _ACEOF fi done $as_echo "#define QDB 1" >>confdefs.h fi if test $WITH_QDBM = 0 -a $WITH_TOKYO = 0 -a $WITH_SQLITE3 = 0; then # Check whether --with-berkeleydb was given. if test "${with_berkeleydb+set}" = set; then : withval=$with_berkeleydb; BERKELEYDB_DIR=$with_berkeleydb else BERKELEYDB_DIR=default fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BerkeleyDB location in $BERKELEYDB_DIR" >&5 $as_echo_n "checking for BerkeleyDB location in $BERKELEYDB_DIR... " >&6; } if test "x$BERKELEYDB_DIR" = "xno" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5 $as_echo "" >&6; } as_fn_error $? "This release of cfengine requires a version of BerkeleyDB 4.4 or later" "$LINENO" 5 else if test "x$BERKELEYDB_DIR" = "xdefault" ; then for v in BerkeleyDB.4.2 BerkeleyDB.4.3 BerkeleyDB.4.4 BerkeleyDB.4.5 BerkeleyDB.4.6 BerkeleyDB.4.7 BerkeleyDB.4.8; do for d in $prefix /opt /usr/local /usr/pkg /usr; do test -d "$d/$v" && BERKELEYDB_DIR="$d/$v" done done fi if test "x$BERKELEYDB_DIR" = "xdefault" ; then for d in $prefix /opt /usr/local /usr; do for v in db-4 db4 db3 db db40 db41 db42 db43 db44 db45 db46 db47 db48 db50 db51; do if test -f "$d/include/$v/db.h" ; then echo "Found header in $d/include/$v " test "x$d" != "x/usr" && BERKELEYDB_LDFLAGS="-L$d/lib/$v" BERKELEYDB_CFLAGS="-I$d/include/$v" late_LIBS=$LIBS # In RedHat 8, for instance, we have /usr/include/db4 # and libdb-4.0.a. Debian has /usr/lib/libdb-4.1.a, for # instance. Look for the appropriate library. if test $v = db4 -o $v = db40; then save_CFLAGS="$CFLAGS" save_LDFLAGS="$LDFLAGS" CFLAGS="$CFLAGS $BERKELEYDB_CFLAGS" LDFLAGS="$LDFLAGS $BERKELEYDB_LDFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing db_create" >&5 $as_echo_n "checking for library containing db_create... " >&6; } if ${ac_cv_search_db_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char db_create (); int main () { return db_create (); ; return 0; } _ACEOF for ac_lib in '' db-4 db4 db-4.8 db-4.7 db-4.6 db-4.5 db-4.4 db-4.3 db-4.2 db-4.1 db-4.0; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_db_create=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_db_create+:} false; then : break fi done if ${ac_cv_search_db_create+:} false; then : else ac_cv_search_db_create=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_db_create" >&5 $as_echo "$ac_cv_search_db_create" >&6; } ac_res=$ac_cv_search_db_create if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" BERKELEYDB_LIBS=$ac_cv_search_db_create fi CFLAGS="$save_CFLAGS" LDFLAGS="$save_LDFLAGS" else BERKELEYDB_LIBS="-ldb" fi LIBS=$late_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: $d" >&5 $as_echo "$d" >&6; } break fi done test "x$BERKELEYDB_LIBS" != "x" && break if test -f "$d/include/db.h"; then if test "x$d" != "x/usr"; then BERKELEYDB_LDFLAGS="-L$d/lib64 -L$d/lib" BERKELEYDB_CFLAGS="-I$d/include" fi BERKELEYDB_LIBS="-ldb" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $d" >&5 $as_echo "$d" >&6; } break fi done if test "x$BERKELEYDB_LIBS" = "x" ; then as_fn_error $? "Cannot find BerkeleyDB" "$LINENO" 5 fi elif test -f "$BERKELEYDB_DIR/include/db.h";then case "$target_os" in solaris*) #If we are staticlly linking the BDB files, we do not want a #-R flag. If .so's are present, assume we are dynamic linking if test -n "`ls $BERKELEYDB_DIR/lib/*.so 2>/dev/null`" then BERKELEYDB_LDFLAGS="-L$BERKELEYDB_DIR/lib -R$BERKELEYDB_DIR/lib" else BERKELEYDB_LDFLAGS="-L$BERKELEYDB_DIR/lib" fi;; *) BERKELEYDB_LDFLAGS="-L$BERKELEYDB_DIR/lib";; esac BERKELEYDB_CFLAGS="-I$BERKELEYDB_DIR/include" BERKELEYDB_LIBS="-ldb" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BERKELEYDB_DIR" >&5 $as_echo "$BERKELEYDB_DIR" >&6; } elif test -d "$BERKELEYDB_DIR"; then BERKELEYDB_CFLAGS="-I$BERKELEYDB_DIR/include" for v in . db48 db47 db46 db45 db44 db43 db42 db41 db40 db4 db33 db32 db3 db; do if test -f "$BERKELEYDB_DIR/include/$v/db.h"; then BERKELEYDB_INCLUDEDIR="$BERKELEYDB_DIR/include/$v" BERKELEYDB_CFLAGS="-I$BERKELEYDB_INCLUDEDIR" break fi done if test -f "$BERKELEYDB_INCLUDEDIR/db.h"; then BERKELEYDB_LIBS="-ldb" for v in db-4.8 db48 db-4.7 db4.7 db47 db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44; do if test -f "$BERKELEYDB_DIR/lib/lib$v.so"; then BERKELEYDB_LIBS="-l$v" break fi if test -f "$BERKELEYDB_DIR/lib64/lib$v.so"; then BERKELEYDB_LIBS="-l$v" break fi done case "$target_os" in solaris*) #If we are staticlly linking the BDB files, we do not want a #-R flag. If .so's are present, assume we are dynamic linking if test -n "`ls $BERKELEYDB_DIR/lib/*.so 2>/dev/null`" then BERKELEYDB_LDFLAGS="-L$BERKELEYDB_DIR/lib -R$BERKELEYDB_DIR/lib" else BERKELEYDB_LDFLAGS="-L$BERKELEYDB_DIR/lib" fi;; *) BERKELEYDB_LDFLAGS="-L$BERKELEYDB_DIR/lib";; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BERKELEYDB_DIR" >&5 $as_echo "$BERKELEYDB_DIR" >&6; } else as_fn_error $? "Cannot find BerkeleyDB" "$LINENO" 5 fi else as_fn_error $? "Cannot find BerkeleyDB" "$LINENO" 5 fi $as_echo "#define USE_BERKELEYDB 1" >>confdefs.h BERKELEYDB_SAVE_LDFLAGS=$LDFLAGS BERKELEYDB_SAVE_CPPFLAGS=$CPPFLAGS BERKELEYDB_SAVE_LIBS=$LIBS LDFLAGS="$LDFLAGS $BERKELEYDB_LDFLAGS" CPPFLAGS="$CFLAGS $BERKELEYDB_CFLAGS" LIBS="$LIBS $BERKELEYDB_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Berkeley DB API" >&5 $as_echo_n "checking for Berkeley DB API... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <db.h> #if DB_VERSION_MAJOR < 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 1) #Ancient Berkeley DB version #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: OK" >&5 $as_echo "OK" >&6; } else $as_echo "#define CF_OLD_DB 1" >>confdefs.h fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for db_create in -ldb" >&5 $as_echo_n "checking for db_create in -ldb... " >&6; } if ${ac_cv_lib_db_db_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldb $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 db_create (); int main () { return db_create (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_db_db_create=yes else ac_cv_lib_db_db_create=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_db_db_create" >&5 $as_echo "$ac_cv_lib_db_db_create" >&6; } if test "x$ac_cv_lib_db_db_create" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDB 1 _ACEOF LIBS="-ldb $LIBS" fi LDFLAGS=$BERKELEYDB_SAVE_LDFLAGS CPPFLAGS=$BERKELEYDB_SAVE_CPPFLAGS LIBS=$BERKELEYDB_SAVE_LIBS fi fi # Check whether --with-openssl was given. if test "${with_openssl+set}" = set; then : withval=$with_openssl; else with_openssl=yes fi if test x"$with_openssl" = xno ; then as_fn_error $? "This release of CFEngine requires OpenSSL >= 0.9.7" "$LINENO" 5 fi # # Populate ${LIBRARY}_{PATH,CFLAGS,LDFLAGS} according to arguments # if test "x$with_openssl" != xyes && test "x$with_openssl" != xcheck; then OPENSSL_PATH="$with_openssl" if test "x$with_openssl" != x/usr && test "x$with_openssl" != x/; then OPENSSL_CFLAGS="-I$with_openssl/include" OPENSSL_LDFLAGS="-L$with_openssl/lib" fi else OPENSSL_PATH="default path" fi save_CFLAGS="$CFLAGS" save_CPPFLAGS="$CPPFLAGS" save_LDFLAGS="$LDFLAGS" save_LIBS="$LIBS" CFLAGS="$CFLAGS $OPENSSL_CFLAGS" CPPFLAGS="$CPPFLAGS $OPENSSL_CFLAGS" LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for RSA_generate_key in -lcrypto" >&5 $as_echo_n "checking for RSA_generate_key in -lcrypto... " >&6; } if ${ac_cv_lib_crypto_RSA_generate_key+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcrypto $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* 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 RSA_generate_key (); int main () { return RSA_generate_key (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_crypto_RSA_generate_key=yes else ac_cv_lib_crypto_RSA_generate_key=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_RSA_generate_key" >&5 $as_echo "$ac_cv_lib_crypto_RSA_generate_key" >&6; } if test "x$ac_cv_lib_crypto_RSA_generate_key" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBCRYPTO 1 _ACEOF LIBS="-lcrypto $LIBS" else as_fn_error $? "Cannot find OpenSSL" "$LINENO" 5 fi for ac_header in openssl/opensslv.h do : ac_fn_c_check_header_mongrel "$LINENO" "openssl/opensslv.h" "ac_cv_header_openssl_opensslv_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_opensslv_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_OPENSSLV_H 1 _ACEOF else as_fn_error $? "Cannot find OpenSSL" "$LINENO" 5 fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenSSL version" >&5 $as_echo_n "checking for OpenSSL version... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <openssl/opensslv.h> #if OPENSSL_VERSION_NUMBER < 0x0090602fL #This OpenSSL is too old #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: OK" >&5 $as_echo "OK" >&6; } else as_fn_error $? "This release of CFEngine requires OpenSSL >= 0.9.7" "$LINENO" 5 fi rm -f conftest.err conftest.i conftest.$ac_ext # # Pick up any libraries added by tests # OPENSSL_LIBS="$LIBS" # # libtool understands -R$path, but we are not using libtool in configure # snippets, so -R$path goes to $pkg_LDFLAGS only after autoconf tests # if test "x$with_openssl" != xyes && test "x$with_openssl" != xcheck; then if test "x$with_openssl" != x/usr && test "x$with_openssl" != x/; then OPENSSL_LDFLAGS="$OPENSSL_LDFLAGS -R$with_openssl/lib" fi fi # # Restore pristine environment # CFLAGS="$save_CFLAGS" CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" # Check whether --with-pcre was given. if test "${with_pcre+set}" = set; then : withval=$with_pcre; else with_pcre=yes fi if test "x$with_pcre" = "xno"; then as_fn_error $? "PCRE is required" "$LINENO" 5 fi # # Populate ${LIBRARY}_{PATH,CFLAGS,LDFLAGS} according to arguments # if test "x$with_pcre" != xyes && test "x$with_pcre" != xcheck; then PCRE_PATH="$with_pcre" if test "x$with_pcre" != x/usr && test "x$with_pcre" != x/; then PCRE_CFLAGS="-I$with_pcre/include" PCRE_LDFLAGS="-L$with_pcre/lib" fi else PCRE_PATH="default path" fi save_CFLAGS="$CFLAGS" save_CPPFLAGS="$CPPFLAGS" save_LDFLAGS="$LDFLAGS" save_LIBS="$LIBS" CFLAGS="$CFLAGS $PCRE_CFLAGS" CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS" LDFLAGS="$LDFLAGS $PCRE_LDFLAGS" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre_exec in -lpcre" >&5 $as_echo_n "checking for pcre_exec in -lpcre... " >&6; } if ${ac_cv_lib_pcre_pcre_exec+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcre $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 pcre_exec (); int main () { return pcre_exec (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pcre_pcre_exec=yes else ac_cv_lib_pcre_pcre_exec=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_pcre_pcre_exec" >&5 $as_echo "$ac_cv_lib_pcre_pcre_exec" >&6; } if test "x$ac_cv_lib_pcre_pcre_exec" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPCRE 1 _ACEOF LIBS="-lpcre $LIBS" else as_fn_error $? "Cannot find PCRE" "$LINENO" 5 fi for ac_header in pcre.h pcre/pcre.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_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 break else as_fn_error $? "Cannot find PCRE" "$LINENO" 5 fi done # # Pick up any libraries added by tests # PCRE_LIBS="$LIBS" # # libtool understands -R$path, but we are not using libtool in configure # snippets, so -R$path goes to $pkg_LDFLAGS only after autoconf tests # if test "x$with_pcre" != xyes && test "x$with_pcre" != xcheck; then if test "x$with_pcre" != x/usr && test "x$with_pcre" != x/; then PCRE_LDFLAGS="$PCRE_LDFLAGS -R$with_pcre/lib" fi fi # # Restore pristine environment # CFLAGS="$save_CFLAGS" CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" for ac_header in unistd.h stdlib.h sys/loadavg.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_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 for ac_header in sys/param.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default" if test "x$ac_cv_header_sys_param_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_PARAM_H 1 _ACEOF fi done # sys/param.h is required for sys/mount.h on OpenBSD for ac_header in sys/mount.h do : ac_fn_c_check_header_compile "$LINENO" "sys/mount.h" "ac_cv_header_sys_mount_h" "$ac_includes_default #ifdef HAVE_SYS_PARAM_H # include <sys/param.h> #endif " if test "x$ac_cv_header_sys_mount_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_MOUNT_H 1 _ACEOF fi done for ac_header in utime.h do : ac_fn_c_check_header_mongrel "$LINENO" "utime.h" "ac_cv_header_utime_h" "$ac_includes_default" if test "x$ac_cv_header_utime_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_UTIME_H 1 _ACEOF fi done for ac_header in time.h do : ac_fn_c_check_header_mongrel "$LINENO" "time.h" "ac_cv_header_time_h" "$ac_includes_default" if test "x$ac_cv_header_time_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_TIME_H 1 _ACEOF fi done for ac_header in sys/time.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default" if test "x$ac_cv_header_sys_time_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_TIME_H 1 _ACEOF fi done for ac_header in malloc.h sys/malloc.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_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 for ac_header in vfs.h do : ac_fn_c_check_header_mongrel "$LINENO" "vfs.h" "ac_cv_header_vfs_h" "$ac_includes_default" if test "x$ac_cv_header_vfs_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VFS_H 1 _ACEOF fi done for ac_header in sys/vfs.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/vfs.h" "ac_cv_header_sys_vfs_h" "$ac_includes_default" if test "x$ac_cv_header_sys_vfs_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_VFS_H 1 _ACEOF fi done for ac_header in sys/sockio.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/sockio.h" "ac_cv_header_sys_sockio_h" "$ac_includes_default" if test "x$ac_cv_header_sys_sockio_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_SOCKIO_H 1 _ACEOF fi done for ac_header in sys/statvfs.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/statvfs.h" "ac_cv_header_sys_statvfs_h" "$ac_includes_default" if test "x$ac_cv_header_sys_statvfs_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_STATVFS_H 1 _ACEOF fi done for ac_header in sys/statfs.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/statfs.h" "ac_cv_header_sys_statfs_h" "$ac_includes_default" if test "x$ac_cv_header_sys_statfs_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_STATFS_H 1 _ACEOF fi done for ac_header in fcntl.h do : ac_fn_c_check_header_mongrel "$LINENO" "fcntl.h" "ac_cv_header_fcntl_h" "$ac_includes_default" if test "x$ac_cv_header_fcntl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_FCNTL_H 1 _ACEOF fi done for ac_header in sys/filesys.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/filesys.h" "ac_cv_header_sys_filesys_h" "$ac_includes_default" if test "x$ac_cv_header_sys_filesys_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_FILESYS_H 1 _ACEOF fi done for ac_header in dustat.h do : ac_fn_c_check_header_mongrel "$LINENO" "dustat.h" "ac_cv_header_dustat_h" "$ac_includes_default" if test "x$ac_cv_header_dustat_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DUSTAT_H 1 _ACEOF fi done for ac_header in sys/systeminfo.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/systeminfo.h" "ac_cv_header_sys_systeminfo_h" "$ac_includes_default" if test "x$ac_cv_header_sys_systeminfo_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_SYSTEMINFO_H 1 _ACEOF fi done for ac_header in sys/acl.h winsock2.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_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 for ac_header in zone.h do : ac_fn_c_check_header_mongrel "$LINENO" "zone.h" "ac_cv_header_zone_h" "$ac_includes_default" if test "x$ac_cv_header_zone_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ZONE_H 1 _ACEOF fi done for ac_header in sys/uio.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/uio.h" "ac_cv_header_sys_uio_h" "$ac_includes_default" if test "x$ac_cv_header_sys_uio_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_UIO_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <stdlib.h> #include <stdarg.h> #include <string.h> #include <float.h> 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 <string.h> _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 <stdlib.h> _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 <ctype.h> #include <stdlib.h> #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 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <sys/types.h> #include <sys/time.h> #include <time.h> int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } if ${ac_cv_header_sys_wait_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <sys/types.h> #include <sys/wait.h> #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main () { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_sys_wait_h=yes else ac_cv_header_sys_wait_h=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_sys_wait_h" >&5 $as_echo "$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then $as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h fi ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 $as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } if eval \${$as_ac_Header+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <sys/types.h> #include <$ac_hdr> int main () { if ((DIR *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$as_ac_Header=yes" else eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$as_ac_Header { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 _ACEOF ac_header_dirent=$ac_hdr; break fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } if ${ac_cv_search_opendir+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' dir; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_opendir=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_opendir+:} false; then : break fi done if ${ac_cv_search_opendir+:} false; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 $as_echo "$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } if ${ac_cv_search_opendir+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' x; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_opendir=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_opendir+:} false; then : break fi done if ${ac_cv_search_opendir+:} false; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 $as_echo "$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } if ${ac_cv_header_stdbool_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <stdbool.h> #ifndef bool "error: bool is not defined" #endif #ifndef false "error: false is not defined" #endif #if false "error: false is not 0" #endif #ifndef true "error: true is not defined" #endif #if true != 1 "error: true is not 1" #endif #ifndef __bool_true_false_are_defined "error: __bool_true_false_are_defined is not defined" #endif struct s { _Bool s: 1; _Bool t; } s; char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1]; /* See body of main program for 'e'. */ char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; char i[sizeof s.t]; enum { j = false, k = true, l = false * true, m = true * 256 }; /* The following fails for HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html */ _Bool q = true; _Bool *pq = &q; int main () { bool e = &s; *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdbool_h=yes else ac_cv_header_stdbool_h=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_stdbool_h" >&5 $as_echo "$ac_cv_header_stdbool_h" >&6; } ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" if test "x$ac_cv_type__Bool" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE__BOOL 1 _ACEOF fi if test $ac_cv_header_stdbool_h = yes; then $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" if test "x$ac_cv_type_mode_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define mode_t int _ACEOF fi ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 $as_echo_n "checking for uid_t in sys/types.h... " >&6; } if ${ac_cv_type_uid_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <sys/types.h> _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "uid_t" >/dev/null 2>&1; then : ac_cv_type_uid_t=yes else ac_cv_type_uid_t=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5 $as_echo "$ac_cv_type_uid_t" >&6; } if test $ac_cv_type_uid_t = no; then $as_echo "#define uid_t int" >>confdefs.h $as_echo "#define gid_t int" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" if test "x$ac_cv_type_pid_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi ac_fn_c_check_type "$LINENO" "clockid_t" "ac_cv_type_clockid_t" "$ac_includes_default" if test "x$ac_cv_type_clockid_t" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_CLOCKID_T 1 _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi # Check whether --enable-largefile was given. if test "${enable_largefile+set}" = set; then : enableval=$enable_largefile; fi if test "$enable_largefile" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 $as_echo_n "checking for special C compiler options needed for large files... " >&6; } if ${ac_cv_sys_largefile_CC+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC while :; do # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <sys/types.h> /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : break fi rm -f core conftest.err conftest.$ac_objext CC="$CC -n32" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_largefile_CC=' -n32'; break fi rm -f core conftest.err conftest.$ac_objext break done CC=$ac_save_CC rm -f conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 $as_echo "$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 $as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } if ${ac_cv_sys_file_offset_bits+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <sys/types.h> /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 #include <sys/types.h> /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=64; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_file_offset_bits=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 $as_echo "$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits _ACEOF ;; esac rm -rf conftest* if test $ac_cv_sys_file_offset_bits = unknown; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 $as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } if ${ac_cv_sys_large_files+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <sys/types.h> /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGE_FILES 1 #include <sys/types.h> /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=1; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_large_files=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 $as_echo "$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _LARGE_FILES $ac_cv_sys_large_files _ACEOF ;; esac rm -rf conftest* fi fi ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" if test "x$ac_cv_type_off_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define off_t long int _ACEOF fi # # AC_SYS_LARGEFILE correctly figures out necessary macros for large files, but # on AIX there is a gotcha: # # Code generated by flex #includes <stdio.h> at the beginning of the file, which # picks up 32-bit wide off_t. Then it #includes <conf.h> which provides LFS # macros, and finally it includes another system header, now with 64-bit wide # off_t, which causes a conflict. # if test "x$ac_cv_sys_large_files" = x1; then CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=1" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqrt in -lm" >&5 $as_echo_n "checking for sqrt in -lm... " >&6; } if ${ac_cv_lib_m_sqrt+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $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 sqrt (); int main () { return sqrt (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_m_sqrt=yes else ac_cv_lib_m_sqrt=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_m_sqrt" >&5 $as_echo "$ac_cv_lib_m_sqrt" >&6; } if test "x$ac_cv_lib_m_sqrt" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF LIBS="-lm $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5 $as_echo_n "checking for clock_gettime in -lrt... " >&6; } if ${ac_cv_lib_rt_clock_gettime+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lrt $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 clock_gettime (); int main () { return clock_gettime (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_rt_clock_gettime=yes else ac_cv_lib_rt_clock_gettime=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_rt_clock_gettime" >&5 $as_echo "$ac_cv_lib_rt_clock_gettime" >&6; } if test "x$ac_cv_lib_rt_clock_gettime" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBRT 1 _ACEOF LIBS="-lrt $LIBS" fi ac_fn_c_check_decl "$LINENO" "clock_gettime" "ac_cv_have_decl_clock_gettime" "#include <time.h> " if test "x$ac_cv_have_decl_clock_gettime" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_CLOCK_GETTIME $ac_have_decl _ACEOF ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime" if test "x$ac_cv_func_clock_gettime" = xyes; then : $as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h else case " $LIBOBJS " in *" clock_gettime.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS clock_gettime.$ac_objext" ;; esac fi ac_fn_c_check_decl "$LINENO" "unsetenv" "ac_cv_have_decl_unsetenv" "$ac_includes_default" if test "x$ac_cv_have_decl_unsetenv" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_UNSETENV $ac_have_decl _ACEOF ac_fn_c_check_func "$LINENO" "unsetenv" "ac_cv_func_unsetenv" if test "x$ac_cv_func_unsetenv" = xyes; then : $as_echo "#define HAVE_UNSETENV 1" >>confdefs.h else case " $LIBOBJS " in *" unsetenv.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS unsetenv.$ac_objext" ;; esac fi ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default" if test "x$ac_cv_have_decl_strnlen" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRNLEN $ac_have_decl _ACEOF ac_fn_c_check_func "$LINENO" "strnlen" "ac_cv_func_strnlen" if test "x$ac_cv_func_strnlen" = xyes; then : $as_echo "#define HAVE_STRNLEN 1" >>confdefs.h else case " $LIBOBJS " in *" strnlen.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strnlen.$ac_objext" ;; esac fi ac_fn_c_check_decl "$LINENO" "strndup" "ac_cv_have_decl_strndup" "$ac_includes_default" if test "x$ac_cv_have_decl_strndup" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRNDUP $ac_have_decl _ACEOF ac_fn_c_check_func "$LINENO" "strndup" "ac_cv_func_strndup" if test "x$ac_cv_func_strndup" = xyes; then : $as_echo "#define HAVE_STRNDUP 1" >>confdefs.h else case " $LIBOBJS " in *" strndup.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strndup.$ac_objext" ;; esac fi ac_fn_c_check_decl "$LINENO" "setlinebuf" "ac_cv_have_decl_setlinebuf" "$ac_includes_default" if test "x$ac_cv_have_decl_setlinebuf" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_SETLINEBUF $ac_have_decl _ACEOF ac_fn_c_check_func "$LINENO" "setlinebuf" "ac_cv_func_setlinebuf" if test "x$ac_cv_func_setlinebuf" = xyes; then : $as_echo "#define HAVE_SETLINEBUF 1" >>confdefs.h else case " $LIBOBJS " in *" setlinebuf.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS setlinebuf.$ac_objext" ;; esac fi ac_fn_c_check_decl "$LINENO" "strlcat" "ac_cv_have_decl_strlcat" "$ac_includes_default" if test "x$ac_cv_have_decl_strlcat" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRLCAT $ac_have_decl _ACEOF ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat" if test "x$ac_cv_func_strlcat" = xyes; then : $as_echo "#define HAVE_STRLCAT 1" >>confdefs.h else case " $LIBOBJS " in *" strlcat.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strlcat.$ac_objext" ;; esac fi ac_fn_c_check_decl "$LINENO" "strlcpy" "ac_cv_have_decl_strlcpy" "$ac_includes_default" if test "x$ac_cv_have_decl_strlcpy" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRLCPY $ac_have_decl _ACEOF ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" if test "x$ac_cv_func_strlcpy" = xyes; then : $as_echo "#define HAVE_STRLCPY 1" >>confdefs.h else case " $LIBOBJS " in *" strlcpy.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strlcpy.$ac_objext" ;; esac fi ac_fn_c_check_decl "$LINENO" "realpath" "ac_cv_have_decl_realpath" "$ac_includes_default" if test "x$ac_cv_have_decl_realpath" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_REALPATH $ac_have_decl _ACEOF for ac_func in realpath do : ac_fn_c_check_func "$LINENO" "realpath" "ac_cv_func_realpath" if test "x$ac_cv_func_realpath" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_REALPATH 1 _ACEOF fi done ac_fn_c_check_decl "$LINENO" "round" "ac_cv_have_decl_round" "#include <math.h> " if test "x$ac_cv_have_decl_round" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_ROUND $ac_have_decl _ACEOF ac_fn_c_check_func "$LINENO" "round" "ac_cv_func_round" if test "x$ac_cv_func_round" = xyes; then : $as_echo "#define HAVE_ROUND 1" >>confdefs.h else case " $LIBOBJS " in *" round.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS round.$ac_objext" ;; esac fi ac_fn_c_check_decl "$LINENO" "strdup" "ac_cv_have_decl_strdup" "$ac_includes_default" if test "x$ac_cv_have_decl_strdup" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRDUP $ac_have_decl _ACEOF ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup" if test "x$ac_cv_func_strdup" = xyes; then : $as_echo "#define HAVE_STRDUP 1" >>confdefs.h else case " $LIBOBJS " in *" strdup.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strdup.$ac_objext" ;; esac fi ac_fn_c_check_decl "$LINENO" "nanosleep" "ac_cv_have_decl_nanosleep" "$ac_includes_default" if test "x$ac_cv_have_decl_nanosleep" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_NANOSLEEP $ac_have_decl _ACEOF ac_fn_c_check_func "$LINENO" "nanosleep" "ac_cv_func_nanosleep" if test "x$ac_cv_func_nanosleep" = xyes; then : $as_echo "#define HAVE_NANOSLEEP 1" >>confdefs.h else case " $LIBOBJS " in *" nanosleep.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS nanosleep.$ac_objext" ;; esac fi for ac_func in getcwd getnetgrent waitpid seteuid setegid setreuid setregid do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_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 for ac_func in uname gethostname chflags do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_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 for ac_func in strstr strsep putenv drand48 srand48 getaddrinfo do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_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 for ac_func in bcopy mkfifo statfs statvfs door do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_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 for ac_func in sysinfo setsid strrchr strerror snprintf sysconf do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_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 for ac_func in getzoneid getzonenamebyid do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_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 for ac_func in fpathconf do : ac_fn_c_check_func "$LINENO" "fpathconf" "ac_cv_func_fpathconf" if test "x$ac_cv_func_fpathconf" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_FPATHCONF 1 _ACEOF fi done ac_fn_c_check_decl "$LINENO" "dirfd" "ac_cv_have_decl_dirfd" "$ac_includes_default #ifdef HAVE_DIRENT_H # include <dirent.h> #endif " if test "x$ac_cv_have_decl_dirfd" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_DIRFD $ac_have_decl _ACEOF for ac_func in dirfd do : ac_fn_c_check_func "$LINENO" "dirfd" "ac_cv_func_dirfd" if test "x$ac_cv_func_dirfd" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DIRFD 1 _ACEOF else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dirfd macro" >&5 $as_echo_n "checking for dirfd macro... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default #ifdef HAVE_DIRENT_H # include <dirent.h> #endif #ifdef dirfd dirfd_found #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "dirfd_found" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } DIRFD_MACRO_FOUND=1 else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f conftest* if test x$DIRFD_MACRO_FOUND = x; then case " $LIBOBJS " in *" dirfd.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS dirfd.$ac_objext" ;; esac fi fi done for ac_func in jail_get do : ac_fn_c_check_func "$LINENO" "jail_get" "ac_cv_func_jail_get" if test "x$ac_cv_func_jail_get" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_JAIL_GET 1 _ACEOF fi done ac_fn_c_check_func "$LINENO" "door_create" "ac_cv_func_door_create" if test "x$ac_cv_func_door_create" = xyes; then : door fi ac_fn_c_check_func "$LINENO" "setsockopt" "ac_cv_func_setsockopt" if test "x$ac_cv_func_setsockopt" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for setsockopt in -lsocket" >&5 $as_echo_n "checking for setsockopt in -lsocket... " >&6; } if ${ac_cv_lib_socket_setsockopt+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* 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 setsockopt (); int main () { return setsockopt (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_setsockopt=yes else ac_cv_lib_socket_setsockopt=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_setsockopt" >&5 $as_echo "$ac_cv_lib_socket_setsockopt" >&6; } if test "x$ac_cv_lib_socket_setsockopt" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSOCKET 1 _ACEOF LIBS="-lsocket $LIBS" fi fi ac_fn_c_check_func "$LINENO" "gethostent" "ac_cv_func_gethostent" if test "x$ac_cv_func_gethostent" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostent in -lnsl" >&5 $as_echo_n "checking for gethostent in -lnsl... " >&6; } if ${ac_cv_lib_nsl_gethostent+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* 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 gethostent (); int main () { return gethostent (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_gethostent=yes else ac_cv_lib_nsl_gethostent=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostent" >&5 $as_echo "$ac_cv_lib_nsl_gethostent" >&6; } if test "x$ac_cv_lib_nsl_gethostent" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBNSL 1 _ACEOF LIBS="-lnsl $LIBS" fi fi ac_fn_c_check_func "$LINENO" "getaddrinfo" "ac_cv_func_getaddrinfo" if test "x$ac_cv_func_getaddrinfo" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getaddrinfo in -lsocket" >&5 $as_echo_n "checking for getaddrinfo in -lsocket... " >&6; } if ${ac_cv_lib_socket_getaddrinfo+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* 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 getaddrinfo (); int main () { return getaddrinfo (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_getaddrinfo=yes else ac_cv_lib_socket_getaddrinfo=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_getaddrinfo" >&5 $as_echo "$ac_cv_lib_socket_getaddrinfo" >&6; } if test "x$ac_cv_lib_socket_getaddrinfo" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSOCKET 1 _ACEOF LIBS="-lsocket $LIBS" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5 $as_echo_n "checking for library containing socket... " >&6; } if ${ac_cv_search_socket+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char socket (); int main () { return socket (); ; return 0; } _ACEOF for ac_lib in '' socket; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_socket=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_socket+:} false; then : break fi done if ${ac_cv_search_socket+:} false; then : else ac_cv_search_socket=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5 $as_echo "$ac_cv_search_socket" >&6; } ac_res=$ac_cv_search_socket if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lnsl" >&5 $as_echo_n "checking for socket in -lnsl... " >&6; } if ${ac_cv_lib_nsl_socket+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl -lsocket $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 socket (); int main () { return socket (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_socket=yes else ac_cv_lib_nsl_socket=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_socket" >&5 $as_echo "$ac_cv_lib_nsl_socket" >&6; } if test "x$ac_cv_lib_nsl_socket" = xyes; then : LIBS="$LIBS -lsocket -lnsl" fi fi ac_fn_c_check_func "$LINENO" "lchown" "ac_cv_func_lchown" if test "x$ac_cv_func_lchown" = xyes; then : $as_echo "#define HAVE_LCHOWN /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpthread" >&5 $as_echo_n "checking for main in -lpthread... " >&6; } if ${ac_cv_lib_pthread_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthread_main=yes else ac_cv_lib_pthread_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_main" >&5 $as_echo "$ac_cv_lib_pthread_main" >&6; } if test "x$ac_cv_lib_pthread_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPTHREAD 1 _ACEOF LIBS="-lpthread $LIBS" fi ac_fn_c_check_func "$LINENO" "pthread_attr_setstacksize" "ac_cv_func_pthread_attr_setstacksize" if test "x$ac_cv_func_pthread_attr_setstacksize" = xyes; then : $as_echo "#define HAVE_PTHREAD_ATTR_SETSTACKSIZE /**/" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 $as_echo_n "checking for pthread_create in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $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 pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_create=yes else ac_cv_lib_pthread_pthread_create=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_pthread_pthread_create" >&5 $as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPTHREAD 1 _ACEOF LIBS="-lpthread $LIBS" fi fi ac_fn_c_check_func "$LINENO" "pthread_sigmask" "ac_cv_func_pthread_sigmask" if test "x$ac_cv_func_pthread_sigmask" = xyes; then : $as_echo "#define HAVE_PTHREAD_SIGMASK /**/" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 $as_echo_n "checking for pthread_create in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $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 pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_create=yes else ac_cv_lib_pthread_pthread_create=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_pthread_pthread_create" >&5 $as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPTHREAD 1 _ACEOF LIBS="-lpthread $LIBS" fi fi if test "$ac_cv_lib_pthread_main" = "yes"; then for ac_header in pthread.h do : ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" if test "x$ac_cv_header_pthread_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTHREAD_H 1 _ACEOF fi done for ac_header in sched.h do : ac_fn_c_check_header_mongrel "$LINENO" "sched.h" "ac_cv_header_sched_h" "$ac_includes_default" if test "x$ac_cv_header_sched_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SCHED_H 1 _ACEOF fi done fi # # Temporarily force C macros to enable threading in CFEngine if pthreads were # found by ACX_PTHREAD, and errorneously disabled by another pthread-related # checks. # if test "x$acx_pthread_ok" = "xyes"; then $as_echo "#define HAVE_PTHREAD_H 1" >>confdefs.h $as_echo "#define HAVE_LIBPTHREAD 1" >>confdefs.h fi ac_fn_c_check_member "$LINENO" "struct sockaddr" "sa_len" "ac_cv_member_struct_sockaddr_sa_len" " #include <sys/types.h> #include <sys/socket.h> " if test "x$ac_cv_member_struct_sockaddr_sa_len" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_SOCKADDR_SA_LEN 1 _ACEOF fi rtry=none { $as_echo "$as_me:${as_lineno-$LINENO}: checking for either struct rtentry or struct ortentry" >&5 $as_echo_n "checking for either struct rtentry or struct ortentry... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <net/route.h> _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "rtentry" >/dev/null 2>&1; then : rtry=rtentry fi rm -f conftest* if test "$rtry" = rtentry; then $as_echo "#define HAVE_RTENTRY 1" >>confdefs.h fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <net/route.h> _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "ortentry" >/dev/null 2>&1; then : rtry=ortentry fi rm -f conftest* if test "$rtry" = ortentry; then $as_echo "#define HAVE_ORTENTRY 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $rtry" >&5 $as_echo "$rtry" >&6; } # Check whether --enable-selinux was given. if test "${enable_selinux+set}" = set; then : enableval=$enable_selinux; fi if test "x$enable_selinux" = "xyes"; then : $as_echo "#define WITH_SELINUX 1" >>confdefs.h LIB_SELINUX="-lselinux" LIBS="$LIBS $LIB_SELINUX" fi CPPFLAGS="$CPPFLAGS $POSTGRESQL_CPPFLAGS $MYSQL_CPPFLAGS $TOKYOCABINET_CPPFLAGS $PCRE_CPPFLAGS $BERKELEYDB_CPPFLAGS $OPENSSL_CPPFLAGS $MONGO_CPPFLAGS $LDAP_CPPFLAGS $LIBVIRT_CPPFLAGS" CFLAGS="$CFLAGS $POSTGRESQL_CFLAGS $MYSQL_CFLAGS $TOKYOCABINET_CFLAGS $PCRE_CFLAGS $BERKELEYDB_CFLAGS $OPENSSL_CFLAGS $MONGO_CFLAGS $LDAP_CFLAGS $LIBVIRT_CFLAGS" LDFLAGS="$LDFLAGS $POSTGRESQL_LDFLAGS $MYSQL_LDFLAGS $TOKYOCABINET_LDFLAGS $PCRE_LDFLAGS $BERKELEYDB_LDFLAGS $OPENSSL_LDFLAGS $MONGO_LDFLAGS $LDAP_LDFLAGS $LIBVIRT_LDFLAGS" LIBS="$LIBS $POSTGRESQL_LIBS $MYSQL_LIBS $TOKYOCABINET_LIBS $PCRE_LIBS $BERKELEYDB_LIBS $OPENSSL_LIBS $MONGO_LIBS $LDAP_LIBS $LIBVIRT_LIBS" if test "$srcdir" != "."; then CPPFLAGS="$CPPFLAGS -I`pwd`/src" fi case "$target_os" in sunos3*) $as_echo "#define SUN3 /**/" >>confdefs.h ;; sunos4*) $as_echo "#define SUN4 /**/" >>confdefs.h ;; solaris2.4*) $as_echo "#define SOLARIS 1" >>confdefs.h $as_echo "#define HAVE_SYS_ACL_H /**/" >>confdefs.h CPPFLAGS="-w $CPPFLAGS" LIBS="$LIBS -lelf" ;; solaris2.5*) $as_echo "#define SOLARIS 1" >>confdefs.h $as_echo "#define _POSIX_C_SOURCE /**/" >>confdefs.h $as_echo "#define __EXTENSIONS__ /**/" >>confdefs.h LIBS="$LIBS -lelf -lsec" ;; solaris2*) $as_echo "#define SOLARIS /**/" >>confdefs.h $as_echo "#define __BIT_TYPES_DEFINED__ /**/" >>confdefs.h # avoid conflict with db.h cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _POSIX_C_SOURCE 1 #include <unistd.h> int main () { ; return 0; } _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : $as_echo "#define _POSIX_C_SOURCE 1" >>confdefs.h else $as_echo "#define _POSIX_C_SOURCE 200112loL" >>confdefs.h fi rm -f conftest.err conftest.i conftest.$ac_ext $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h LIBS="$LIBS -lelf -lsec" ;; solaris*) $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h ;; ultrix*) $as_echo "#define ULTRIX /**/" >>confdefs.h ;; hpux*|hp-ux*) $as_echo "#define HPuUX /**/" >>confdefs.h if test "$GCC" != "yes"; then $as_echo "#define REGEX_MALLOC /**/" >>confdefs.h fi LIBS="$LIBS -lc" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lPW" >&5 $as_echo_n "checking for main in -lPW... " >&6; } if ${ac_cv_lib_PW_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lPW $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_PW_main=yes else ac_cv_lib_PW_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_PW_main" >&5 $as_echo "$ac_cv_lib_PW_main" >&6; } if test "x$ac_cv_lib_PW_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPW 1 _ACEOF LIBS="-lPW $LIBS" fi ;; aix*) $as_echo "#define AIX /**/" >>confdefs.h CPPFLAGS="$CPPFLAGS -w" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpthreads" >&5 $as_echo_n "checking for main in -lpthreads... " >&6; } if ${ac_cv_lib_pthreads_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthreads $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthreads_main=yes else ac_cv_lib_pthreads_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthreads_main" >&5 $as_echo "$ac_cv_lib_pthreads_main" >&6; } if test "x$ac_cv_lib_pthreads_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPTHREADS 1 _ACEOF LIBS="-lpthreads $LIBS" fi ac_fn_c_check_header_mongrel "$LINENO" "pthreads.h" "ac_cv_header_pthreads_h" "$ac_includes_default" if test "x$ac_cv_header_pthreads_h" = xyes; then : fi ;; osf*) $as_echo "#define OSF /**/" >>confdefs.h if test "$GCC" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pthreads may not work with GCC under Tru64" >&5 $as_echo "$as_me: WARNING: pthreads may not work with GCC under Tru64" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: If you get build errors mentioning PTHREADDEFAULTS etc.," >&5 $as_echo "$as_me: WARNING: If you get build errors mentioning PTHREADDEFAULTS etc.," >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: re-configure with CC=cc." >&5 $as_echo "$as_me: WARNING: re-configure with CC=cc." >&2;} fi ;; irix6*) # rtentry is detected OK on a 6.5.19 system. $as_echo "#define HAVE_ORTENTRY 1" >>confdefs.h # Have to hack this for 6.* owing to bug $as_echo "#define IRIX /**/" >>confdefs.h CFLAGS="$CFLAGS -w" ;; irix4*) $as_echo "#define IRIX 1" >>confdefs.h CFLAGS="$CFLAGS -w" LIBS="$LIBS -lsun" ;; irix*) $as_echo "#define IRIX 1" >>confdefs.h CFLAGS="$CFLAGS -w" ;; linux*) $as_echo "#define LINUX /**/" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking for yp_get_default_domain in -lnss_nis" >&5 $as_echo_n "checking for yp_get_default_domain in -lnss_nis... " >&6; } if ${ac_cv_lib_nss_nis_yp_get_default_domain+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnss_nis $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 yp_get_default_domain (); int main () { return yp_get_default_domain (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nss_nis_yp_get_default_domain=yes else ac_cv_lib_nss_nis_yp_get_default_domain=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_nss_nis_yp_get_default_domain" >&5 $as_echo "$ac_cv_lib_nss_nis_yp_get_default_domain" >&6; } if test "x$ac_cv_lib_nss_nis_yp_get_default_domain" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBNSS_NIS 1 _ACEOF LIBS="-lnss_nis $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lacl" >&5 $as_echo_n "checking for main in -lacl... " >&6; } if ${ac_cv_lib_acl_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lacl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_acl_main=yes else ac_cv_lib_acl_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_acl_main" >&5 $as_echo "$ac_cv_lib_acl_main" >&6; } if test "x$ac_cv_lib_acl_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBACL 1 _ACEOF LIBS="-lacl $LIBS" fi for ac_header in acl.h sys/acl.h acl/libacl.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_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 ;; freebsd*|dragonfly*) $as_echo "#define FREEBSD /**/" >>confdefs.h CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE -DBUILDTIN_GCC_THREAD" for ac_header in pthread.h do : ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" if test "x$ac_cv_header_pthread_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTHREAD_H 1 _ACEOF fi done ;; netbsd*) $as_echo "#define NETBSD /**/" >>confdefs.h ;; newsos*) $as_echo "#define NEWS_OS /**/" >>confdefs.h ;; bsd/os*) $as_echo "#define BSDOS /**/" >>confdefs.h ;; bsd*) $as_echo "#define BSD43 /**/" >>confdefs.h ;; aos*) $as_echo "#define AOS /**/" >>confdefs.h ;; nextstep*) $as_echo "#define NEXTSTEP /**/" >>confdefs.h ;; unicos*) $as_echo "#define CFCRAY /**/" >>confdefs.h ;; cray*) $as_echo "#define CFCRAY 1" >>confdefs.h ;; qnx*) $as_echo "#define CFQNX /**/" >>confdefs.h ;; openbsd*|obsd*) $as_echo "#define OPENBSD /**/" >>confdefs.h ;; gnu*) $as_echo "#define CFGNU /**/" >>confdefs.h ;; sysv4.2MP|unix_sv*) $as_echo "#define UNIXWARE /**/" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lthread" >&5 $as_echo_n "checking for main in -lthread... " >&6; } if ${ac_cv_lib_thread_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_thread_main=yes else ac_cv_lib_thread_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_thread_main" >&5 $as_echo "$ac_cv_lib_thread_main" >&6; } if test "x$ac_cv_lib_thread_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBTHREAD 1 _ACEOF LIBS="-lthread $LIBS" fi if test "$ac_cv_lib_thread_main" = "yes"; then for ac_header in thread.h do : ac_fn_c_check_header_mongrel "$LINENO" "thread.h" "ac_cv_header_thread_h" "$ac_includes_default" if test "x$ac_cv_header_thread_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_THREAD_H 1 _ACEOF fi done fi ;; cygwin*) $as_echo "#define CFCYG 1" >>confdefs.h $as_echo "#define NT /**/" >>confdefs.h ;; mingw*) $as_echo "#define MINGW 1" >>confdefs.h $as_echo "#define NT 1" >>confdefs.h LIBS="$LIBS -liphlpapi -lws2_32 -lpsapi -lole32 -loleaut32 -luuid" ;; sco*) $as_echo "#define SCO /**/" >>confdefs.h ;; darwin*) $as_echo "#define DARWIN /**/" >>confdefs.h LDFLAGS="-Xlinker -m $LDFLAGS" ;; *) as_fn_error $? "Unknown system type $target_os" "$LINENO" 5 ;; esac # # OS kernels conditionals. Don't use those unless it is really needed (if code # depends on the *kernel* feature, and even then -- some kernel features are # shared by different kernels). # # Good example: use LINUX to select code which uses inotify and netlink sockets. # Bad example: use LINUX to select code which parses output of coreutils' ps(1). # if test -n "`echo ${target_os} | grep linux`"; then LINUX_TRUE= LINUX_FALSE='#' else LINUX_TRUE='#' LINUX_FALSE= fi if test -n "`(echo ${target_os} | egrep 'solaris|sunos')`"; then SOLARIS_TRUE= SOLARIS_FALSE='#' else SOLARIS_TRUE='#' SOLARIS_FALSE= fi if test -n "`(echo ${target_os} | egrep 'mingw|cygwin')`"; then NT_TRUE= NT_FALSE='#' else NT_TRUE='#' NT_FALSE= fi if test -n "`(echo ${target_os} | grep aix)`"; then AIX_TRUE= AIX_FALSE='#' else AIX_TRUE='#' AIX_FALSE= fi if test -n "`(echo ${target_os} | egrep 'hpux|hp-ux')`"; then HPUX_TRUE= HPUX_FALSE='#' else HPUX_TRUE='#' HPUX_FALSE= fi if test -n "`(echo ${target_os} | grep freebsd)`"; then FREEBSD_TRUE= FREEBSD_FALSE='#' else FREEBSD_TRUE='#' FREEBSD_FALSE= fi if test -n "`(echo ${target_os} | grep netbsd)`"; then NETBSD_TRUE= NETBSD_FALSE='#' else NETBSD_TRUE='#' NETBSD_FALSE= fi if test -n "`(echo ${target_os} | grep darwin)`"; then XNU_TRUE= XNU_FALSE='#' else XNU_TRUE='#' XNU_FALSE= fi # Check whether --with-workdir was given. if test "${with_workdir+set}" = set; then : withval=$with_workdir; if test x$withval != x ; then WORKDIR=$withval else WORKDIR=/var/cfengine fi cat >>confdefs.h <<_ACEOF #define WORKDIR "${WORKDIR}" _ACEOF workdir="${WORKDIR}" else case "$target_os" in mingw*) WORKDIR=$(cmd /c "echo %PROGRAMFILES%\\Cfengine" | sed 's/\\/\\\\/g') ;; *) WORKDIR=/var/cfengine ;; esac cat >>confdefs.h <<_ACEOF #define WORKDIR "${WORKDIR}" _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 8-bit support in Flex" >&5 $as_echo_n "checking for 8-bit support in Flex... " >&6; } if test "$LEX" = "flex"; then EIGHTBIT="\200-\377" { $as_echo "$as_me:${as_lineno-$LINENO}: result: 8-bit support added" >&5 $as_echo "8-bit support added" >&6; } NOWRAP="%option noyywrap" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no 8-bit support" >&5 $as_echo "no 8-bit support" >&6; } NOWRAP="" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for HP-UX aC" >&5 $as_echo_n "checking for HP-UX aC... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined __HP_cc #This is HP-UX ANSI C #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS="$CFLAGS -Agcc" CPPFLAGS="$CPPFLAGS -Agcc" HP_UX_AC=yes fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC specific compile flags" >&5 $as_echo_n "checking for GCC specific compile flags... " >&6; } if test x"$GCC" = "xyes" && test x"$HP_UX_AC" != x"yes"; then GCC_CFLAG="-g -Wreturn-type -Wmissing-prototypes" case "$CFLAGS" in "-O"*|*" -O"*) GCC_CFLAG="$GCC_CFLAG -Wuninitialized" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else GCC_CFLAG="" { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "hostname", so it can be a program name with args. set dummy hostname; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_HOSTNAME+:} false; then : $as_echo_n "(cached) " >&6 else case $HOSTNAME in [\\/]* | ?:[\\/]*) ac_cv_path_HOSTNAME="$HOSTNAME" # 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_HOSTNAME="$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 test -z "$ac_cv_path_HOSTNAME" && ac_cv_path_HOSTNAME="""" ;; esac fi HOSTNAME=$ac_cv_path_HOSTNAME if test -n "$HOSTNAME"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HOSTNAME" >&5 $as_echo "$HOSTNAME" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi cat >>confdefs.h <<_ACEOF #define AUTOCONF_HOSTNAME "`$HOSTNAME`" _ACEOF cat >>confdefs.h <<_ACEOF #define AUTOCONF_SYSNAME "$target_os" _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Xen cpuid-based HVM detection" >&5 $as_echo_n "checking for Xen cpuid-based HVM detection... " >&6; } if test x"$GCC" = "xyes"; then case $host_cpu in i[3456]86*|x86_64*) $as_echo "#define XEN_CPUID_SUPPORT 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5 $as_echo "" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: Summary of options..." >&5 $as_echo "Summary of options..." >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: -> PCRE: $PCRE_PATH" >&5 $as_echo "-> PCRE: $PCRE_PATH" >&6; } if test "x$ac_cv_lib_mysqlclient_mysql_real_connect" != "xno"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: -> MySQL connector: $MYSQL_PATH" >&5 $as_echo "-> MySQL connector: $MYSQL_PATH" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: -> MySQL connector: disabled" >&5 $as_echo "-> MySQL connector: disabled" >&6; } fi if test "x$ac_cv_lib_pq_PQconnectdb" = "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: -> PostgreSQL connector: $POSTGRESQL_PATH" >&5 $as_echo "-> PostgreSQL connector: $POSTGRESQL_PATH" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: -> PostgreSQL connector: disabled" >&5 $as_echo "-> PostgreSQL connector: disabled" >&6; } fi if test $WITH_TOKYO = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: -> DB: Tokyo Cabinet: $TOKYOCABINET_PATH" >&5 $as_echo "-> DB: Tokyo Cabinet: $TOKYOCABINET_PATH" >&6; } elif test $WITH_QDBM = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: -> DB: QDBM" >&5 $as_echo "-> DB: QDBM" >&6; } elif test $WITH_SQLITE3 = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: -> DB: SQLite 3 (EXPERIMENTAL, BROKEN)" >&5 $as_echo "-> DB: SQLite 3 (EXPERIMENTAL, BROKEN)" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: -> DB: Berkeley DB: $BERKELEYDB_DIR" >&5 $as_echo "-> DB: Berkeley DB: $BERKELEYDB_DIR" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5 $as_echo "" >&6; } ac_config_files="$ac_config_files Makefile pub/Makefile src/Makefile src/cf3lex.l docs/Makefile examples/Makefile examples/example_config/Makefile masterfiles/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 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 "${CROSS_COMPILING_TRUE}" && test -z "${CROSS_COMPILING_FALSE}"; then as_fn_error $? "conditional \"CROSS_COMPILING\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_NOVA_TRUE}" && test -z "${HAVE_NOVA_FALSE}"; then as_fn_error $? "conditional \"HAVE_NOVA\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_CONSTELLATION_TRUE}" && test -z "${HAVE_CONSTELLATION_FALSE}"; then as_fn_error $? "conditional \"HAVE_CONSTELLATION\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_GALAXY_TRUE}" && test -z "${HAVE_GALAXY_FALSE}"; then as_fn_error $? "conditional \"HAVE_GALAXY\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${LINUX_TRUE}" && test -z "${LINUX_FALSE}"; then as_fn_error $? "conditional \"LINUX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${SOLARIS_TRUE}" && test -z "${SOLARIS_FALSE}"; then as_fn_error $? "conditional \"SOLARIS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${NT_TRUE}" && test -z "${NT_FALSE}"; then as_fn_error $? "conditional \"NT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${AIX_TRUE}" && test -z "${AIX_FALSE}"; then as_fn_error $? "conditional \"AIX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HPUX_TRUE}" && test -z "${HPUX_FALSE}"; then as_fn_error $? "conditional \"HPUX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${FREEBSD_TRUE}" && test -z "${FREEBSD_FALSE}"; then as_fn_error $? "conditional \"FREEBSD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${NETBSD_TRUE}" && test -z "${NETBSD_FALSE}"; then as_fn_error $? "conditional \"NETBSD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${XNU_TRUE}" && test -z "${XNU_FALSE}"; then as_fn_error $? "conditional \"XNU\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -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 $as_me, which was generated by GNU Autoconf 2.68. 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="\\ config.status configured by $0, generated by GNU Autoconf 2.68, 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 "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ 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 \ nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ 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_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$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 \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done 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 "src/conf.h") CONFIG_HEADERS="$CONFIG_HEADERS src/conf.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "pub/Makefile") CONFIG_FILES="$CONFIG_FILES pub/Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "src/cf3lex.l") CONFIG_FILES="$CONFIG_FILES src/cf3lex.l" ;; "docs/Makefile") CONFIG_FILES="$CONFIG_FILES docs/Makefile" ;; "examples/Makefile") CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;; "examples/example_config/Makefile") CONFIG_FILES="$CONFIG_FILES examples/example_config/Makefile" ;; "masterfiles/Makefile") CONFIG_FILES="$CONFIG_FILES masterfiles/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' <conf$$subs.awk | sed ' /^[^""]/{ N s/\n// } ' >>$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' <confdefs.h | sed ' s/'"$ac_delim"'/"\\\ "/g' >>$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # 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, 2009, 2010, 2011 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="" # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build static libraries. build_old_libs=$enable_static # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # 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 # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # 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 # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # DLL creation program. DLLTOOL=$lt_DLLTOOL # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # 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 # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # 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 # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and in which our libraries should be installed. lt_sysroot=$lt_sysroot # The name of the directory that contains temporary libtool files. objdir=$objdir # 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 # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # 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 # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # 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 # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # 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 # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # 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 # 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 # 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 # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_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 # ### 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 '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) if test x"$xsi_shell" = xyes; then sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ func_dirname ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ } # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_basename ()$/,/^} # func_basename /c\ func_basename ()\ {\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ func_dirname_and_basename ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ 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}"}\ } # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ func_split_long_opt ()\ {\ \ func_split_long_opt_name=${1%%=*}\ \ func_split_long_opt_arg=${1#*=}\ } # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ func_split_short_opt ()\ {\ \ func_split_short_opt_arg=${1#??}\ \ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ } # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ func_lo2o ()\ {\ \ case ${1} in\ \ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ \ *) func_lo2o_result=${1} ;;\ \ esac\ } # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_xform ()$/,/^} # func_xform /c\ func_xform ()\ {\ func_xform_result=${1%.*}.lo\ } # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_arith ()$/,/^} # func_arith /c\ func_arith ()\ {\ func_arith_result=$(( $* ))\ } # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_len ()$/,/^} # func_len /c\ func_len ()\ {\ func_len_result=${#1}\ } # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$lt_shell_append" = xyes; then sed -e '/^func_append ()$/,/^} # func_append /c\ func_append ()\ {\ eval "${1}+=\\${2}"\ } # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ func_append_quoted ()\ {\ \ func_quote_for_eval "${2}"\ \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ } # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 $as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} fi mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ;; 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 { $as_echo "$as_me:${as_lineno-$LINENO}: result: DONE: Configuration done. Run make/gmake to build cfengine." >&5 $as_echo "DONE: Configuration done. Run make/gmake to build cfengine." >&6; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/�������������������������������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�011447� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/���������������������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�013212� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/���������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�015324� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/002x.cf��������������������������������������������������0000644�0001750�0001750�00000002347�11715232734�016254� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" move_obstructions => "true", link_from => test_link; } body link_from test_link { source => "/etc/motd"; link_type => "banana"; } ####################################################### bundle agent check { classes: "ok" not => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should fail"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/013.cf���������������������������������������������������0000644�0001750�0001750�00000002442�11715232734�016062� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 setup (precursor to actual tickle of bug) # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", action => test_action; } body action test_action { log_priority => "alert"; } ####################################################### bundle agent check { classes: "ok" expression => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should pass as a precursor to a bunch of related failures"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/100.cf.sub�����������������������������������������������0000644�0001750�0001750�00000000211�11715232734�016637� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������body common control { bundlesequence => { 'test' }; } bundle agent test { files: "/tmp/foobar" comment => "${this.promiser}"; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/014x.cf��������������������������������������������������0000644�0001750�0001750�00000002305�11715232734�016251� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", action => test_action; } body action test_action { log_priority => "banana"; } ####################################################### bundle agent check { classes: "ok" not => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should fail"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/101.cf���������������������������������������������������0000644�0001750�0001750�00000002135�11715232734�016057� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Test that \<newline> expands correctly by eating newline (Issue 696) # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "mystring" string => "some\ thing"; } ####################################################### bundle agent check { classes: "ok" expression => strcmp("$(test.mystring)", "something"); reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; DEBUG:: "$(test.subout)"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/025.cf���������������������������������������������������0000644�0001750�0001750�00000002444�11715232734�016067� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 setup (precursor to actual tickle of bug) # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", action => test_action; } body action test_action { report_level => "verbose"; } ####################################################### bundle agent check { classes: "ok" expression => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should pass as a precursor to a bunch of related failures"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/033x.cf��������������������������������������������������0000644�0001750�0001750�00000002234�11715232734�016253� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "type" string => "banana"; files: "$(g.testfile)" create => "$(type)"; } ####################################################### bundle agent check { classes: "ok" not => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should fail"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/038x.cf��������������������������������������������������0000644�0001750�0001750�00000002254�11715232734�016262� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", action => test_action; } body action test_action { promise_repaired => { "ok" }; persist_time => "banana"; } ####################################################### bundle agent check { reports: DEBUG:: "This test should fail"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/README���������������������������������������������������0000644�0001750�0001750�00000001001�11715232734�016113� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������0*.cf: This suite of tests is essentially 5 different tests repeated for various attributes. 1) prove that the test case works 2) show that it fails as expected with an illegal value 3) attempt to show failure when that illegal value is a parameter to the body 4) attempt to show failure when that illegal value is a parameter to the bundle 5) attempt to show failure when that illegal value is a parameter to a method 7*.cf: These tests are slightly different, but also address issues in constraint checking �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/004x.cf��������������������������������������������������0000644�0001750�0001750�00000002371�11715232734�016253� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" move_obstructions => "true", link_from => test_link("banana"); } body link_from test_link(type) { source => "/etc/motd"; link_type => "$(type)"; } ####################################################### bundle agent check { classes: "ok" not => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should fail"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/710x.cf��������������������������������������������������0000644�0001750�0001750�00000002256�11715232734�016261� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Related to bug introduced in core r1900 - allowed any body constraint name # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { files: "$(g.testdir)/shouldnotexist" create => "true", nonexistant_attribute => "abc"; } ####################################################### bundle agent check { classes: "ok" not => fileexists("$(g.testdir)/shouldnotexist"); reports: DEBUG:: "Expected to crash - illegal body contstraint name"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/007.cf���������������������������������������������������0000644�0001750�0001750�00000002441�11715232734�016064� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 setup (precursor to actual tickle of bug) # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", action => test_action; } body action test_action { log_level => "verbose"; } ####################################################### bundle agent check { classes: "ok" expression => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should pass as a precursor to a bunch of related failures"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/032x.cf��������������������������������������������������0000644�0001750�0001750�00000002164�11715232734�016254� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "banana"; } ####################################################### bundle agent check { classes: "ok" not => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should fail"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/026x.cf��������������������������������������������������0000644�0001750�0001750�00000002305�11715232734�016254� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", action => test_action; } body action test_action { report_level => "banana"; } ####################################################### bundle agent check { classes: "ok" not => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should fail"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/037.cf���������������������������������������������������0000644�0001750�0001750�00000002377�11715232734�016077� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 setup (precursor to actual tickle of bug) # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", action => test_action; } body action test_action { promise_repaired => { "ok" }; persist_time => "10"; } ####################################################### bundle agent check { reports: DEBUG:: "This test should pass as a precursor to a bunch of related failures"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/001.cf���������������������������������������������������0000644�0001750�0001750�00000002604�11715232734�016057� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 setup (precursor to actual tickle of bug) # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; "$(g.testfile).SOURCE" create => "true"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" move_obstructions => "true", link_from => test_link; } body link_from test_link { source => "$(g.testfile).SOURCE"; link_type => "hardlink"; } ####################################################### bundle agent check { classes: "ok" expression => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should pass as a precursor to a bunch of related failures"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/704x.cf��������������������������������������������������0000644�0001750�0001750�00000002462�11715232734�016263� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Related to Issue 377 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { processes: ".*" process_select => test_plain, signals => { "child" }; } body process_select test_plain { command => "should-never-find-this"; process_result => "command|bfd.pms.wtf!"; # Illegal test names } ####################################################### bundle agent check { vars: "count" string => execresult("/usr/bin/wc $(test.counter)", "noshell"); classes: "ok" expression => regcmp("\s*3\s.*", "$(count)"); reports: DEBUG:: "Expected to crash - illegal test names"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/034x.cf��������������������������������������������������0000644�0001750�0001750�00000002232�11715232734�016252� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 (duplicate, to preserve pattern of 5) # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "banana"; } ####################################################### bundle agent check { classes: "ok" not => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should fail"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/020x.cf��������������������������������������������������0000644�0001750�0001750�00000002306�11715232734�016247� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", action => test_action; } body action test_action { action_policy => "banana"; } ####################################################### bundle agent check { classes: "ok" not => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should fail"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/003x.cf��������������������������������������������������0000644�0001750�0001750�00000002417�11715232734�016253� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "type" string => "banana"; files: "$(g.testfile)" move_obstructions => "true", link_from => test_link; } body link_from test_link { source => "/etc/motd"; link_type => "$(type)"; } ####################################################### bundle agent check { classes: "ok" not => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should fail"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/100.cf���������������������������������������������������0000644�0001750�0001750�00000002401�11715232734�016052� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Test that ${this.promiser} is expanded in comments (Issue 691) # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "subout" string => execresult("$(sys.cf_agent) -Kvf $(this.promise_filename).sub | grep Comment", "useshell"); } ####################################################### bundle agent check { classes: "ok1" not => regcmp(".*this\.promiser.*", "$(test.subout)"); "ok2" expression => regcmp(".*foobar.*", "$(test.subout)"); "ok" and => { "ok1", "ok2" }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; DEBUG:: "$(test.subout)"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/031.cf���������������������������������������������������0000644�0001750�0001750�00000002320�11715232734�016055� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 setup (precursor to actual tickle of bug) # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true"; } ####################################################### bundle agent check { classes: "ok" expression => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should pass as a precursor to a bunch of related failures"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/008x.cf��������������������������������������������������0000644�0001750�0001750�00000002302�11715232734�016251� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", action => test_action; } body action test_action { log_level => "banana"; } ####################################################### bundle agent check { classes: "ok" not => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should fail"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/01_compiler/019.cf���������������������������������������������������0000644�0001750�0001750�00000002520�11715232734�016065� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������###################################################### # # Issue 375 setup (precursor to actual tickle of bug) # ##################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { g, default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", action => test_action; } body action test_action { action_policy => "warn"; } ####################################################### bundle agent check { classes: "ok" expression => fileexists("$(g.testfile)"); reports: DEBUG:: "This test should pass as a precursor to a bunch of related failures"; "This test should not create $(g.testfile)"; ok:: "$(this.promise_filename) FAIL"; !ok:: "$(this.promise_filename) Pass"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/���������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�015344� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/003.cf���������������������������������������������������0000644�0001750�0001750�00000001163�11715232734�016100� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # This is a special test - it exercises runtime switches # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { test }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } ####################################################### bundle agent test { vars: "cmd" string => "$(sys.cf_agent) -Kf $(this.promise_filename).sub -D AUTO,ok_"; commands: "$(cmd)"; reports: DEBUG:: "Running: $(cmd)"; "Test results come from $(this.promise_filename).sub"; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/002.cf.sub�����������������������������������������������0000644�0001750�0001750�00000002106�11715232734�016665� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test class creation with -D # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "dummy" expression => regextract("(.*)\.sub", $(this.promise_filename), "fn"); reports: DEBUG:: "This should only pass if you run it with: -D ok"; "Look at $(fn[1]) to see which flags are passed in"; ok:: "$(fn[1]) Pass"; !ok:: "$(fn[1]) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/002.cf���������������������������������������������������0000644�0001750�0001750�00000001163�11715232734�016077� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # This is a special test - it exercises runtime switches # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { test }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } ####################################################### bundle agent test { vars: "cmd" string => "$(sys.cf_agent) -Kf $(this.promise_filename).sub -D AUTO,ok,"; commands: "$(cmd)"; reports: DEBUG:: "Running: $(cmd)"; "Test results come from $(this.promise_filename).sub"; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/004.cf���������������������������������������������������0000644�0001750�0001750�00000001163�11715232734�016101� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # This is a special test - it exercises runtime switches # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { test }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } ####################################################### bundle agent test { vars: "cmd" string => "$(sys.cf_agent) -Kf $(this.promise_filename).sub -D AUTO,ok."; commands: "$(cmd)"; reports: DEBUG:: "Running: $(cmd)"; "Test results come from $(this.promise_filename).sub"; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/010.cf.sub2����������������������������������������������0000644�0001750�0001750�00000002265�11715232734�016754� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test class creation with -D # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "dummy" expression => regextract("(.*)\.sub\d", $(this.promise_filename), "fn"); reports: DEBUG:: "This is $(this.promise_filename)"; "This should only pass if you run it with the 'bingo' class defined"; "The main tester does NOT set it, but it is created in the 'setup'"; "config file, $(fn[1]).sub1"; bingo:: "$(fn[1]) FAIL"; !bingo:: "$(fn[1]) Pass"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/005.cf.sub�����������������������������������������������0000644�0001750�0001750�00000002111�11715232734�016664� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test initial class negation with -N # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "dummy" expression => regextract("(.*)\.sub", $(this.promise_filename), "fn"); reports: DEBUG:: "This should pass if you run it with: -N ok"; "Look at $(fn[1]) to see which flags are passed in"; ok:: "$(fn[1]) FAIL"; !ok:: "$(fn[1]) Pass"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/README���������������������������������������������������0000644�0001750�0001750�00000000425�11715232734�016144� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������There are tests in this directory that consist of two files. The first file is the nnn.cf file, which is called by the test runner. The second file is the nnn.cf.sub file, which is called by the nnn.cf file. In each case we are testing the effects of various runtime flags. �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/001.cf���������������������������������������������������0000644�0001750�0001750�00000001072�11715232734�016075� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # This is a special test - it exercises runtime switches # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { test }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } ####################################################### bundle agent test { vars: "cmd" string => "$(sys.cf_agent) -Kf $(this.promise_filename).sub -D AUTO,ok"; commands: "$(cmd)"; reports: DEBUG:: "Running: $(cmd)"; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/004.cf.sub�����������������������������������������������0000644�0001750�0001750�00000002115�11715232734�016667� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test class creation with -D # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "dummy" expression => regextract("(.*)\.sub", $(this.promise_filename), "fn"); reports: DEBUG:: "This should only pass if you do not run it with: -D ok"; "Look at $(fn[1]) to see which flags are passed in"; ok:: "$(fn[1]) FAIL"; !ok:: "$(fn[1]) Pass"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/005.cf���������������������������������������������������0000644�0001750�0001750�00000001165�11715232734�016104� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # This is a special test - it exercises runtime switches # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { test }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } ####################################################### bundle agent test { vars: "cmd" string => "$(sys.cf_agent) -Kf $(this.promise_filename).sub -D AUTO -N ok"; commands: "$(cmd)"; reports: DEBUG:: "Running: $(cmd)"; "Test results come from $(this.promise_filename).sub"; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/003.cf.sub�����������������������������������������������0000644�0001750�0001750�00000002041�11715232734�016664� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test class creation with -D # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "dummy" expression => regextract("(.*)\.sub", $(this.promise_filename), "fn"); reports: DEBUG:: "This should only pass if you do not run it with: -D ok"; "Look at $(fn[1]) to see which flags are passed in"; ok:: "$(fn[1]) FAIL"; !ok:: "$(fn[1]) Pass"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/010.cf���������������������������������������������������0000644�0001750�0001750�00000001437�11715232734�016102� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # This is a special test - it exercises runtime switches # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { test }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } ####################################################### bundle agent test { vars: "cmd1" string => "$(sys.cf_agent) -Kf $(this.promise_filename).sub1 -D AUTO -N bingo"; "cmd2" string => "$(sys.cf_agent) -Kf $(this.promise_filename).sub2 -D AUTO"; commands: "$(cmd1)"; "$(cmd2)"; reports: DEBUG:: "Running: $(cmd1)"; "Running: $(cmd2)"; "Setup comes from $(this.promise_filename).sub1, results come from $(this.promise_filename).sub2"; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/010.cf.sub1����������������������������������������������0000644�0001750�0001750�00000002501�11715232734�016744� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test initial class negation with -N # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", classes => set_bingo; } body classes set_bingo { promise_kept => { "bingo" }; promise_repaired => { "bingo" }; } ####################################################### bundle agent check { classes: "dummy" expression => regextract("(.*)\.sub\d", $(this.promise_filename), "fn"); "ok" expression => "bingo"; reports: DEBUG:: "This is $(this.promise_filename), the setup stage of the test only"; DEBUG.bingo:: "bingo is set in $(this.promise_filename)"; DEBUG.!bingo:: "bingo is not set in $(this.promise_filename)"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/00_basics/02_switches/001.cf.sub�����������������������������������������������0000644�0001750�0001750�00000002106�11715232734�016664� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test class creation with -D # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "dummy" expression => regextract("(.*)\.sub", $(this.promise_filename), "fn"); reports: DEBUG:: "This should only pass if you run it with: -D ok"; "Look at $(fn[1]) to see which flags are passed in"; ok:: "$(fn[1]) Pass"; !ok:: "$(fn[1]) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/06_storage/��������������������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�013420� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/06_storage/01_local/�����������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�015012� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/06_storage/01_local/001.cf�����������������������������������������������������0000644�0001750�0001750�00000002346�11715232734�015550� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test simple storage promises - free space in range # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { storage: "/var" volume => test_volume, classes => test_set_class("pass","fail"); } body volume test_volume { freespace => "1k"; } body classes test_set_class(ok_class,notok_class) { promise_kept => { "$(ok_class)" }; promise_repaired => { "$(ok_class)" }; repair_failed => { "$(notok_class)" }; } ####################################################### bundle agent check { classes: "ok" expression => "pass.!fail"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/README�������������������������������������������������������������������������0000644�0001750�0001750�00000012743�11715232734�012255� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������============================================================================== CFEngine testsuite ============================================================================== CFEngine has an extensive testsuite which covers lot of functionality which can be tested as a series of cf-agent runs. You are encouraged to run this testsuite on any new software/hardware configuration, in order to * verify that CFEngine functions correctly * provide developers with reproducible way to fix any problems encountered in new configurations / environment In case you find a bug you are encouraged to create tests in format of testsuite which demonstrate bug found, so the test could be added to this testsuite and checked for in the future. ------------------------------------------------------------------------------ Preparing for running tests ------------------------------------------------------------------------------ * Compile and install CFEngine. - It is advised to use Tokyo Cabinet as it gives much better performance in test suite over Berkeley DB. - You might want to run CFEngine from source tree. Then you need to provide it with symlink from $workdir/bin/cf-promises to built src/cf-promises, as cf-agent looks there for cf-promises. Building with --disable-shared in this case might save a lot of headaches too. * Make sure there is no failsafe.cf in $workdir/inputs directory, otherwise some tests will be errorneously marked as failed. * Make sure user you are running testsuite from has sudo rights. This is necessary to test functionality which is only available for root user. ------------------------------------------------------------------------------ Running testsuite ------------------------------------------------------------------------------ Currently, all tests are assumed to be run by root. All tests ought only to create files and directories in /tmp, and ought not to modify other files. Run ./testall --agent=$workdir/bin/cf-agent e.g. ./testall --agent=/var/cfengine/bin/cf-agent Testing will start. For every test case the name and result (failed / passed) will be produced. At the end testing summary will be provided. Test runner creates the following log files: * test.log contains detailed information about each test case (name, standard output/error contents, return code, and test status). * summary.log contains summary information, like the one displayed during testsuite run. Also a directory .succeeded will be created, containing stamps for each passed test case, so test cases which passed before and failing in subsequent testsuite run will be additionally marked in output as "(UNEXPECTED FAILURE)". You might run a subset of tests by passing either filenames: ./testall --agent=$workdir/bin/cf-agent 01_vars/01_basic/001.cf 01_vars/01_basic/002x.cf or directories to 'testall': ./testall --agent=$workdir/bin/cf-agent 01_vars ------------------------------------------------------------------------------ Creating/editing test cases ------------------------------------------------------------------------------ Each test should be 100% standalone, and must contain at least 4 main bundles: init setup, create initial and hoped-for final states test the actual test code check the comparison of expected and actual results fini cleanup, restore to pre-test state Look in default.cf for some standard check and fini bundles (for example, to compare files when testing file edits, or for cleaning up temporary files). Tests should be named with only digits (e.g., "001.cf") unless they are expected to crash (that is, if they contan syntax errors or other faults), in which case the filename should end in an 'x' (e.g., "001x.cf"). Tests which use Nova-only features should have a name which ends in an 'n' if they are expected to pass, and 'nx' if they are expected to crash (e.g., "007n.cf" or "007nx.cf"). Tests which are not expected to pass yet (e.g. there is a bug in code which prevents tests from passing) should be placed in 'staging' subdirectory in the test directory where they belong. Such test cases will be only run if --staging argument to ./testall is passed. Tests which need network connectivity should be placed to 'network' subdirectories. Those tests may be disabled by passing --no-network option to 'testall'. NOTE: Since the class 'ok' is used in most tests, never create a persistent class called 'ok' in any test. Persistent classes are cleaned up between test runs, but better safe than sorry. ------------------------------------------------------------------------------ Glossary ------------------------------------------------------------------------------ For purposes of testing, here is what our terms mean: Pass: the test did what we expected (whether that was setting a variable, editing a file, killing or starting a process, or correctly failing to do these actions in the light of existing conditions or attributes). Note that in the case of tests that end in an 'x', a Pass is generated when the test abnormally terminates and we wanted it to do that. FAIL: not doing what we wanted: either test finished and returned "FAIL" from check bundle, or something went wrong - cf-agent might have dropped core, cf-promises may have denied execution of the promises, etc. FAILed to crash: test was expected to crash, but did not. This is another kind of failure, split into separate kind due to low impact. Skipped: test is skipped due to be either explicitly disabled or being Nova-specific and being run on Community cf-agent. �����������������������������cfengine-3.2.4/tests/05_processes/������������������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�013761� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/05_processes/01_matching/������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�016053� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/05_processes/01_matching/003.cf������������������������������������������������0000644�0001750�0001750�00000002220�11715232734�016602� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Set a class if a process does not exist # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { processes: "There-is-NoPrOCess-with-this-name" process_count => test_no_such; } body process_count test_no_such { in_range_define => { "found" }; out_of_range_define => { "not_found" }; match_range => irange(1,"inf"); } ####################################################### bundle agent check { classes: "ok" expression => "!found.not_found"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/05_processes/01_matching/002.cf������������������������������������������������0000644�0001750�0001750�00000001764�11715232734�016615� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Set a class if a process exists # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { processes: "\bcf-agent\b" restart_class => "not_ok"; classes: "ok" not => "not_ok"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������cfengine-3.2.4/tests/05_processes/01_matching/004.cf������������������������������������������������0000644�0001750�0001750�00000002167�11715232734�016615� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Set a class if a process does exist # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { processes: "\bcf-agent\b" process_count => test_no_such; } body process_count test_no_such { in_range_define => { "found" }; out_of_range_define => { "not_found" }; match_range => irange(1,"inf"); } ####################################################### bundle agent check { classes: "ok" expression => "found.!not_found"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/05_processes/01_matching/201.cf������������������������������������������������0000644�0001750�0001750�00000002505�11715232734�016610� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Set a class if a process does exist, more complex matches # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { processes: ".*" process_count => test_range, process_select => test_select_high_users; } body process_count test_range { in_range_define => { "found" }; out_of_range_define => { "not_found" }; match_range => irange(0,0); } body process_select test_select_high_users { ttime_range => irange(0, accumulated(9,0,0,0,0,0)); # Anything process_result => "ttime"; # Everything } ####################################################### bundle agent check { classes: "ok" expression => "!found.not_found"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/05_processes/01_matching/006.cf������������������������������������������������0000644�0001750�0001750�00000002163�11715232734�016613� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Set a class if a process does exist # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { processes: "\bcf-agent\b" process_count => test_no_such; } body process_count test_no_such { in_range_define => { "found" }; out_of_range_define => { "not_found" }; match_range => irange(0,0); } ####################################################### bundle agent check { classes: "ok" expression => "!found.not_found"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/05_processes/01_matching/202.cf������������������������������������������������0000644�0001750�0001750�00000002503�11715232734�016607� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Set a class if a process does exist, more complex matches # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { processes: ".*" process_count => test_range, process_select => test_select_high_users; } body process_count test_range { in_range_define => { "found" }; out_of_range_define => { "not_found" }; match_range => irange(0,0); } body process_select test_select_high_users { ttime_range => irange(0, accumulated(9,0,0,0,0,0)); # Anything process_result => "!ttime"; # Nothing } ####################################################### bundle agent check { classes: "ok" expression => "found.!not_found"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/05_processes/01_matching/001.cf������������������������������������������������0000644�0001750�0001750�00000001754�11715232734�016613� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Set a class if a process does not exist # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { processes: "There-is-NoPrOCess-with-this-name" restart_class => "ok"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ��������������������cfengine-3.2.4/tests/05_processes/01_matching/204.cf������������������������������������������������0000644�0001750�0001750�00000002551�11715232734�016614� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Set a class if a process does exist, more complex matches # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { processes: ".*" process_select => test_select_high_users, classes => test_set_class("found", "not_found"); } body classes test_set_class(t,f) { promise_kept => { "$(t)" }; promise_repaired => { "$(t)" }; repair_failed => { "$(f)" }; } body process_select test_select_high_users { ttime_range => irange(0, accumulated(9,0,0,0,0,0)); # Anything process_result => "!ttime"; # Nothing } ####################################################### bundle agent check { classes: "ok" expression => "found.!not_found"; # Nothing found is "kept" reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/05_processes/01_matching/005.cf������������������������������������������������0000644�0001750�0001750�00000002214�11715232734�016607� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Set a class if a process does not exist # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { processes: "There-is-NoPrOCess-with-this-name" process_count => test_no_such; } body process_count test_no_such { in_range_define => { "found" }; out_of_range_define => { "not_found" }; match_range => irange(0,0); } ####################################################### bundle agent check { classes: "ok" expression => "found.!not_found"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/05_processes/01_matching/203.cf������������������������������������������������0000644�0001750�0001750�00000002521�11715232734�016610� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Set a class if a process does exist, more complex matches # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { processes: ".*" process_select => test_select_high_users, classes => test_set_class("found", "not_found"); } body classes test_set_class(t,f) { promise_kept => { "$(t)" }; promise_repaired => { "$(t)" }; repair_failed => { "$(f)" }; } body process_select test_select_high_users { ttime_range => irange(0, accumulated(9,0,0,0,0,0)); # Anything process_result => "ttime"; # Everything } ####################################################### bundle agent check { classes: "ok" expression => "found.!not_found"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/05_processes/01_matching/100.cf������������������������������������������������0000644�0001750�0001750�00000002173�11715232734�016607� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Set a class if a process does exist, partial name # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { processes: "-agent" process_count => test_no_such; } body process_count test_no_such { in_range_define => { "found" }; out_of_range_define => { "not_found" }; match_range => irange(0,0); } ####################################################### bundle agent check { classes: "ok" expression => "!found.not_found"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/default.cf���������������������������������������������������������������������0000644�0001750�0001750�00000006025�11715232734�013327� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������bundle common G { classes: "bin_sort" expression => fileexists("/bin/sort"); "usr_bin_sort" expression => fileexists("/usr/bin/sort"); vars: "cwd" string => execresult("/bin/pwd", "noshell"); "logfile_leafname" string => "TEST.log"; "logfile" string => "$(cwd)/$(logfile_leafname)"; bin_sort:: "sort" string => "/bin/sort"; usr_bin_sort:: "sort" string => "/usr/bin/sort"; } bundle agent default(filename) { vars: "tests" slist => { "init", "test", "check", "fini" }; methods: AUTO:: "any" usebundle => "$(tests)"; reports: !AUTO:: "# You must either specify '-D AUTO' or run the following commands:"; "cf-agent -f ./$(filename) -b $(tests)"; } ####################################################### bundle agent default_sort(infile, outfile) { commands: "$(G.sort) $(infile) > $(outfile)" contain => default_shell_command; } bundle agent default_check_diff(file1, file2, test) { methods: "any" usebundle => check_diff("$(file1)", "$(file2)", "$(test)", "no"); } bundle agent sorted_check_diff(file1, file2, test) { methods: "any" usebundle => default_sort("$(file1)", "$(file1).sort"); "any" usebundle => default_sort("$(file2)", "$(file2).sort"); "any" usebundle => check_diff("$(file1).sort", "$(file2).sort", "$(test)", "no"); } bundle agent check_diff(file1, file2, test, expected_difference) { vars: DEBUG.!no_difference:: "file1r" string => readfile("$(file1)", "9999999999"); "file1h" string => execresult("/usr/bin/hexdump -C $(file1)", "useshell"); "file2r" string => readfile("$(file2)", "9999999999"); "file2h" string => execresult("/usr/bin/hexdump -C $(file2)", "useshell"); "diffu" string => execresult("/usr/bin/diff -u $(file2) $(file1)", "noshell"); classes: "no_difference" expression => returnszero( "/usr/bin/diff -q $(file1) $(file2)", "useshell"); "expected_difference" expression => strcmp("$(expected_difference)", "yes"); reports: no_difference.!expected_difference:: "$(test) Pass"; !no_difference.expected_difference:: "$(test) Pass"; !no_difference.!expected_difference:: "$(test) FAIL"; no_difference.expected_difference:: "$(test) FAIL"; DEBUG.!no_difference.!expected_difference:: "$(file1) and $(file2) differ:"; "$(file1): <$(file1r)>"; "$(file2): <$(file2r)>"; "hexdump $(file1): $(file1h)"; "hexdump $(file2): $(file2h)"; "$(diffu)"; DEBUG.no_difference.expected_difference:: "Contents of $(file1) and $(file) is the same."; } body contain default_shell_command { useshell => "true"; } ####################################################### # Uses rm -rf instead of selecting and deleting files to avoid side-effects in # tests due to problems in file deleletion promises. bundle agent default_fini(file) { commands: "/bin/rm -rf $(file)*" contain => useshell; "/bin/rm -rf $(sys.workdir)/state/cf_state.*" contain => useshell; } body contain useshell { useshell => "true"; chdir => "/"; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/�����������������������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�012722� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/03_lists/��������������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�014362� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/03_lists/003.cf��������������������������������������������������������0000644�0001750�0001750�00000003306�11715232734�015117� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Iteration on slist of size 1 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => ""; "expected" string => " a"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert; } bundle edit_line test_insert { vars: "one" slist => { "a" }; insert_lines: "$(one)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_sort("$(g.testfile).actual", "$(g.testfile).actual.sorted"); "any" usebundle => default_sort("$(g.testfile).expected", "$(g.testfile).expected.sorted"); "any" usebundle => default_check_diff("$(g.testfile).actual.sorted", "$(g.testfile).expected.sorted", "$(this.promise_filename)"); } body contain check_in_shell { useshell => "true"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/03_lists/002.cf��������������������������������������������������������0000644�0001750�0001750�00000003314�11715232734�015115� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Iterations of slists # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => ""; "expected" string => " a b c"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert; } bundle edit_line test_insert { vars: "one" slist => { "a", "b", "c" }; insert_lines: "$(one)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_sort("$(g.testfile).actual", "$(g.testfile).actual.sorted"); "any" usebundle => default_sort("$(g.testfile).expected", "$(g.testfile).expected.sorted"); "any" usebundle => default_check_diff("$(g.testfile).actual.sorted", "$(g.testfile).expected.sorted", "$(this.promise_filename)"); } body contain check_in_shell { useshell => "true"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/03_lists/001.cf��������������������������������������������������������0000644�0001750�0001750�00000003511�11715232734�015113� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Nested iterations of slists (the ordering is not guaranteed, so we sort) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => ""; "expected" string => " a x a y a z b x b y b z c x c y c z"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert; } bundle edit_line test_insert { vars: "one" slist => { "a", "b", "c" }; "two" slist => { "x", "y", "z" }; insert_lines: "$(one) $(two)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_sort("$(g.testfile).actual", "$(g.testfile).actual.sorted"); "any" usebundle => default_sort("$(g.testfile).expected", "$(g.testfile).expected.sorted"); "any" usebundle => default_check_diff("$(g.testfile).actual.sorted", "$(g.testfile).expected.sorted", "$(this.promise_filename)"); } body contain check_in_shell { useshell => "true"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/��������������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�014303� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/007x.cf�������������������������������������������������������0000644�0001750�0001750�00000001665�11715232734�015242� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test simple variables failures # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "ten" real => "e2"; # Not a float } ####################################################### bundle agent check { reports: DEBUG:: "The real variable assignment should fail"; cfengine_3:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/009.cf��������������������������������������������������������0000644�0001750�0001750�00000002437�11715232734�015052� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test simple variables failures # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "zero_p" real => "0e2345678"; # Exponent too big, but still zero "zero_n" real => "0e-2345678"; # Exponent too big, but still zero } ####################################################### bundle agent check { classes: "ok" and => { isgreaterthan("$(test.zero_p)", "-0.1"), islessthan("$(test.zero_p)", "0.1"), isgreaterthan("$(test.zero_n)", "-0.1"), islessthan("$(test.zero_n)", "0.1"), }; reports: DEBUG:: "zero_p == $(test.zero_p)"; "zero_n == $(test.zero_n)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/106.cf.sub����������������������������������������������������0000644�0001750�0001750�00000000437�11715232734�015636� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������body common control { bundlesequence => { "test" }; nova_edition:: host_licenses_paid => "5"; } bundle agent test { vars: "index" slist => { "index" }; "array[$(index)]" string => "value"; "indices" slist => getindices("array"); "values" slist => getvalues("array"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/004x.cf�������������������������������������������������������0000644�0001750�0001750�00000001670�11715232734�015233� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test simple variables failures # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "ten" real => "1.2.3"; # Not a float } ####################################################### bundle agent check { reports: DEBUG:: "The real variable assignment should fail"; cfengine_3:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/006x.cf�������������������������������������������������������0000644�0001750�0001750�00000001664�11715232734�015240� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test simple variables failures # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "ten" real => "."; # Not a float } ####################################################### bundle agent check { reports: DEBUG:: "The real variable assignment should fail"; cfengine_3:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ����������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/012.cf��������������������������������������������������������0000644�0001750�0001750�00000002333�11715232734�015037� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Compilation test of strings that end with a \ - issue 690 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "foo" string => "simple"; "baz" string => "s\imple"; "gar" string => "s\\imple"; "goo" string => "s\\"; "boo" string => "\\e"; "zoo" string => "\\"; } bundle agent check { classes: "ok" expression => "any"; reports: ok:: "$(this.promise_filename) Pass"; MAIN.ok:: "$(this.promise_filename) Pass" report_to_file => "$(G.logfile)"; !ok:: "$(this.promise_filename) FAIL"; MAIN.!ok:: "$(this.promise_filename) FAIL" report_to_file => "$(G.logfile)"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/106.cf��������������������������������������������������������0000644�0001750�0001750�00000002130�11715232734�015036� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test arrays with list-specified indices (issue 692) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "subout" string => execresult("$(sys.cf_agent) -Kf $(this.promise_filename).sub", "useshell"); } ####################################################### bundle agent check { classes: "ok" not => regcmp(".*Redefinition.*", "$(test.subout)"); reports: DEBUG:: "$(test.subout)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/001.cf��������������������������������������������������������0000644�0001750�0001750�00000002330�11715232734�015032� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test simple variables # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "ten" int => "10"; "ten[ten]" int => "11"; "nine" string => "hello", policy => "free"; "nine" int => "9", policy => "free"; } ####################################################### bundle agent check { classes: "ok_10" not => strcmp("$(test.ten)", "$(test.ten[ten])"); "ok" and => { "ok_10", strcmp("$(test.nine)", "9") }; reports: DEBUG:: "ten == $(test.ten)"; "ten[ten] == $(test.ten[ten])"; "nine == $(test.nine)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/staging/������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�015737� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/staging/002x.cf�����������������������������������������������0000644�0001750�0001750�00000001670�11715232734�016665� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test simple variables failures # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "ten" int => "10.0"; # Not an integer } ####################################################### bundle agent check { reports: DEBUG:: "The int variable assignment should fail"; cfengine_3:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/staging/003x.cf�����������������������������������������������0000644�0001750�0001750�00000001711�11715232734�016662� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test simple variables failures # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "ten" int => "12345678901234567890"; # Integer too big } ####################################################### bundle agent check { reports: DEBUG:: "The int variable assignment should fail"; cfengine_3:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/105.cf��������������������������������������������������������0000644�0001750�0001750�00000002655�11715232734�015051� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test Scoping of "this" variables (issue 349) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: # $(this.promiser) is not available in this context "not_valid" not => strcmp("xyzzy", "$(this.promiser)"); "valid" expression => strcmp("xyzzy", "$(this.promiser)"); "any_promiser" and => { "not_valid", "valid" }; "ok" not => "any_promiser"; reports: DEBUG.not_valid:: "not_valid IS set (and should not be)"; DEBUG.!not_valid:: "not_valid is not set (and should not be)"; DEBUG.valid:: "valid IS set (and should not be)"; DEBUG.!valid:: "valid is not set (and should not be)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/005x.cf�������������������������������������������������������0000644�0001750�0001750�00000001671�11715232734�015235� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test simple variables failures # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "ten" real => "1.2e.3"; # Not a float } ####################################################### bundle agent check { reports: DEBUG:: "The real variable assignment should fail"; cfengine_3:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/010.cf��������������������������������������������������������0000644�0001750�0001750�00000002554�11715232734�015042� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test nested functions # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "oct2" string => '20'; "oct4" slist => { '11', '12' }; "separator" string => ","; "prefix" string => "10.${oct2}.20"; "temp_namelist" slist => { " ", @(oct4) }; "foo" slist => splitstring ( join("${separator}${prefix}", "temp_namelist"), "$(separator)", "99999999999" ); "nameserv" slist => grep ("^[^\s]+$", join(escape("${separator}${prefix}"), "temp_namelist") ); } ####################################################### bundle agent check { classes: "ok" expression => "any"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ����������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/01_basic/008x.cf�������������������������������������������������������0000644�0001750�0001750�00000001701�11715232734�015232� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test simple variables failures # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "ten" real => "1e2345678"; # Exponent too big } ####################################################### bundle agent check { reports: DEBUG:: "The real variable assignment should fail"; cfengine_3:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/����������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�015233� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/003.cf����������������������������������������������������0000644�0001750�0001750�00000003076�11715232734�015774� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test countlinesmatching() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "zero_regex" string => "impossible line"; "one_regex" string => "root:.*"; "positive_regex" string => ".*:\d+:.*"; "zero" int => countlinesmatching("$(zero_regex)", "/etc/passwd"); "one" int => countlinesmatching("$(one_regex)", "/etc/passwd"); "positive" int => countlinesmatching("$(positive_regex)", "/etc/passwd"); } ####################################################### bundle agent check { classes: "ok" and => { strcmp("$(test.zero)", "0"), strcmp("$(test.one)", "1"), isgreaterthan("$(test.positive)", "1"), }; reports: DEBUG:: "Expected 0 matches to '$(test.zero_regex)', found $(test.zero)"; "Expected 1 matches to '$(test.one_regex)', found $(test.one)"; "Expected >1 matches to '$(test.positive_regex)', found $(test.positive)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/002.cf����������������������������������������������������0000644�0001750�0001750�00000003445�11715232734�015773� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test getgid() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: linux|freebsd:: "gid_daemon" int => getgid("daemon"); "gid_sys" int => getgid("sys"); !linux.!freebsd:: "gid_daemon" string => "fixme"; "gid_sys" string => "fixme"; linux:: "gid_0" int => getgid("root"); freebsd:: "gid_0" int => getgid("wheel"); !linux.!freebsd:: "gid_0" string => "fixme"; SuSE|redhat:: "num_daemon" int => "2"; (linux.!SuSE.!redhat)|freebsd:: "num_daemon" int => "1"; !linux.!freebsd:: "num_daemon" string => "fixme"; linux|freebsd:: "num_sys" int => "3"; !linux.!freebsd:: "num_sys" string => "fixme"; } ####################################################### bundle agent check { classes: "ok" and => { strcmp("$(test.gid_0)", "0"), strcmp("$(test.gid_daemon)", "$(test.num_daemon)"), strcmp("$(test.gid_sys)", "$(test.num_sys)"), }; reports: DEBUG:: "root/wheel is GID $(test.gid_0), expected 0"; "daemon is GID $(test.gid_daemon), expected $(test.num_daemon)"; "sys is GID $(test.gid_sys), expected $(test.num_sys)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/013.cf����������������������������������������������������0000644�0001750�0001750�00000003154�11715232734�015772� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test readstringlist() issue 364 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; "$(g.testfile)" create => "true", edit_line => init_fill_in; } bundle edit_line init_fill_in { insert_lines: "123 456"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "nums" slist => readstringlist("$(g.testfile)","NoComment","\s+",5,100); "sum" real => sum("nums"); } ####################################################### bundle agent check { vars: "nums" slist => { @{test.nums} }; classes: "ok_list" not => strcmp("won't match", "$(nums)"); "ok123" expression => strcmp("123", "$(nums)"); "ok456" expression => strcmp("456", "$(nums)"); "ok" and => { "ok_list", "ok123", "ok456", islessthan("$(test.sum)", "579.1"), isgreaterthan("$(test.sum)", "578.9") }; reports: DEBUG:: "nums: $(nums)"; "sum: $(test.sum)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/064x.cf���������������������������������������������������0000644�0001750�0001750�00000002210�11715232734�016160� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => accumulated(1001,1000,1000,1000,1000,40000); } ####################################################### bundle agent check { vars: "time" int => "2682100000"; # 1 year == 365 days classes: "ok" expression => strcmp("$(time)", "$(test.time)"); reports: DEBUG:: "time: $(time)"; "test.time: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/004.cf����������������������������������������������������0000644�0001750�0001750�00000004553�11715232734�015776� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test sum() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "six" ilist => { "1", "2", "3" }; "sum_six" real => sum("six"); "minus_six" ilist => { "-1", "-2", "-3" }; "sum_minus_six" real => sum("minus_six"); "zero" ilist => { "-1", "-2", "3" }; "sum_zero" real => sum("zero"); "sixpoint" rlist => { "1.", "2", "3e0" }; "sum_sixpoint" real => sum("sixpoint"); "minus_sixpoint" rlist => { "-1.", "-2", "-3e0" }; "sum_minus_sixpoint" real => sum("minus_sixpoint"); "zeropoint" rlist => { "-1.", "-2", "3e0" }; "sum_zeropoint" real => sum("zeropoint"); } ####################################################### bundle agent check { classes: "ok" and => { isgreaterthan("$(test.sum_six)", "5.9999999"), islessthan("$(test.sum_six)", "6.0000001"), islessthan("$(test.sum_minus_six)", "-5.9999999"), isgreaterthan("$(test.sum_minus_six)", "-6.0000001"), isgreaterthan("$(test.sum_zero)", "-.0000001"), islessthan("$(test.sum_zero)", ".0000001"), isgreaterthan("$(test.sum_sixpoint)", "5.9999999"), islessthan("$(test.sum_sixpoint)", "6.0000001"), islessthan("$(test.sum_minus_sixpoint)", "-5.9999999"), isgreaterthan("$(test.sum_minus_sixpoint)", "-6.0000001"), isgreaterthan("$(test.sum_zeropoint)", "-.0000001"), islessthan("$(test.sum_zeropoint)", ".0000001"), }; reports: DEBUG:: "test.sum_six = $(test.sum_six)"; "test.sum_minus_six = $(test.sum_minus_six)"; "test.sum_zero = $(test.sum_zero)"; "test.sum_sixpoint = $(test.sum_sixpoint)"; "test.sum_minus_sixpoint = $(test.sum_minus_sixpoint)"; "test.sum_zeropoint = $(test.sum_zeropoint)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/017.cf����������������������������������������������������0000644�0001750�0001750�00000003174�11715232734�016000� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test readstringlist() issue 364 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; "$(g.testfile)" create => "true", edit_line => init_fill_in; } bundle edit_line init_fill_in { insert_lines: "123.456"; "789"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "nums" slist => readstringlist("$(g.testfile)","NoComment","\s+",5,100); "sum" real => sum("nums"); } ####################################################### bundle agent check { vars: "nums" slist => { @{test.nums} }; classes: "ok_list" not => strcmp("won't match", "$(nums)"); "ok123" expression => strcmp("123.456", "$(nums)"); "ok789" expression => strcmp("789", "$(nums)"); "ok" and => { "ok_list", "ok123", "ok789", islessthan("$(test.sum)", "912.457"), isgreaterthan("$(test.sum)", "912.455") }; reports: DEBUG:: "nums: $(nums)"; "sum: $(test.sum)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/018.cf����������������������������������������������������0000644�0001750�0001750�00000003254�11715232734�016000� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test readstringlist() issue 364 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; "$(g.testfile)" create => "true", edit_line => init_fill_in; } bundle edit_line init_fill_in { insert_lines: "123 456 789"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "nums" slist => readstringlist("$(g.testfile)","NoComment","\s+",5,100); "sum" real => sum("nums"); } ####################################################### bundle agent check { vars: "nums" slist => { @{test.nums} }; classes: "ok_list" not => strcmp("won't match", "$(nums)"); "ok123" expression => strcmp("123", "$(nums)"); "ok456" expression => strcmp("456", "$(nums)"); "ok789" expression => strcmp("789", "$(nums)"); "ok" and => { "ok_list", "ok123", "ok456", "ok789", islessthan("$(test.sum)", "1368.1"), isgreaterthan("$(test.sum)", "1367.9") }; reports: DEBUG:: "nums: $(nums)"; "sum: $(test.sum)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/101.cf����������������������������������������������������0000644�0001750�0001750�00000002251�11715232734�015765� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test countlinesmatching() with some kind of failure expected # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "zero_regex" string => "impossible line"; "fail" int => countlinesmatching("$(zero_regex)", "/asd/fgh/qwertyio0p"); } ####################################################### bundle agent check { classes: "ok" and => { strcmp("$(test.fail)", "0"), }; reports: DEBUG:: "Expected 0 matches to '$(test.zero_regex)', found $(test.fail)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/011.cf����������������������������������������������������0000644�0001750�0001750�00000003045�11715232734�015767� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test readstringlist() issue 364 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; "$(g.testfile)" create => "true", edit_line => init_fill_in; } bundle edit_line init_fill_in { insert_lines: "123"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "nums" slist => readstringlist("$(g.testfile)","NoComment","\s+",5,100); "sum" real => sum("nums"); } ####################################################### bundle agent check { vars: "nums" slist => { @{test.nums} }; classes: "ok_list" not => strcmp("won't match", "$(nums)"); "ok123" expression => strcmp("123", "$(nums)"); "ok" and => { "ok_list", islessthan("$(test.sum)", "123.1"), isgreaterthan("$(test.sum)", "122.9") }; reports: DEBUG:: "nums: $(nums)"; "sum: $(test.sum)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/021.cf����������������������������������������������������0000644�0001750�0001750�00000003307�11715232734�015771� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test readstringlist() issue 364, also 366 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; "$(g.testfile)" create => "true", edit_line => init_fill_in; } bundle edit_line init_fill_in { insert_lines: "123,,,456,789"; # "empty" fields } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "nums" slist => readstringlist("$(g.testfile)","NoComment",",",5,100); "sum" real => sum("nums"); } ####################################################### bundle agent check { vars: "nums" slist => { @{test.nums} }; classes: "ok_list" not => strcmp("won't match", "$(nums)"); "ok123" expression => strcmp("123", "$(nums)"); "ok456" expression => strcmp("456", "$(nums)"); "ok789" expression => strcmp("789", "$(nums)"); "ok" and => { "ok_list", "ok123", "ok456", "ok789", islessthan("$(test.sum)", "1368.1"), isgreaterthan("$(test.sum)", "1367.9") }; reports: DEBUG:: "nums: $(nums)"; "sum: $(test.sum)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/201.cf����������������������������������������������������0000644�0001750�0001750�00000002537�11715232734�015775� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test getindices(), size 0 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; files: "$(g.testfile).expected" create => "true"; } ####################################################### bundle agent test { vars: "array" string => "zero"; # Intentionally not an array "keys" slist => getindices("array"); files: "$(g.testfile).actual" create => "true", edit_line => test_insert; reports: DEBUG:: "Inserting line: $(keys)"; } bundle edit_line test_insert { vars: "keys" slist => { @{test.keys} }; insert_lines: "$(keys)"; } ####################################################### bundle agent check { methods: "any" usebundle => sorted_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/056x.cf���������������������������������������������������0000644�0001750�0001750�00000002162�11715232734�016167� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => accumulated("-1",0,0,0,0,100); } ####################################################### bundle agent check { vars: "time" int => "31536100"; # 1 year == 365 days classes: "ok" expression => strcmp("$(time)", "$(test.time)"); reports: DEBUG:: "nums: $(time)"; "sum: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/060x.cf���������������������������������������������������0000644�0001750�0001750�00000002210�11715232734�016154� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => accumulated(1001,1000,1000,1000,1000,40000); } ####################################################### bundle agent check { vars: "time" int => "2682100000"; # 1 year == 365 days classes: "ok" expression => strcmp("$(time)", "$(test.time)"); reports: DEBUG:: "time: $(time)"; "test.time: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/020.cf����������������������������������������������������0000644�0001750�0001750�00000003310�11715232734�015762� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test readstringlist() issue 364, also 366 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; "$(g.testfile)" create => "true", edit_line => init_fill_in; } bundle edit_line init_fill_in { insert_lines: "123 456 789"; # "empty" fields } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "nums" slist => readstringlist("$(g.testfile)","NoComment","\s",5,100); "sum" real => sum("nums"); } ####################################################### bundle agent check { vars: "nums" slist => { @{test.nums} }; classes: "ok_list" not => strcmp("won't match", "$(nums)"); "ok123" expression => strcmp("123", "$(nums)"); "ok456" expression => strcmp("456", "$(nums)"); "ok789" expression => strcmp("789", "$(nums)"); "ok" and => { "ok_list", "ok123", "ok456", "ok789", islessthan("$(test.sum)", "1368.1"), isgreaterthan("$(test.sum)", "1367.9") }; reports: DEBUG:: "nums: $(nums)"; "sum: $(test.sum)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/functions_and_nulls.cf������������������������������������0000644�0001750�0001750�00000004026�11715232734�021535� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test hash() # ####################################################### body common control { bundlesequence => { test }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle agent test { vars: # The nulls terminate the string here "test1" string => execresult("/usr/bin/perl -e 'print \"Test of \0\1\2\n nulls in a string\";'", "noshell"); # Write the same string to a file and read it in again, they are converted "test2" string => execresult("/usr/bin/perl -e 'print \"Test of \0\1\2\n nulls in a string\";' > /tmp/foo", "useshell"); "test3" string => readfile("/tmp/foo","100"); # They are converted here, too, so the split fails "test4a" slist => readstringlist("/tmp/foo","#no comments", "\0", "2", "100"); # And simply quoting the backslash doesn't work, because I think the # regex is also converted "test4b" slist => readstringlist("/tmp/foo","#no comments", "\\0", "2", "100"); # So this doubly incorrect split succeeds because of the two conversions "test4c" slist => readstringlist("/tmp/foo","#no comments", "\\\0", "2", "100"); # readstringarray() (or perhaps getindices) simply breaks "i" int => readstringarray("test5", "/tmp/foo","#no comments", "no split", "2", "100"); "test5_idx" slist => getindices("test5"); # readstringarrayidx() converts the results (same split issues as test4) "j" int => readstringarrayidx("test6", "/tmp/foo","#no comments", "no split", "2", "100"); "test6_idx" slist => getindices("test6"); # This shows that the nulls are really there in the file "od_file" string => execresult("/usr/bin/od -c /tmp/foo", "noshell"); reports: cfengine_3:: "test1: $(test1)"; "test2: $(test2) (<== we expect nothing here)"; "test3: $(test3)"; "test4a: $(test4a)"; "test4b: $(test4b)"; "test4c: $(test4c)"; "test5, $(i) entries: $(test5[$(test5_idx)])"; "test5_idx: $(test5_idx)"; "test6, $(j) entries: $(test6[$(test6_idx)][0])"; "od_file: $(od_file)"; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/052.cf����������������������������������������������������0000644�0001750�0001750�00000002133�11715232734�015771� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => accumulated(0,0,0,0,2,100); } ####################################################### bundle agent check { vars: "time" int => "220"; classes: "ok" expression => strcmp("$(time)", "$(test.time)"); reports: DEBUG:: "time: $(time)"; "test.time: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/network/��������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�016724� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/network/008.cf��������������������������������������������0000644�0001750�0001750�00000003160�11715232734�017464� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test host2ip() # ####################################################### body common control { inputs => { "../../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: # Neither of these are likely to change... "localhost" string => host2ip("localhost"); "a" string => host2ip("a.root-servers.net"); } ####################################################### bundle agent check { vars: "localhost" string => "127.0.0.1"; "localhost_6" string => "::1"; "a" string => "198.41.0.4"; "a_6" string => "2001:503:ba3e::2:30"; classes: "ok_a" or => { strcmp("$(test.a)", "$(a)"), strcmp("$(test.a)", "$(a_6)"), }; "ok_localhost" or => { strcmp("$(test.localhost)", "$(localhost)"), strcmp("$(test.localhost)", "$(localhost_6)"), }; "ok" and => { "ok_a", "ok_localhost", }; reports: DEBUG:: "Expected $(test.localhost) == $(localhost)"; "Expected $(test.a) == ( $(a) or $(a_6) )"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/062x.cf���������������������������������������������������0000644�0001750�0001750�00000002205�11715232734�016162� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => accumulated(0,1000,1000,1000,1001,40000); } ####################################################### bundle agent check { vars: "time" int => "2682100000"; # 1 year == 365 days classes: "ok" expression => strcmp("$(time)", "$(test.time)"); reports: DEBUG:: "time: $(time)"; "test.time: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/300.cf����������������������������������������������������0000644�0001750�0001750�00000002073�11715232734�015770� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test multiline regcmp # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "haystack" string => "foo bar"; "needle" string => ".*"; } ####################################################### bundle agent check { classes: "ok" and => { regcmp("$(test.needle)", "$(test.haystack)") }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/059x.cf���������������������������������������������������0000644�0001750�0001750�00000002205�11715232734�016170� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => accumulated(0,1001,1000,1000,1000,40000); } ####################################################### bundle agent check { vars: "time" int => "2682100000"; # 1 year == 365 days classes: "ok" expression => strcmp("$(time)", "$(test.time)"); reports: DEBUG:: "time: $(time)"; "test.time: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/202.cf����������������������������������������������������0000644�0001750�0001750�00000002641�11715232734�015772� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test getindices(), size 1 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; files: "$(g.testfile).expected" create => "true", edit_line => init_insert; } bundle edit_line init_insert { insert_lines: "alpha"; } ####################################################### bundle agent test { vars: "array[alpha]" string => "zero"; "keys" slist => getindices("array"); files: "$(g.testfile).actual" create => "true", edit_line => test_insert; reports: DEBUG:: "Inserting line: $(keys)"; } bundle edit_line test_insert { vars: "keys" slist => { @{test.keys} }; insert_lines: "$(keys)"; } ####################################################### bundle agent check { methods: "any" usebundle => sorted_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/012.cf����������������������������������������������������0000644�0001750�0001750�00000003160�11715232734�015766� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test readstringlist() issue 364 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; "$(g.testfile)" create => "true", edit_line => init_fill_in; } bundle edit_line init_fill_in { insert_lines: "123"; "456"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "nums" slist => readstringlist("$(g.testfile)","NoComment","\s+",5,100); "sum" real => sum("nums"); } ####################################################### bundle agent check { vars: "nums" slist => { @{test.nums} }; classes: "ok_list" not => strcmp("won't match", "$(nums)"); "ok123" expression => strcmp("123", "$(nums)"); "ok456" expression => strcmp("456", "$(nums)"); "ok" and => { "ok_list", "ok123", "ok456", islessthan("$(test.sum)", "579.1"), isgreaterthan("$(test.sum)", "578.9") }; reports: DEBUG:: "nums: $(nums)"; "sum: $(test.sum)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/007.cf����������������������������������������������������0000644�0001750�0001750�00000005475�11715232734�016005� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test canonify() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "in1" string => "hello"; "expect1" string => "hello"; "out1" string => canonify("$(in1)"); "in2" string => "hello there"; "expect2" string => "hello_there"; "out2" string => canonify("$(in2)"); "in3" string => "/etc/passwd"; "expect3" string => "_etc_passwd"; "out3" string => canonify("$(in3)"); "in4" string => "hello@mumble.com"; "expect4" string => "hello_mumble_com"; "out4" string => canonify("$(in4)"); "in5" string => "!@#$%^&*()_-+={}[]\:;<>,?"; "expect5" string => "_________________________"; "out5" string => canonify("$(in5)"); "in6" string => "Eystein Måløy Stenberg"; "expect6" string => "Eystein_M__l__y_Stenberg"; "out6" string => canonify("$(in6)"); "in7" string => "$(in1) $(in1)"; "expect7" string => "$(in1)_$(in1)"; "out7" string => canonify("$(in1) $(in1)"); "in8" string => "'\"hello\"'"; "expect8" string => "__hello__"; "out8" string => canonify("$(in8)"); } ####################################################### bundle agent check { classes: "ok" and => { strcmp("$(test.expect1)", "$(test.out1)"), strcmp("$(test.expect2)", "$(test.out2)"), strcmp("$(test.expect3)", "$(test.out3)"), strcmp("$(test.expect4)", "$(test.out4)"), strcmp("$(test.expect5)", "$(test.out5)"), strcmp("$(test.expect6)", "$(test.out6)"), strcmp("$(test.expect7)", "$(test.out7)"), strcmp("$(test.expect8)", "$(test.out8)"), }; reports: DEBUG:: "Expected canonify('$(test.in1)') => $(test.out1) == $(test.expect1)"; "Expected canonify('$(test.in2)') => $(test.out2) == $(test.expect2)"; "Expected canonify('$(test.in3)') => $(test.out3) == $(test.expect3)"; "Expected canonify('$(test.in4)') => $(test.out4) == $(test.expect4)"; "Expected canonify('$(test.in5)') => $(test.out5) == $(test.expect5)"; "Expected canonify('$(test.in6)') => $(test.out6) == $(test.expect6)"; "Expected canonify('$(test.in7)') => $(test.out7) == $(test.expect7)"; "Expected canonify('$(test.in8)') => $(test.out8) == $(test.expect8)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/055.cf����������������������������������������������������0000644�0001750�0001750�00000002165�11715232734�016001� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => accumulated(1,0,0,0,0,100); } ####################################################### bundle agent check { vars: "time" int => "31536100"; # 1 year == 365 days classes: "ok" expression => strcmp("$(time)", "$(test.time)"); reports: DEBUG:: "time: $(time)"; "test.time: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/065.cf����������������������������������������������������0000644�0001750�0001750�00000002164�11715232734�016001� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => now(); } ####################################################### bundle agent check { vars: "time" int => "1289601605"; # About when this test was created classes: "ok" expression => islessthan("$(time)", "$(test.time)"); reports: DEBUG:: "time: $(time)"; "test.time: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/001.cf����������������������������������������������������0000644�0001750�0001750�00000003363�11715232734�015771� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test getuid() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: any:: "uid_root" int => getuid("root"); "uid_daemon" int => getuid("daemon"); "uid_bin" int => getuid("bin"); linux.!SuSE.!redhat:: "num_root" int => "0"; "num_daemon" int => "1"; "num_bin" int => "2"; SuSE|redhat:: "num_root" int => "0"; "num_daemon" int => "2"; "num_bin" int => "1"; freebsd:: "num_root" int => "0"; "num_daemon" int => "1"; "num_bin" int => "3"; !freebsd.!linux:: "num_root" string => "fixme"; "num_daemon" string => "fixme"; "num_bin" string => "fixme"; } ####################################################### bundle agent check { classes: "ok" and => { strcmp("$(test.uid_root)", "$(test.num_root)"), strcmp("$(test.uid_daemon)", "$(test.num_daemon)"), strcmp("$(test.uid_bin)", "$(test.num_bin)"), }; reports: DEBUG:: "root is UID $(test.uid_root), expected $(test.num_root)"; "daemon is UID $(test.uid_daemon), expected $(test.num_daemon)"; "bin is UID $(test.uid_bin), expected $(test.num_bin)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/204.cf����������������������������������������������������0000644�0001750�0001750�00000003222�11715232734�015770� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test getindices(), size 5 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; files: "$(g.testfile).expected" create => "true", edit_line => init_insert; } bundle edit_line init_insert { insert_lines: "alpha"; "beta"; "gamma's"; "delta-delta:delta"; "last"; } ####################################################### bundle agent test { vars: "array[alpha]" string => "zero"; "array[beta]" string => "two"; "array[gamma's]" string => "three's"; "array[delta-delta:delta]" string => "four-fore:quatre"; "array[last]" string => "last"; "keys" slist => getindices("array"); files: "$(g.testfile).actual" create => "true", edit_line => test_insert; reports: DEBUG:: "Inserting line: $(keys)"; } bundle edit_line test_insert { vars: "keys" slist => { @{test.keys} }; insert_lines: "$(keys)"; } ####################################################### bundle agent check { methods: "any" usebundle => sorted_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/014.cf����������������������������������������������������0000644�0001750�0001750�00000003153�11715232734�015772� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test readstringlist() issue 364 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; "$(g.testfile)" create => "true", edit_line => init_fill_in; } bundle edit_line init_fill_in { insert_lines: "123.456"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "nums" slist => readstringlist("$(g.testfile)","NoComment","\.",5,100); "sum" real => sum("nums"); } ####################################################### bundle agent check { vars: "nums" slist => { @{test.nums} }; classes: "ok_list" not => strcmp("won't match", "$(nums)"); "ok123" expression => strcmp("123", "$(nums)"); "ok456" expression => strcmp("456", "$(nums)"); "ok" and => { "ok_list", "ok123", "ok456", islessthan("$(test.sum)", "579.1"), isgreaterthan("$(test.sum)", "578.9") }; reports: DEBUG:: "nums: $(nums)"; "sum: $(test.sum)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/063x.cf���������������������������������������������������0000644�0001750�0001750�00000002205�11715232734�016163� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => accumulated(0,1000,1000,1000,1000,40001); } ####################################################### bundle agent check { vars: "time" int => "2682100000"; # 1 year == 365 days classes: "ok" expression => strcmp("$(time)", "$(test.time)"); reports: DEBUG:: "time: $(time)"; "test.time: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/staging/��������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�016667� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/staging/058.cf��������������������������������������������0000644�0001750�0001750�00000002205�11715232734�017433� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => accumulated(0,1000,1000,1000,1000,40000); } ####################################################### bundle agent check { vars: "time" int => "2682100000"; # 1 year == 365 days classes: "ok" expression => strcmp("$(time)", "$(test.time)"); reports: DEBUG:: "time: $(time)"; "test.time: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/staging/006.cf��������������������������������������������0000644�0001750�0001750�00000002707�11715232734�017433� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test diskfree() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "positive_disk" string => "/etc"; "p_disk" string => "/etc/passwd"; "zero_disk" string => "/lkjqeroiu"; "positive" int => diskfree("$(positive_disk)"); "p" int => diskfree("$(p_disk)"); "zero" int => diskfree("$(zero_disk)"); } ####################################################### bundle agent check { classes: "ok" and => { strcmp("$(test.zero)", "0"), isgreaterthan("$(test.p)", "0"), isgreaterthan("$(test.positive)", "0"), }; reports: DEBUG:: "Expected 0 size on $(test.zero_disk), found $(test.zero)"; "Expected >1 size on $(test.p_disk), found $(test.p)"; "Expected >1 size on $(test.positive_disk), found $(test.positive)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/staging/057.cf��������������������������������������������0000644�0001750�0001750�00000002167�11715232734�017441� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => accumulated(315,0,0,0,0,0); } ####################################################### bundle agent check { vars: "time" int => "9933840000"; # 1 year == 365 days classes: "ok" expression => strcmp("$(time)", "$(test.time)"); reports: DEBUG:: "time: $(time)"; "test.time: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/051.cf����������������������������������������������������0000644�0001750�0001750�00000002133�11715232734�015770� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => accumulated(0,0,0,0,0,100); } ####################################################### bundle agent check { vars: "time" int => "100"; classes: "ok" expression => strcmp("$(time)", "$(test.time)"); reports: DEBUG:: "time: $(time)"; "test.time: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/015.cf����������������������������������������������������0000644�0001750�0001750�00000003072�11715232734�015773� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test readstringlist() issue 364 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; "$(g.testfile)" create => "true", edit_line => init_fill_in; } bundle edit_line init_fill_in { insert_lines: "123.456"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "nums" slist => readstringlist("$(g.testfile)","NoComment","\s+",5,100); "sum" real => sum("nums"); } ####################################################### bundle agent check { vars: "nums" slist => { @{test.nums} }; classes: "ok_list" not => strcmp("won't match", "$(nums)"); "ok123" expression => strcmp("123.456", "$(nums)"); "ok" and => { "ok_list", "ok123", islessthan("$(test.sum)", "123.457"), isgreaterthan("$(test.sum)", "123.455") }; reports: DEBUG:: "nums: $(nums)"; "sum: $(test.sum)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/005.cf����������������������������������������������������0000644�0001750�0001750�00000004767�11715232734�016006� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test product() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "six" ilist => { "1", "2", "3" }; "product_six" real => product("six"); "minus_six" ilist => { "-1", "-2", "-3" }; "product_minus_six" real => product("minus_six"); "zero" ilist => { "-1", "0", "3" }; "product_zero" real => product("zero"); "sixpoint" rlist => { "1.", "2", "3" }; "product_sixpoint" real => product("sixpoint"); "minus_sixpoint" rlist => { "-1.", "-2", "-3" }; "product_minus_sixpoint" real => product("minus_sixpoint"); "zeropoint" rlist => { "-1.", "0", "3" }; "product_zeropoint" real => product("zeropoint"); } ####################################################### bundle agent check { classes: "ok" and => { isgreaterthan("$(test.product_six)", "5.9999999"), islessthan("$(test.product_six)", "6.0000001"), islessthan("$(test.product_minus_six)", "-5.9999999"), isgreaterthan("$(test.product_minus_six)", "-6.0000001"), isgreaterthan("$(test.product_zero)", "-.0000001"), islessthan("$(test.product_zero)", ".0000001"), isgreaterthan("$(test.product_sixpoint)", "5.9999999"), islessthan("$(test.product_sixpoint)", "6.0000001"), islessthan("$(test.product_minus_sixpoint)", "-5.9999999"), isgreaterthan("$(test.product_minus_sixpoint)", "-6.0000001"), isgreaterthan("$(test.product_zeropoint)", "-.0000001"), islessthan("$(test.product_zeropoint)", ".0000001"), }; reports: DEBUG:: "test.product_six = $(test.product_six)"; "test.product_minus_six = $(test.product_minus_six)"; "test.product_zero = $(test.product_zero)"; "test.product_sixpoint = $(test.product_sixpoint)"; "test.product_minus_sixpoint = $(test.product_minus_sixpoint)"; "test.product_zeropoint = $(test.product_zeropoint)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������cfengine-3.2.4/tests/01_vars/02_functions/212.cf����������������������������������������������������0000644�0001750�0001750�00000002636�11715232734�015777� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test getvalues(), size 1 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; files: "$(g.testfile).expected" create => "true", edit_line => init_insert; } bundle edit_line init_insert { insert_lines: "zero"; } ####################################################### bundle agent test { vars: "array[alpha]" string => "zero"; "vals" slist => getvalues("array"); files: "$(g.testfile).actual" create => "true", edit_line => test_insert; reports: DEBUG:: "Inserting line: $(vals)"; } bundle edit_line test_insert { vars: "vals" slist => { @{test.vals} }; insert_lines: "$(vals)"; } ####################################################### bundle agent check { methods: "any" usebundle => sorted_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/061x.cf���������������������������������������������������0000644�0001750�0001750�00000002205�11715232734�016161� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => accumulated(0,1000,1000,1001,1000,40000); } ####################################################### bundle agent check { vars: "time" int => "2682100000"; # 1 year == 365 days classes: "ok" expression => strcmp("$(time)", "$(test.time)"); reports: DEBUG:: "time: $(time)"; "test.time: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/203.cf����������������������������������������������������0000644�0001750�0001750�00000002720�11715232734�015771� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test getindices(), size 2 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; files: "$(g.testfile).expected" create => "true", edit_line => init_insert; } bundle edit_line init_insert { insert_lines: "alpha"; "beta"; } ####################################################### bundle agent test { vars: "array[alpha]" string => "zero"; "array[beta]" string => "two"; "keys" slist => getindices("array"); files: "$(g.testfile).actual" create => "true", edit_line => test_insert; reports: DEBUG:: "Inserting line: $(keys)"; } bundle edit_line test_insert { vars: "keys" slist => { @{test.keys} }; insert_lines: "$(keys)"; } ####################################################### bundle agent check { methods: "any" usebundle => sorted_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/016.cf����������������������������������������������������0000644�0001750�0001750�00000003260�11715232734�015773� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test readstringlist() issue 364 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; "$(g.testfile)" create => "true", edit_line => init_fill_in; } bundle edit_line init_fill_in { insert_lines: "123 456"; "789"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "nums" slist => readstringlist("$(g.testfile)","NoComment","\s+",5,100); "sum" real => sum("nums"); } ####################################################### bundle agent check { vars: "nums" slist => { @{test.nums} }; classes: "ok_list" not => strcmp("won't match", "$(nums)"); "ok123" expression => strcmp("123", "$(nums)"); "ok456" expression => strcmp("456", "$(nums)"); "ok789" expression => strcmp("789", "$(nums)"); "ok" and => { "ok_list", "ok123", "ok456", "ok789", islessthan("$(test.sum)", "1368.1"), isgreaterthan("$(test.sum)", "1367.9") }; reports: DEBUG:: "nums: $(nums)"; "sum: $(test.sum)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/211.cf����������������������������������������������������0000644�0001750�0001750�00000002535�11715232734�015774� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test getvalues(), size 0 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; files: "$(g.testfile).expected" create => "true"; } ####################################################### bundle agent test { vars: "array" string => "zero"; # Intentionally not an array "vals" slist => getvalues("array"); files: "$(g.testfile).actual" create => "true", edit_line => test_insert; reports: DEBUG:: "Inserting line: $(vals)"; } bundle edit_line test_insert { vars: "vals" slist => { @{test.vals} }; insert_lines: "$(vals)"; } ####################################################### bundle agent check { methods: "any" usebundle => sorted_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/010.cf����������������������������������������������������0000644�0001750�0001750�00000002077�11715232734�015772� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test hostsseen() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "hosts" slist => hostsseen("inf", "lastseen", "name"); } ####################################################### bundle agent check { vars: "hosts" slist => { @{test.hosts} }; classes: "ok" expression => "any"; # XXX # I don't know how to test hostsseen! reports: DEBUG:: "$(hosts)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/054.cf����������������������������������������������������0000644�0001750�0001750�00000002164�11715232734�015777� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => accumulated(0,1,0,0,0,100); } ####################################################### bundle agent check { vars: "time" int => "2592100"; # 1 month == 30 days classes: "ok" expression => strcmp("$(time)", "$(test.time)"); reports: DEBUG:: "time: $(time)"; "test.time: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/053.cf����������������������������������������������������0000644�0001750�0001750�00000002135�11715232734�015774� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test accumulated() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "time" int => accumulated(0,0,1,1,2,100); } ####################################################### bundle agent check { vars: "time" int => "90220"; classes: "ok" expression => strcmp("$(time)", "$(test.time)"); reports: DEBUG:: "time: $(time)"; "test.time: $(test.time)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/01_vars/02_functions/019.cf����������������������������������������������������0000644�0001750�0001750�00000003070�11715232734�015775� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test readstringlist() issue 364 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; "$(g.testfile)" create => "true", edit_line => init_fill_in; } bundle edit_line init_fill_in { insert_lines: "123.456"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "nums" slist => readstringlist("$(g.testfile)","NoComment","X",5,100); "sum" real => sum("nums"); } ####################################################### bundle agent check { vars: "nums" slist => { @{test.nums} }; classes: "ok_list" not => strcmp("won't match", "$(nums)"); "ok123" expression => strcmp("123.456", "$(nums)"); "ok" and => { "ok_list", "ok123", islessthan("$(test.sum)", "123.457"), isgreaterthan("$(test.sum)", "123.455") }; reports: DEBUG:: "nums: $(nums)"; "sum: $(test.sum)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/����������������������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�013051� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/05_classes/�����������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�015012� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/05_classes/002.cf�����������������������������������������������������0000644�0001750�0001750�00000003671�11715232734�015553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line that isn't there, ensure that a promise_kept class gets set # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "keep this and this keep this too"; "expected" string => "keep this and this keep this too"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => ".*delete.*"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => full_set; } body classes full_set { promise_kept => { "pass" }; promise_repaired => { "fail" }; repair_failed => { "fail" }; repair_denied => { "fail" }; repair_timeout => { "fail" }; } ####################################################### bundle agent check { classes: "no_difference" expression => returnszero( "/usr/bin/diff -q $(g.testfile).actual $(g.testfile).expected", "noshell"); "ok" and => { "pass", "!fail", "no_difference" }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������cfengine-3.2.4/tests/10_files/05_classes/004.cf�����������������������������������������������������0000644�0001750�0001750�00000004036�11715232734�015551� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line that isn't there, action_policy=>"warn", ensure that a promise_kept class gets set # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "keep this and this keep this too"; "expected" string => "keep this and this keep this too"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => ".*delete.*"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" action => warn_only, classes => full_set; } body action warn_only { action_policy => "warn"; } body classes full_set { promise_kept => { "pass" }; promise_repaired => { "fail" }; repair_failed => { "fail" }; repair_denied => { "fail" }; repair_timeout => { "fail" }; } ####################################################### bundle agent check { classes: "no_difference" expression => returnszero( "/usr/bin/diff -q $(g.testfile).actual $(g.testfile).expected", "noshell"); "ok" and => { "pass", "!fail", "no_difference" }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/05_classes/006.cf�����������������������������������������������������0000644�0001750�0001750�00000004034�11715232734�015551� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line that isn't there, action_policy=>"nop", ensure that a promise_kept class gets set # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "keep this and this keep this too"; "expected" string => "keep this and this keep this too"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => ".*delete.*"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" action => warn_only, classes => full_set; } body action warn_only { action_policy => "nop"; } body classes full_set { promise_kept => { "pass" }; promise_repaired => { "fail" }; repair_failed => { "fail" }; repair_denied => { "fail" }; repair_timeout => { "fail" }; } ####################################################### bundle agent check { classes: "no_difference" expression => returnszero( "/usr/bin/diff -q $(g.testfile).actual $(g.testfile).expected", "noshell"); "ok" and => { "pass", "!fail", "no_difference" }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/05_classes/001.cf�����������������������������������������������������0000644�0001750�0001750�00000003700�11715232734�015543� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line, ensure that a promise_repaired class gets set # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "keep this and this but delete one line keep this too"; "expected" string => "keep this and this keep this too"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => ".*delete.*"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => full_set; } body classes full_set { promise_kept => { "fail" }; promise_repaired => { "pass" }; repair_failed => { "fail" }; repair_denied => { "fail" }; repair_timeout => { "fail" }; } ####################################################### bundle agent check { classes: "no_difference" expression => returnszero( "/usr/bin/diff -q $(g.testfile).actual $(g.testfile).expected", "noshell"); "ok" and => { "pass", "!fail", "no_difference" }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�016057� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/119.cf������������������������������������������������0000644�0001750�0001750�00000003741�11715232734�016627� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that whitespace_policy other than # ignore_leading works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_embedded", "ignore_trailing" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/102.cf������������������������������������������������0000644�0001750�0001750�00000003711�11715232734�016614� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that exact match works when given a # not-exact match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "exact_match" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/121.cf������������������������������������������������0000644�0001750�0001750�00000003706�11715232734�016621� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that whitespace_policy ignore_embedded # works when given a close-enough exact match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/003.cf������������������������������������������������0000644�0001750�0001750�00000003450�11715232734�016614� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines at the end of a partially bounded region # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Four END"; "expected" string => "BEGIN One potato Two potato Four END Three potatoe"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " One potato Two potato Three potatoe Four"; files: "$(g.testfile).actual" create => "true", edit_line => test_insert("$(test.tstr)"); } bundle edit_line test_insert(str) { insert_lines: "$(str)" select_region => test_region; } body select_region test_region { select_start => "BEGIN"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/002.cf������������������������������������������������0000644�0001750�0001750�00000003471�11715232734�016616� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines at the end of a fully bounded region # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Four END"; "expected" string => "BEGIN One potato Two potato Four Three potatoe END"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " One potato Two potato Three potatoe Four"; files: "$(g.testfile).actual" create => "true", edit_line => test_insert("$(test.tstr)"); } bundle edit_line test_insert(str) { insert_lines: "$(str)" select_region => test_region; } body select_region test_region { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/215.cf������������������������������������������������0000644�0001750�0001750�00000003765�11715232734�016632� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that whitespace_policy ignore_trailing # works when given a close-enough exact match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_trailing" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������cfengine-3.2.4/tests/10_files/09_insert_lines/118.cf������������������������������������������������0000644�0001750�0001750�00000003772�11715232734�016632� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that whitespace_policy other than # ignore_leading works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces "; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_trailing" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������cfengine-3.2.4/tests/10_files/09_insert_lines/013.cf������������������������������������������������0000644�0001750�0001750�00000003442�11715232734�016616� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines before the last instance of a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Four END"; "insert" string => " One potato Two potato Three potatoe Spuds spuds spuds Four"; "expected" string => "BEGIN One potato Two potato Two potatos Four END Three potatoe Spuds spuds spuds"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(str) { insert_lines: "$(str)" insert_type => "file"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/301.cf������������������������������������������������0000644�0001750�0001750�00000002745�11715232734�016623� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test that specifying whitespace_policy escapes meta-characters (Issue 644) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "expected" string => "*foobar*"; files: "$(g.testfile).expected" create => "true", edit_line => init_insert("$(init.expected)"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => set_value_rev, create => "true"; } bundle edit_line set_value_rev { insert_lines: "*foobar*" whitespace_policy => { "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/108.cf������������������������������������������������0000644�0001750�0001750�00000003666�11715232734�016633� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that pairs of whitespace_policy work # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_leading", "ignore_trailing", "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/221.cf������������������������������������������������0000644�0001750�0001750�00000003764�11715232734�016626� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that whitespace_policy ignore_embedded # works when given a close-enough exact match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������cfengine-3.2.4/tests/10_files/09_insert_lines/009.cf������������������������������������������������0000644�0001750�0001750�00000003614�11715232734�016624� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines after the last instance of a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Four END"; "expected" string => "BEGIN One potato Two potato Two potatos Three potatoe Four END"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " One potato Two potato Three potatoe Four"; files: "$(g.testfile).actual" create => "true", edit_line => test_insert("$(test.tstr)"); } bundle edit_line test_insert(str) { insert_lines: "$(str)" location => test_after_last(".*potato.*"); } body location test_after_last(line) { before_after => "after"; first_last => "last"; select_line_matching => "$(line)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/004.cf������������������������������������������������0000644�0001750�0001750�00000004155�11715232734�016620� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines at the end of a fully bounded # region, before the first instance of a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => " big potatoes BEGIN One potato Two potato Two potatos Four END small potatoes"; "expected" string => " big potatoes BEGIN Three potatoe One potato Two potato Two potatos Four END small potatoes"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " One potato Two potato Three potatoe Four"; files: "$(g.testfile).actual" create => "true", edit_line => test_insert("$(test.tstr)"); } bundle edit_line test_insert(str) { insert_lines: "$(str)" select_region => test_region, location => test_before_first(".*potato.*"); } body select_region test_region { select_start => "BEGIN"; select_end => "END"; } body location test_before_first(line) { before_after => "before"; first_last => "first"; select_line_matching => "$(line)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/218.cf������������������������������������������������0000644�0001750�0001750�00000004050�11715232734�016621� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that whitespace_policy other than # ignore_leading works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces "; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_trailing" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/116.cf������������������������������������������������0000644�0001750�0001750�00000003706�11715232734�016625� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that whitespace_policy ignore_leading # works when given a close-enough exact match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_leading" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/101.cf������������������������������������������������0000644�0001750�0001750�00000003644�11715232734�016620� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that exact match works when given an # exact match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "exact_match" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/207.cf������������������������������������������������0000644�0001750�0001750�00000003771�11715232734�016630� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that pairs of whitespace_policy work # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_trailing", "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������cfengine-3.2.4/tests/10_files/09_insert_lines/011.cf������������������������������������������������0000644�0001750�0001750�00000003620�11715232734�016612� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines before the last instance of a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Four END"; "expected" string => "BEGIN One potato Two potato Three potatoe Two potatos Four END"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " One potato Two potato Three potatoe Four"; files: "$(g.testfile).actual" create => "true", edit_line => test_insert("$(test.tstr)"); } bundle edit_line test_insert(str) { insert_lines: "$(str)" location => test_before_last(".*potato.*"); } body location test_before_last(line) { before_after => "before"; first_last => "last"; select_line_matching => "$(line)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/201.cf������������������������������������������������0000644�0001750�0001750�00000003722�11715232734�016616� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that exact match works when given an # exact match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "exact_match" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/006.cf������������������������������������������������0000644�0001750�0001750�00000004151�11715232734�016616� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines at the end of a fully bounded # region, after the first instance of a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => " big potatoes BEGIN One potato Two potato Two potatos Four END small potatoes"; "expected" string => " big potatoes BEGIN One potato Three potatoe Two potato Two potatos Four END small potatoes"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " One potato Two potato Three potatoe Four"; files: "$(g.testfile).actual" create => "true", edit_line => test_insert("$(test.tstr)"); } bundle edit_line test_insert(str) { insert_lines: "$(str)" select_region => test_region, location => test_after_first(".*potato.*"); } body select_region test_region { select_start => "BEGIN"; select_end => "END"; } body location test_after_first(line) { before_after => "after"; first_last => "first"; select_line_matching => "$(line)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/206.cf������������������������������������������������0000644�0001750�0001750�00000003770�11715232734�016626� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that pairs of whitespace_policy work # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_leading", "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������cfengine-3.2.4/tests/10_files/09_insert_lines/216.cf������������������������������������������������0000644�0001750�0001750�00000003764�11715232734�016632� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that whitespace_policy ignore_leading # works when given a close-enough exact match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_leading" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������cfengine-3.2.4/tests/10_files/09_insert_lines/300.cf������������������������������������������������0000644�0001750�0001750�00000010042�11715232734�016607� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test insertion of newlines (Issue 555) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "template", "expected" }; "template" string => "## # Sendmail Alias File # @(#)B11.23_LRaliases $Revision: 1.1.212.1 $ $Date: 99/09/13 15:13:16 $ # # Mail to an alias in this file will be sent to the users, programs, or # files designated following the colon. # Aliases defined in this file will NOT be expanded in headers from # mailx(1), but WILL be visible over networks and in headers from # rmail(1). # # >>>>>>>>>> The program \"/usr/sbin/newaliases\" must be run after # >> NOTE >> this file is updated, or else any changes will not be # >>>>>>>>>> visible to sendmail. ## # Alias for mailer daemon MAILER-DAEMON : root # RFC 822 requires that every host have a mail address \"postmaster\" postmaster : root # Aliases to handle mail to msgs and news nobody : /dev/null # System Admistration aliases operator : root uucp : root daemon : root # Ftp maintainer. ftp-bugs : root # Local aliases root : dcpds.sysadmin@dcpds.cpms.osd.mil,:include:/etc/mail/aliases.root oracle : dcpds.dba@dcpds.cpms.osd.mil exinfac : dcpds.exits@dcpds.cpms.osd.mil applmgr : dcpds.dba@dcpds.cpms.osd.mil"; "expected" string => "## # Sendmail Alias File # @(#)B11.23_LRaliases $Revision: 1.1.212.1 $ $Date: 99/09/13 15:13:16 $ # # Mail to an alias in this file will be sent to the users, programs, or # files designated following the colon. # Aliases defined in this file will NOT be expanded in headers from # mailx(1), but WILL be visible over networks and in headers from # rmail(1). # # >>>>>>>>>> The program \"/usr/sbin/newaliases\" must be run after # >> NOTE >> this file is updated, or else any changes will not be # >>>>>>>>>> visible to sendmail. ## # Alias for mailer daemon MAILER-DAEMON : root # RFC 822 requires that every host have a mail address \"postmaster\" postmaster : root # Aliases to handle mail to msgs and news nobody : /dev/null # System Admistration aliases operator : root uucp : root daemon : root # Ftp maintainer. ftp-bugs : root # Local aliases root : dcpds.sysadmin@dcpds.cpms.osd.mil,:include:/etc/mail/aliases.root oracle : dcpds.dba@dcpds.cpms.osd.mil exinfac : dcpds.exits@dcpds.cpms.osd.mil applmgr : dcpds.dba@dcpds.cpms.osd.mil stgmgmt : :include:/etc/mail/aliases.stgmgmt"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "MailAliases" slist => { "stgmgmt : :include:/etc/mail/aliases.stgmgmt" }; files: "$(g.testfile).actual" edit_line => copy_and_append_lines("$(g.testfile).template", "@(this.MailAliases)"), edit_defaults => empty, create => "true"; } bundle edit_line copy_and_append_lines(file,lines) { insert_lines: "$(file)" insert_type => "file"; "$(lines)" insert_type => "string"; } body edit_defaults empty { empty_file_before_editing => "true"; edit_backup => "false"; max_file_size => "300000"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/214.cf������������������������������������������������0000644�0001750�0001750�00000004067�11715232734�016625� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that whitespace_policy other than # ignore_embedded works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces "; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_leading", "ignore_trailing" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/202.cf������������������������������������������������0000644�0001750�0001750�00000003767�11715232734�016630� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that exact match works when given a # not-exact match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "exact_match" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������cfengine-3.2.4/tests/10_files/09_insert_lines/213.cf������������������������������������������������0000644�0001750�0001750�00000004045�11715232734�016620� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that whitespace_policy other than # ignore_embedded works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces "; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_trailing" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/012.cf������������������������������������������������0000644�0001750�0001750�00000003720�11715232734�016614� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines before the last instance of a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Four END"; "insert" string => " One potato Two potato Three potatoe Spuds spuds spuds Four"; "expected" string => "BEGIN One potato Two potato Three potatoe Spuds spuds spuds Two potatos Four END"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(str) { insert_lines: "$(str)" insert_type => "file", location => test_before_last(".*potato.*"); } body location test_before_last(line) { before_after => "before"; first_last => "last"; select_line_matching => "$(line)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/007.cf������������������������������������������������0000644�0001750�0001750�00000004151�11715232734�016617� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines at the end of a fully bounded # region, before the last instance of a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => " big potatoes BEGIN One potato Two potato Two potatos Four END small potatoes"; "expected" string => " big potatoes BEGIN One potato Two potato Three potatoe Two potatos Four END small potatoes"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " One potato Two potato Three potatoe Four"; files: "$(g.testfile).actual" create => "true", edit_line => test_insert("$(test.tstr)"); } bundle edit_line test_insert(str) { insert_lines: "$(str)" select_region => test_region, location => test_before_last(".*potato.*"); } body select_region test_region { select_start => "BEGIN"; select_end => "END"; } body location test_before_last(line) { before_after => "before"; first_last => "last"; select_line_matching => "$(line)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/222.cf������������������������������������������������0000644�0001750�0001750�00000004044�11715232734�016617� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that whitespace_policy other than # ignore_embedded works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces "; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_leading" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/103.cf������������������������������������������������0000644�0001750�0001750�00000003761�11715232734�016622� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that whitespace_policy other than # ignore_trailing works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������cfengine-3.2.4/tests/10_files/09_insert_lines/104.cf������������������������������������������������0000644�0001750�0001750�00000004003�11715232734�016611� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that whitespace_policy other than # ignore_trailing works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_leading", "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/117.cf������������������������������������������������0000644�0001750�0001750�00000003716�11715232734�016627� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that whitespace_policy other than # ignore_leading works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/106.cf������������������������������������������������0000644�0001750�0001750�00000003712�11715232734�016621� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that pairs of whitespace_policy work # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_leading", "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/001.cf������������������������������������������������0000644�0001750�0001750�00000003274�11715232734�016616� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Four END"; "expected" string => "BEGIN One potato Two potato Four END Three potatoe"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " One potato Two potato Three potatoe Four"; files: "$(g.testfile).actual" create => "true", edit_line => test_insert("$(test.tstr)"); } bundle edit_line test_insert(str) { insert_lines: "BEGIN$(const.n)$(str)$(const.n)END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/204.cf������������������������������������������������0000644�0001750�0001750�00000004061�11715232734�016616� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that whitespace_policy other than # ignore_trailing works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_leading", "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/113.cf������������������������������������������������0000644�0001750�0001750�00000003767�11715232734�016631� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that whitespace_policy other than # ignore_embedded works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces "; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_trailing" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������cfengine-3.2.4/tests/10_files/09_insert_lines/014.cf������������������������������������������������0000644�0001750�0001750�00000003662�11715232734�016623� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines before the last instance of a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Four END"; "insert" string => " One potato Two potato Three potatoe Spuds spuds spuds Four"; "expected" string => "BEGIN One potato Two potato Two potatos Four END Three potatoe Spuds spuds spuds"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(str) { insert_lines: "$(str)" insert_type => "file", insert_select => test_insert_exclude("Xhree"); } body insert_select test_insert_exclude(r) { insert_if_not_match_from_list => { "$(r)" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/122.cf������������������������������������������������0000644�0001750�0001750�00000003766�11715232734�016630� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that whitespace_policy other than # ignore_embedded works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces "; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_leading" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������cfengine-3.2.4/tests/10_files/09_insert_lines/105.cf������������������������������������������������0000644�0001750�0001750�00000003712�11715232734�016620� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that pairs of whitespace_policy work # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_leading", "ignore_trailing" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/107.cf������������������������������������������������0000644�0001750�0001750�00000003713�11715232734�016623� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that pairs of whitespace_policy work # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_trailing", "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/015.cf������������������������������������������������0000644�0001750�0001750�00000003674�11715232734�016627� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines before the last instance of a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Four END"; "insert" string => " One potato Two potato Three potatoe Spuds spuds spuds Four"; "expected" string => "BEGIN One potato Two potato Two potatos Four END Three potatoe Spuds spuds spuds"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", insert_select => test_insert_exclude("Three"); } body insert_select test_insert_exclude(r) { insert_if_not_match_from_list => { "$(r)" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/005.cf������������������������������������������������0000644�0001750�0001750�00000004145�11715232734�016620� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines at the end of a fully bounded # region, after the last instance of a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => " big potatoes BEGIN One potato Two potato Two potatos Four END small potatoes"; "expected" string => " big potatoes BEGIN One potato Two potato Two potatos Three potatoe Four END small potatoes"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " One potato Two potato Three potatoe Four"; files: "$(g.testfile).actual" create => "true", edit_line => test_insert("$(test.tstr)"); } bundle edit_line test_insert(str) { insert_lines: "$(str)" select_region => test_region, location => test_after_last(".*potato.*"); } body select_region test_region { select_start => "BEGIN"; select_end => "END"; } body location test_after_last(line) { before_after => "after"; first_last => "last"; select_line_matching => "$(line)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/212.cf������������������������������������������������0000644�0001750�0001750�00000004036�11715232734�016617� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that whitespace_policy other than # ignore_trailing works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_leading" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/203.cf������������������������������������������������0000644�0001750�0001750�00000004037�11715232734�016620� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that whitespace_policy other than # ignore_trailing works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/016.cf������������������������������������������������0000644�0001750�0001750�00000003656�11715232734�016630� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines before the last instance of a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Four END"; "insert" string => " One potato Two potato Three potatoe Spuds spuds spuds Four"; "expected" string => "BEGIN One potato Two potato Two potatos Four END Spuds spuds spuds"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", insert_select => test_insert_exclude(".*Three.*"); } body insert_select test_insert_exclude(r) { insert_if_not_match_from_list => { "$(r)" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/208.cf������������������������������������������������0000644�0001750�0001750�00000003744�11715232734�016631� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that pairs of whitespace_policy work # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_leading", "ignore_trailing", "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/112.cf������������������������������������������������0000644�0001750�0001750�00000003760�11715232734�016621� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that whitespace_policy other than # ignore_trailing works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_leading" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������cfengine-3.2.4/tests/10_files/09_insert_lines/219.cf������������������������������������������������0000644�0001750�0001750�00000004070�11715232734�016624� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that whitespace_policy other than # ignore_leading works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces "; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_embedded", "ignore_trailing" }; } ####################################################### bundle agent check { methods: "any" usebundle => check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)", "yes"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/010.cf������������������������������������������������0000644�0001750�0001750�00000003620�11715232734�016611� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines after the first instance of a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Four END"; "expected" string => "BEGIN One potato Three potatoe Two potato Two potatos Four END"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " One potato Two potato Three potatoe Four"; files: "$(g.testfile).actual" create => "true", edit_line => test_insert("$(test.tstr)"); } bundle edit_line test_insert(str) { insert_lines: "$(str)" location => test_after_first(".*potato.*"); } body location test_after_first(line) { before_after => "after"; first_last => "first"; select_line_matching => "$(line)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/115.cf������������������������������������������������0000644�0001750�0001750�00000003754�11715232734�016627� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that whitespace_policy ignore_trailing # works when given a close-enough exact match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_trailing" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������cfengine-3.2.4/tests/10_files/09_insert_lines/008.cf������������������������������������������������0000644�0001750�0001750�00000003624�11715232734�016624� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert a number of lines before the first instance of a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Four END"; "expected" string => "BEGIN Three potatoe One potato Two potato Two potatos Four END"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " One potato Two potato Three potatoe Four"; files: "$(g.testfile).actual" create => "true", edit_line => test_insert("$(test.tstr)"); } bundle edit_line test_insert(str) { insert_lines: "$(str)" location => test_before_first(".*potato.*"); } body location test_before_first(line) { before_after => "before"; first_last => "first"; select_line_matching => "$(line)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/114.cf������������������������������������������������0000644�0001750�0001750�00000004011�11715232734�016611� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a variable, verify that whitespace_policy other than # ignore_embedded works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces "; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(init.insert)"); } bundle edit_line test_insert(lines) { insert_lines: "$(lines)" whitespace_policy => { "ignore_leading", "ignore_trailing" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/217.cf������������������������������������������������0000644�0001750�0001750�00000004032�11715232734�016620� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that whitespace_policy other than # ignore_leading works when given a not-close-enough match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_embedded" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/09_insert_lines/205.cf������������������������������������������������0000644�0001750�0001750�00000003770�11715232734�016625� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Insert lines from a file, verify that pairs of whitespace_policy work # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected", "insert" }; "actual" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END"; "insert" string => " One potato Two potato Three potatoe Leading embedded and trailing spaces Four"; "expected" string => "BEGIN One potato Two potato Two potatos Leading embedded and trailing spaces Four END Three potatoe Leading embedded and trailing spaces"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_insert("$(g.testfile).insert"); } bundle edit_line test_insert(filename) { insert_lines: "$(filename)" insert_type => "file", whitespace_policy => { "ignore_leading", "ignore_trailing" }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������cfengine-3.2.4/tests/10_files/07_delete_lines/������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�016013� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/347.cf������������������������������������������������0000644�0001750�0001750�00000003761�11715232734�016570� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@{test.tstr}"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), not_matching => "false", select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������cfengine-3.2.4/tests/10_files/07_delete_lines/413.cf������������������������������������������������0000644�0001750�0001750�00000003503�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete multiple lines if they are not in the exact order # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)$(const.n)BEGIN$(const.n)END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/128.cf������������������������������������������������0000644�0001750�0001750�00000004104�11715232734�016555� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/102.cf������������������������������������������������0000644�0001750�0001750�00000003702�11715232734�016550� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete a line # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe "; # NOTE, DOES NOT MATCH! files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/223.cf������������������������������������������������0000644�0001750�0001750�00000003721�11715232734�016555� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete a line, set a class # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe "; # NOTE, DOES NOT MATCH! files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => test_class("ok"), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body classes test_class(a) { promise_kept => { "$(a)" }; } ####################################################### bundle agent check { reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/343.cf������������������������������������������������0000644�0001750�0001750�00000004012�11715232734�016552� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "C" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/524.cf������������������������������������������������0000644�0001750�0001750�00000003743�11715232734�016565� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " Three potatoe" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/003.cf������������������������������������������������0000644�0001750�0001750�00000003140�11715232734�016544� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a contiguous group of three lines # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN Three potatoe END trailer trailer"; "expected" string => "header header trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => "BEGIN Three potatoe END"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/039.cf������������������������������������������������0000644�0001750�0001750�00000003515�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "Three", "GI", "ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/246.cf������������������������������������������������0000644�0001750�0001750�00000003477�11715232734�016572� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" not_matching => "false", select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/535.cf������������������������������������������������0000644�0001750�0001750�00000003762�11715232734�016570� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN Two potato Three potatoe Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������cfengine-3.2.4/tests/10_files/07_delete_lines/002.cf������������������������������������������������0000644�0001750�0001750�00000003305�11715232734�016546� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe "; # NOTE, DOES NOT MATCH! files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/401.cf������������������������������������������������0000644�0001750�0001750�00000003473�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/235.cf������������������������������������������������0000644�0001750�0001750�00000004031�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/326.cf������������������������������������������������0000644�0001750�0001750�00000004070�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "header", " Two.*", "BEGIN", "END" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/146.cf������������������������������������������������0000644�0001750�0001750�00000003546�11715232734�016566� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" not_matching => "false", select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/430.cf������������������������������������������������0000644�0001750�0001750�00000004003�11715232734�016547� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/244.cf������������������������������������������������0000644�0001750�0001750�00000004050�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/247.cf������������������������������������������������0000644�0001750�0001750�00000004001�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@{test.tstr}"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), not_matching => "false", select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/422.cf������������������������������������������������0000644�0001750�0001750�00000003566�11715232734�016565� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line, set a class # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => test_class("ok"), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body classes test_class(a) { promise_repaired => { "$(a)" }; } ####################################################### bundle agent check { reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/528.cf������������������������������������������������0000644�0001750�0001750�00000003766�11715232734�016576� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN Two potato Three potatoe Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������cfengine-3.2.4/tests/10_files/07_delete_lines/225.cf������������������������������������������������0000644�0001750�0001750�00000004172�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: # Note - regex doesn't qualify for "starts_with"! "tstr" slist => { " Three potatoe", " Two.*", "BEGIN", "END" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/215.cf������������������������������������������������0000644�0001750�0001750�00000003672�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines (different order than in original) # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: " Three potatoe" select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/118.cf������������������������������������������������0000644�0001750�0001750�00000004023�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way (different order than original) # Region editing, include_start_delimiter and include_end_delimiter # Second edit destroys the region # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { " Three potatoe", "BEGIN", "END" }; delete_lines: # Second edit destroys the region "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/013.cf������������������������������������������������0000644�0001750�0001750�00000003233�11715232734�016550� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete multiple lines if they are not in the exact order # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "BEGIN$(const.n)$(str)$(const.n)END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/410.cf������������������������������������������������0000644�0001750�0001750�00000003563�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way, different patterns # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { ".*BEGIN.*", ".*Three.*", ".*END.*" }; delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/301.cf������������������������������������������������0000644�0001750�0001750�00000003531�11715232734�016551� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/518.cf������������������������������������������������0000644�0001750�0001750�00000003566�11715232734�016573� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way (different order than original) # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header header One potato Two potato Four trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { " Three potatoe", "BEGIN", "END" }; delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/035.cf������������������������������������������������0000644�0001750�0001750�00000003502�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/417.cf������������������������������������������������0000644�0001750�0001750�00000003672�11715232734�016567� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines, using regexes different way (different order than in original) # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "^\s+Three.*$" # Anchors should make no difference select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/027.cf������������������������������������������������0000644�0001750�0001750�00000003446�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/108.cf������������������������������������������������0000644�0001750�0001750�00000004104�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines, using regexes different way # Region editing, include_start_delimiter and include_end_delimiter # Region is destroyed by first edit # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: # Region is destroyed by first edit "BEGIN" select_region => test_select; "^\s+Three.*$" # Anchors should make no difference select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/243.cf������������������������������������������������0000644�0001750�0001750�00000004032�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "C" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/126.cf������������������������������������������������0000644�0001750�0001750�00000004157�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "header", " Two.*", "BEGIN", "END" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/009.cf������������������������������������������������0000644�0001750�0001750�00000003255�11715232734�016561� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { "BEGIN", " Three potatoe", "END" }; delete_lines: "$(str)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/403.cf������������������������������������������������0000644�0001750�0001750�00000003414�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a group of three lines at once, should do nothing because # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN Three potatoe END trailer trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => "BEGIN Three potatoe END"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/004.cf������������������������������������������������0000644�0001750�0001750�00000003201�11715232734�016543� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a contiguous group of three lines, different way # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN Three potatoe END trailer trailer"; "expected" string => "header header trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "BEGIN$(const.n)$(str)$(const.n)END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/427.cf������������������������������������������������0000644�0001750�0001750�00000003717�11715232734�016570� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/513.cf������������������������������������������������0000644�0001750�0001750�00000003500�11715232734�016552� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete multiple lines if they are not in the exact order # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)$(const.n)BEGIN$(const.n)END" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/332.cf������������������������������������������������0000644�0001750�0001750�00000004033�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*", ".*GI.*", ".*ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/440.cf������������������������������������������������0000644�0001750�0001750�00000004007�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "eade", "EGI", "ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/034.cf������������������������������������������������0000644�0001750�0001750�00000003442�11715232734�016555� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/218.cf������������������������������������������������0000644�0001750�0001750�00000003651�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way (different order than original) # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { " Three potatoe", "BEGIN", "END" }; delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/519.cf������������������������������������������������0000644�0001750�0001750�00000003612�11715232734�016564� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way, different patterns (different order than original) # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header header One potato Two potato Four trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { ".*Three.*", ".*BEGIN.*", ".*END.*" }; delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/124.cf������������������������������������������������0000644�0001750�0001750�00000004061�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " Three potatoe" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/539.cf������������������������������������������������0000644�0001750�0001750�00000003775�11715232734�016600� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "Three", "GI", "ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���cfengine-3.2.4/tests/10_files/07_delete_lines/017.cf������������������������������������������������0000644�0001750�0001750�00000003320�11715232734�016551� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines, using regexes different way (different order than in original) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "^\s+Three.*$"; # Anchors should make no difference "BEGIN"; "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/232.cf������������������������������������������������0000644�0001750�0001750�00000004053�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*", ".*GI.*", ".*ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/036.cf������������������������������������������������0000644�0001750�0001750�00000003510�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*C.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/047.cf������������������������������������������������0000644�0001750�0001750�00000003453�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@{test.tstr}"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), not_matching => "false"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/438.cf������������������������������������������������0000644�0001750�0001750�00000003717�11715232734�016572� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "Three" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/138.cf������������������������������������������������0000644�0001750�0001750�00000004044�11715232734�016561� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "Three" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/018.cf������������������������������������������������0000644�0001750�0001750�00000003315�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way (different order than original) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { " Three potatoe", "BEGIN", "END" }; delete_lines: "$(str)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/045.cf������������������������������������������������0000644�0001750�0001750�00000003146�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => " One potato Two potato Three potatoe"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" not_matching => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/329.cf������������������������������������������������0000644�0001750�0001750�00000004025�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/116.cf������������������������������������������������0000644�0001750�0001750�00000004057�11715232734�016561� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines, using regexes (different order than in original) # Region editing, include_start_delimiter and include_end_delimiter # Second edit destroys the region # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: # Second edit destroys the region "\s+Three.*" select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/101.cf������������������������������������������������0000644�0001750�0001750�00000003620�11715232734�016546� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/025.cf������������������������������������������������0000644�0001750�0001750�00000003643�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: # Note - regex doesn't qualify for "starts_with"! "tstr" slist => { " Three potatoe", " Two.*", "BEGIN", "END" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/431.cf������������������������������������������������0000644�0001750�0001750�00000003720�11715232734�016555� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/424.cf������������������������������������������������0000644�0001750�0001750�00000003734�11715232734�016564� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " Three potatoe" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/227.cf������������������������������������������������0000644�0001750�0001750�00000003775�11715232734�016572� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���cfengine-3.2.4/tests/10_files/07_delete_lines/316.cf������������������������������������������������0000644�0001750�0001750�00000003660�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines, using regexes (different order than in original) # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "\s+Three.*" select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/133.cf������������������������������������������������0000644�0001750�0001750�00000004143�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*eade.*", ".*EGI.*", ".*ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/207.cf������������������������������������������������0000644�0001750�0001750�00000003637�11715232734�016565� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines, using regexes # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "BEGIN" select_region => test_select; "\s+Three.*" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/534.cf������������������������������������������������0000644�0001750�0001750�00000003722�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/011.cf������������������������������������������������0000644�0001750�0001750�00000003321�11715232734�016544� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, original way, different patterns # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*BEGIN.*", ".*Three.*", ".*END.*" }; files: "$(g.testfile).actual" edit_line => test_delete("$(tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/509.cf������������������������������������������������0000644�0001750�0001750�00000003526�11715232734�016567� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header header One potato Two potato Four trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { "BEGIN", " Three potatoe", "END" }; delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/319.cf������������������������������������������������0000644�0001750�0001750�00000003653�11715232734�016567� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way, different patterns (different order than original) # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { ".*Three.*", ".*BEGIN.*", ".*END.*" }; delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/318.cf������������������������������������������������0000644�0001750�0001750�00000003627�11715232734�016567� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way (different order than original) # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { " Three potatoe", "BEGIN", "END" }; delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/123.cf������������������������������������������������0000644�0001750�0001750�00000003770�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete a line, set a class # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe "; # NOTE, DOES NOT MATCH! files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => test_class("ok"), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body classes test_class(a) { promise_kept => { "$(a)" }; } ####################################################### bundle agent check { reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������cfengine-3.2.4/tests/10_files/07_delete_lines/508.cf������������������������������������������������0000644�0001750�0001750�00000003616�11715232734�016566� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines, using regexes different way # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header header One potato Two potato Four trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "BEGIN" select_region => test_select; "^\s+Three.*$" # Anchors should make no difference select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/447.cf������������������������������������������������0000644�0001750�0001750�00000003723�11715232734�016567� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@{test.tstr}"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), not_matching => "false", select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/432.cf������������������������������������������������0000644�0001750�0001750�00000003775�11715232734�016570� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*", ".*GI.*", ".*ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���cfengine-3.2.4/tests/10_files/07_delete_lines/042.cf������������������������������������������������0000644�0001750�0001750�00000003501�11715232734�016550� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/415.cf������������������������������������������������0000644�0001750�0001750�00000003620�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines (different order than in original) # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: " Three potatoe" select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/210.cf������������������������������������������������0000644�0001750�0001750�00000003635�11715232734�016555� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way, different patterns # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { ".*BEGIN.*", ".*Three.*", ".*END.*" }; delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/312.cf������������������������������������������������0000644�0001750�0001750�00000003517�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete multiple lines if they are not in the exact order # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe BEGIN END"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/201.cf������������������������������������������������0000644�0001750�0001750�00000003551�11715232734�016552� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/302.cf������������������������������������������������0000644�0001750�0001750�00000003613�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete a line # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe "; # NOTE, DOES NOT MATCH! files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/330.cf������������������������������������������������0000644�0001750�0001750�00000004041�11715232734�016550� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/501.cf������������������������������������������������0000644�0001750�0001750�00000003502�11715232734�016551� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/137.cf������������������������������������������������0000644�0001750�0001750�00000004124�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/446.cf������������������������������������������������0000644�0001750�0001750�00000003421�11715232734�016561� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" not_matching => "false", select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/238.cf������������������������������������������������0000644�0001750�0001750�00000003775�11715232734�016574� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "Three" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���cfengine-3.2.4/tests/10_files/07_delete_lines/224.cf������������������������������������������������0000644�0001750�0001750�00000004012�11715232734�016550� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " Three potatoe" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/230.cf������������������������������������������������0000644�0001750�0001750�00000004061�11715232734�016551� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/540.cf������������������������������������������������0000644�0001750�0001750�00000004016�11715232734�016555� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "eade", "EGI", "ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/541.cf������������������������������������������������0000644�0001750�0001750�00000003715�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/411.cf������������������������������������������������0000644�0001750�0001750�00000003603�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, original way, different patterns # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*BEGIN.*", ".*Three.*", ".*END.*" }; files: "$(g.testfile).actual" edit_line => test_delete("$(tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/139.cf������������������������������������������������0000644�0001750�0001750�00000004113�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "Three", "GI", "ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/020.cf������������������������������������������������0000644�0001750�0001750�00000003360�11715232734�016547� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, original way, different patterns (different order than original) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*", ".*BEGIN.*", ".*END.*" }; files: "$(g.testfile).actual" edit_line => test_delete("$(tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/006.cf������������������������������������������������0000644�0001750�0001750�00000003203�11715232734�016547� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "BEGIN"; " Three potatoe"; "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/542.cf������������������������������������������������0000644�0001750�0001750�00000003761�11715232734�016565� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN Two potato Three potatoe Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������cfengine-3.2.4/tests/10_files/07_delete_lines/630.cf������������������������������������������������0000644�0001750�0001750�00000004325�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Two regions - expect changes to occur in both # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/120.cf������������������������������������������������0000644�0001750�0001750�00000004066�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, original way, different patterns (different order than original) # Region editing, include_start_delimiter and include_end_delimiter # Second edit destroys the region # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*", ".*BEGIN.*", ".*END.*" }; files: "$(g.testfile).actual" edit_line => test_delete("$(tstr)"); } bundle edit_line test_delete(str) { delete_lines: # Second edit destroys the region "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/520.cf������������������������������������������������0000644�0001750�0001750�00000003631�11715232734�016555� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, original way, different patterns (different order than original) # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header header One potato Two potato Four trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*", ".*BEGIN.*", ".*END.*" }; files: "$(g.testfile).actual" edit_line => test_delete("$(tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/416.cf������������������������������������������������0000644�0001750�0001750�00000003630�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines, using regexes (different order than in original) # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "\s+Three.*" select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/324.cf������������������������������������������������0000644�0001750�0001750�00000003772�11715232734�016565� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " Three potatoe" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������cfengine-3.2.4/tests/10_files/07_delete_lines/537.cf������������������������������������������������0000644�0001750�0001750�00000004006�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/231.cf������������������������������������������������0000644�0001750�0001750�00000003776�11715232734�016566� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��cfengine-3.2.4/tests/10_files/07_delete_lines/206.cf������������������������������������������������0000644�0001750�0001750�00000003627�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "BEGIN" select_region => test_select; " Three potatoe" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/209.cf������������������������������������������������0000644�0001750�0001750�00000003611�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { "BEGIN", " Three potatoe", "END" }; delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/322.cf������������������������������������������������0000644�0001750�0001750�00000003624�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line, set a class # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => test_class("ok"), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body classes test_class(a) { promise_repaired => { "$(a)" }; } ####################################################### bundle agent check { reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/532.cf������������������������������������������������0000644�0001750�0001750�00000004004�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*", ".*GI.*", ".*ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/516.cf������������������������������������������������0000644�0001750�0001750�00000003617�11715232734�016566� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines, using regexes (different order than in original) # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header header One potato Two potato Four trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "\s+Three.*" select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/439.cf������������������������������������������������0000644�0001750�0001750�00000003766�11715232734�016577� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "Three", "GI", "ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������cfengine-3.2.4/tests/10_files/07_delete_lines/419.cf������������������������������������������������0000644�0001750�0001750�00000003623�11715232734�016565� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way, different patterns (different order than original) # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { ".*Three.*", ".*BEGIN.*", ".*END.*" }; delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/216.cf������������������������������������������������0000644�0001750�0001750�00000003702�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines, using regexes (different order than in original) # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "\s+Three.*" select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/236.cf������������������������������������������������0000644�0001750�0001750�00000004037�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*C.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/530.cf������������������������������������������������0000644�0001750�0001750�00000004012�11715232734�016550� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/304.cf������������������������������������������������0000644�0001750�0001750�00000003452�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a group of lines at once, different way # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN Three potatoe END trailer trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "BEGIN$(const.n)$(str)$(const.n)END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/443.cf������������������������������������������������0000644�0001750�0001750�00000003754�11715232734�016567� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "C" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������cfengine-3.2.4/tests/10_files/07_delete_lines/142.cf������������������������������������������������0000644�0001750�0001750�00000004077�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/135.cf������������������������������������������������0000644�0001750�0001750�00000004100�11715232734�016547� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/337.cf������������������������������������������������0000644�0001750�0001750�00000004035�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/242.cf������������������������������������������������0000644�0001750�0001750�00000004030�11715232734�016550� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/547.cf������������������������������������������������0000644�0001750�0001750�00000003732�11715232734�016570� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@{test.tstr}"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), not_matching => "false", select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/140.cf������������������������������������������������0000644�0001750�0001750�00000004134�11715232734�016552� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "eade", "EGI", "ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/026.cf������������������������������������������������0000644�0001750�0001750�00000003561�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "header", " Two.*", "BEGIN", "END" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/040.cf������������������������������������������������0000644�0001750�0001750�00000003536�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "eade", "EGI", "ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/504.cf������������������������������������������������0000644�0001750�0001750�00000003447�11715232734�016564� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a group of lines at once, different way # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN Three potatoe END trailer END trailer"; "expected" string => "header BEGIN header trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "BEGIN$(const.n)$(str)$(const.n)END" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/030.cf������������������������������������������������0000644�0001750�0001750�00000003532�11715232734�016551� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/320.cf������������������������������������������������0000644�0001750�0001750�00000003672�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, original way, different patterns (different order than original) # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*", ".*BEGIN.*", ".*END.*" }; files: "$(g.testfile).actual" edit_line => test_delete("$(tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/032.cf������������������������������������������������0000644�0001750�0001750�00000003524�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*", ".*GI.*", ".*ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/127.cf������������������������������������������������0000644�0001750�0001750�00000004044�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/626.cf������������������������������������������������0000644�0001750�0001750�00000004354�11715232734�016567� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # Two regions - expect changes to occur in both # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "header", " Two.*", "BEGIN", "END" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/202.cf������������������������������������������������0000644�0001750�0001750�00000003633�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete a line # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe "; # NOTE, DOES NOT MATCH! files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/213.cf������������������������������������������������0000644�0001750�0001750�00000003561�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete multiple lines if they are not in the exact order # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)$(const.n)BEGIN$(const.n)END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/339.cf������������������������������������������������0000644�0001750�0001750�00000004024�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "Three", "GI", "ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/623.cf������������������������������������������������0000644�0001750�0001750�00000004165�11715232734�016564� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete a line, set a class # Two regions - expect changes to occur in both # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe "; # NOTE, DOES NOT MATCH! files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => test_class("ok"), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body classes test_class(a) { promise_kept => { "$(a)" }; } ####################################################### bundle agent check { reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/408.cf������������������������������������������������0000644�0001750�0001750�00000003627�11715232734�016567� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines, using regexes different way # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "BEGIN" select_region => test_select; "^\s+Three.*$" # Anchors should make no difference select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/144.cf������������������������������������������������0000644�0001750�0001750�00000004117�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/404.cf������������������������������������������������0000644�0001750�0001750�00000003447�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a group of lines at once, different way, should do nothing because # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN Three potatoe END trailer trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "BEGIN$(const.n)$(str)$(const.n)END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/220.cf������������������������������������������������0000644�0001750�0001750�00000003714�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, original way, different patterns (different order than original) # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*", ".*BEGIN.*", ".*END.*" }; files: "$(g.testfile).actual" edit_line => test_delete("$(tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/012.cf������������������������������������������������0000644�0001750�0001750�00000003211�11715232734�016543� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete multiple lines if they are not in the exact order # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => "BEGIN Three potatoe END"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/226.cf������������������������������������������������0000644�0001750�0001750�00000004110�11715232734�016551� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "header", " Two.*", "BEGIN", "END" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/434.cf������������������������������������������������0000644�0001750�0001750�00000003713�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/633.cf������������������������������������������������0000644�0001750�0001750�00000004340�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # Two regions - expect changes to occur in both # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*eade.*", ".*EGI.*", ".*ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/041.cf������������������������������������������������0000644�0001750�0001750�00000003435�11715232734�016555� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/531.cf������������������������������������������������0000644�0001750�0001750�00000003727�11715232734�016565� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/007.cf������������������������������������������������0000644�0001750�0001750�00000003213�11715232734�016551� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines, using regexes # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "BEGIN"; "\s+Three.*"; "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/044.cf������������������������������������������������0000644�0001750�0001750�00000003521�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/222.cf������������������������������������������������0000644�0001750�0001750�00000003644�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line, set a class # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => test_class("ok"), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body classes test_class(a) { promise_repaired => { "$(a)" }; } ####################################################### bundle agent check { reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/132.cf������������������������������������������������0000644�0001750�0001750�00000004122�11715232734�016550� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*", ".*GI.*", ".*ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/323.cf������������������������������������������������0000644�0001750�0001750�00000003701�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete a line, set a class # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe "; # NOTE, DOES NOT MATCH! files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => test_class("ok"), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body classes test_class(a) { promise_kept => { "$(a)" }; } ####################################################### bundle agent check { reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/333.cf������������������������������������������������0000644�0001750�0001750�00000004054�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*eade.*", ".*EGI.*", ".*ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/412.cf������������������������������������������������0000644�0001750�0001750�00000003461�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete multiple lines if they are not in the exact order # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe BEGIN END"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/445.cf������������������������������������������������0000644�0001750�0001750�00000003467�11715232734�016572� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" not_matching => "true", select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/544.cf������������������������������������������������0000644�0001750�0001750�00000004001�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/523.cf������������������������������������������������0000644�0001750�0001750�00000003652�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete a line, set a class # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe "; # NOTE, DOES NOT MATCH! files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => test_class("ok"), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body classes test_class(a) { promise_kept => { "$(a)" }; } ####################################################### bundle agent check { reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/110.cf������������������������������������������������0000644�0001750�0001750�00000004035�11715232734�016547� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way, different patterns # Region editing, include_start_delimiter and include_end_delimiter # Region is destroyed by first edit # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { ".*BEGIN.*", ".*Three.*", ".*END.*" }; delete_lines: # Region is destroyed by first edit "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/502.cf������������������������������������������������0000644�0001750�0001750�00000003564�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete a line # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe "; # NOTE, DOES NOT MATCH! files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/529.cf������������������������������������������������0000644�0001750�0001750�00000003776�11715232734�016600� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN Two potato Three potatoe Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��cfengine-3.2.4/tests/10_files/07_delete_lines/103.cf������������������������������������������������0000644�0001750�0001750�00000003535�11715232734�016555� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a contiguous group of three lines # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN Three potatoe END trailer trailer"; "expected" string => "header header trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => "BEGIN Three potatoe END"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/546.cf������������������������������������������������0000644�0001750�0001750�00000003430�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" not_matching => "false", select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/637.cf������������������������������������������������0000644�0001750�0001750�00000004321�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Two regions - expect changes to occur in both # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/527.cf������������������������������������������������0000644�0001750�0001750�00000003726�11715232734�016571� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/228.cf������������������������������������������������0000644�0001750�0001750�00000004035�11715232734�016561� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/407.cf������������������������������������������������0000644�0001750�0001750�00000003565�11715232734�016567� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines, using regexes # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "BEGIN" select_region => test_select; "\s+Three.*" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/345.cf������������������������������������������������0000644�0001750�0001750�00000003517�11715232734�016565� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Three potatoe END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" not_matching => "true", select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/640.cf������������������������������������������������0000644�0001750�0001750�00000004331�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # Two regions - expect changes to occur in both # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "eade", "EGI", "ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/141.cf������������������������������������������������0000644�0001750�0001750�00000004033�11715232734�016551� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/109.cf������������������������������������������������0000644�0001750�0001750�00000004011�11715232734�016551� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way # Region editing, include_start_delimiter and include_end_delimiter # Region is destroyed by first edit # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { "BEGIN", " Three potatoe", "END" }; delete_lines: # Region is destroyed by first edit "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/104.cf������������������������������������������������0000644�0001750�0001750�00000003565�11715232734�016561� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a group of lines at once, different way # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN Three potatoe END trailer trailer"; "expected" string => "header header trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "BEGIN$(const.n)$(str)$(const.n)END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/111.cf������������������������������������������������0000644�0001750�0001750�00000004055�11715232734�016552� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, original way, different patterns # Region editing, include_start_delimiter and include_end_delimiter # Region is destroyed by first edit # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*BEGIN.*", ".*Three.*", ".*END.*" }; files: "$(g.testfile).actual" edit_line => test_delete("$(tstr)"); } bundle edit_line test_delete(str) { delete_lines: # Region is destroyed by first edit "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/313.cf������������������������������������������������0000644�0001750�0001750�00000003541�11715232734�016555� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete multiple lines if they are not in the exact order # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)$(const.n)BEGIN$(const.n)END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/538.cf������������������������������������������������0000644�0001750�0001750�00000003726�11715232734�016573� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "Three" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/033.cf������������������������������������������������0000644�0001750�0001750�00000003545�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*eade.*", ".*EGI.*", ".*ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/525.cf������������������������������������������������0000644�0001750�0001750�00000004123�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: # Note - regex doesn't qualify for "starts_with"! "tstr" slist => { " Three potatoe", " Two.*", "BEGIN", "END" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/117.cf������������������������������������������������0000644�0001750�0001750�00000004121�11715232734�016552� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines, using regexes different way (different order than in original) # Region editing, include_start_delimiter and include_end_delimiter # Second edit destroys the region # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: # Second edit destroys the region "^\s+Three.*$" # Anchors should make no difference select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/106.cf������������������������������������������������0000644�0001750�0001750�00000004032�11715232734�016551� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines # Region editing, include_start_delimiter and include_end_delimiter # Region is destroyed by first edit # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: # Region is destroyed by first edit "BEGIN" select_region => test_select; " Three potatoe" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/145.cf������������������������������������������������0000644�0001750�0001750�00000003602�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Three potatoe trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" not_matching => "true", select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/134.cf������������������������������������������������0000644�0001750�0001750�00000004040�11715232734�016551� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/420.cf������������������������������������������������0000644�0001750�0001750�00000003642�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, original way, different patterns (different order than original) # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*", ".*BEGIN.*", ".*END.*" }; files: "$(g.testfile).actual" edit_line => test_delete("$(tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/315.cf������������������������������������������������0000644�0001750�0001750�00000003650�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines (different order than in original) # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: " Three potatoe" select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/533.cf������������������������������������������������0000644�0001750�0001750�00000004025�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*eade.*", ".*EGI.*", ".*ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/433.cf������������������������������������������������0000644�0001750�0001750�00000004016�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*eade.*", ".*EGI.*", ".*ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/428.cf������������������������������������������������0000644�0001750�0001750�00000003757�11715232734�016575� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������cfengine-3.2.4/tests/10_files/07_delete_lines/037.cf������������������������������������������������0000644�0001750�0001750�00000003526�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/024.cf������������������������������������������������0000644�0001750�0001750�00000003463�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " Three potatoe" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/517.cf������������������������������������������������0000644�0001750�0001750�00000003661�11715232734�016566� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines, using regexes different way (different order than in original) # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header header One potato Two potato Four trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "^\s+Three.*$" # Anchors should make no difference select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/001.cf������������������������������������������������0000644�0001750�0001750�00000003223�11715232734�016544� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/241.cf������������������������������������������������0000644�0001750�0001750�00000003764�11715232734�016564� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������cfengine-3.2.4/tests/10_files/07_delete_lines/245.cf������������������������������������������������0000644�0001750�0001750�00000003541�11715232734�016561� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" not_matching => "true", select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/204.cf������������������������������������������������0000644�0001750�0001750�00000003505�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a group of lines at once, different way # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN Three potatoe END trailer trailer"; "expected" string => "header header BEGIN trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)$(const.n)END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/113.cf������������������������������������������������0000644�0001750�0001750�00000003630�11715232734�016552� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete multiple lines if they are not in the exact order # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)$(const.n)BEGIN$(const.n)END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/233.cf������������������������������������������������0000644�0001750�0001750�00000004074�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*eade.*", ".*EGI.*", ".*ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/425.cf������������������������������������������������0000644�0001750�0001750�00000004024�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " Three potatoe", " Two.*", "BEGIN", "END" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/515.cf������������������������������������������������0000644�0001750�0001750�00000003607�11715232734�016564� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines (different order than in original) # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header header One potato Two potato Four trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: " Three potatoe" select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/122.cf������������������������������������������������0000644�0001750�0001750�00000003713�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line, set a class # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => test_class("ok"), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body classes test_class(a) { promise_repaired => { "$(a)" }; } ####################################################### bundle agent check { reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/327.cf������������������������������������������������0000644�0001750�0001750�00000003755�11715232734�016571� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������cfengine-3.2.4/tests/10_files/07_delete_lines/336.cf������������������������������������������������0000644�0001750�0001750�00000004017�11715232734�016561� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*C.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/125.cf������������������������������������������������0000644�0001750�0001750�00000004241�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: # Note - regex doesn't qualify for "starts_with"! "tstr" slist => { " Three potatoe", " Two.*", "BEGIN", "END" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/402.cf������������������������������������������������0000644�0001750�0001750�00000003555�11715232734�016561� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete a line # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe "; # NOTE, DOES NOT MATCH! files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/406.cf������������������������������������������������0000644�0001750�0001750�00000003555�11715232734�016565� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "BEGIN" select_region => test_select; " Three potatoe" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/107.cf������������������������������������������������0000644�0001750�0001750�00000004042�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines, using regexes # Region editing, include_start_delimiter and include_end_delimiter # Region is destroyed by first edit # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: # Region is destroyed by first edit "BEGIN" select_region => test_select; "\s+Three.*" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/442.cf������������������������������������������������0000644�0001750�0001750�00000003752�11715232734�016564� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������cfengine-3.2.4/tests/10_files/07_delete_lines/342.cf������������������������������������������������0000644�0001750�0001750�00000004010�11715232734�016547� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/015.cf������������������������������������������������0000644�0001750�0001750�00000003246�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines (different order than in original) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: " Three potatoe"; "BEGIN"; "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/229.cf������������������������������������������������0000644�0001750�0001750�00000004045�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/331.cf������������������������������������������������0000644�0001750�0001750�00000003756�11715232734�016565� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������cfengine-3.2.4/tests/10_files/07_delete_lines/038.cf������������������������������������������������0000644�0001750�0001750�00000003446�11715232734�016565� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "Three" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/212.cf������������������������������������������������0000644�0001750�0001750�00000003537�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete multiple lines if they are not in the exact order # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe BEGIN END"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/435.cf������������������������������������������������0000644�0001750�0001750�00000003753�11715232734�016567� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������cfengine-3.2.4/tests/10_files/07_delete_lines/441.cf������������������������������������������������0000644�0001750�0001750�00000003706�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/147.cf������������������������������������������������0000644�0001750�0001750�00000004050�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@{test.tstr}"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), not_matching => "false", select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/512.cf������������������������������������������������0000644�0001750�0001750�00000003456�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete multiple lines if they are not in the exact order # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe BEGIN END"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/346.cf������������������������������������������������0000644�0001750�0001750�00000003457�11715232734�016571� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" not_matching => "false", select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/511.cf������������������������������������������������0000644�0001750�0001750�00000003572�11715232734�016561� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, original way, different patterns # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header header One potato Two potato Four trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*BEGIN.*", ".*Three.*", ".*END.*" }; files: "$(g.testfile).actual" edit_line => test_delete("$(tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/203.cf������������������������������������������������0000644�0001750�0001750�00000003463�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a group of three lines at once # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN Three potatoe END trailer trailer"; "expected" string => "header header BEGIN trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe END"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/016.cf������������������������������������������������0000644�0001750�0001750�00000003256�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines, using regexes (different order than in original) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "\s+Three.*"; "BEGIN"; "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/211.cf������������������������������������������������0000644�0001750�0001750�00000003655�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, original way, different patterns # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*BEGIN.*", ".*Three.*", ".*END.*" }; files: "$(g.testfile).actual" edit_line => test_delete("$(tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/208.cf������������������������������������������������0000644�0001750�0001750�00000003701�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines, using regexes different way # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "BEGIN" select_region => test_select; "^\s+Three.*$" # Anchors should make no difference select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/112.cf������������������������������������������������0000644�0001750�0001750�00000003606�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete multiple lines if they are not in the exact order # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe BEGIN END"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/341.cf������������������������������������������������0000644�0001750�0001750�00000003744�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/219.cf������������������������������������������������0000644�0001750�0001750�00000003675�11715232734�016572� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way, different patterns (different order than original) # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { ".*Three.*", ".*BEGIN.*", ".*END.*" }; delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/543.cf������������������������������������������������0000644�0001750�0001750�00000003763�11715232734�016570� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN Two potato Three potatoe Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "C" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������cfengine-3.2.4/tests/10_files/07_delete_lines/010.cf������������������������������������������������0000644�0001750�0001750�00000003301�11715232734�016541� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way, different patterns # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { ".*BEGIN.*", ".*Three.*", ".*END.*" }; delete_lines: "$(str)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/240.cf������������������������������������������������0000644�0001750�0001750�00000004065�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "eade", "EGI", "ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/644.cf������������������������������������������������0000644�0001750�0001750�00000004314�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Two regions - expect changes to occur in both # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/303.cf������������������������������������������������0000644�0001750�0001750�00000003417�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a group of three lines at once # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN Three potatoe END trailer trailer"; "expected" string => "$(actual)"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => "BEGIN Three potatoe END"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/429.cf������������������������������������������������0000644�0001750�0001750�00000003767�11715232734�016577� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������cfengine-3.2.4/tests/10_files/07_delete_lines/043.cf������������������������������������������������0000644�0001750�0001750�00000003503�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "C" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/237.cf������������������������������������������������0000644�0001750�0001750�00000004055�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/029.cf������������������������������������������������0000644�0001750�0001750�00000003516�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/334.cf������������������������������������������������0000644�0001750�0001750�00000003751�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������cfengine-3.2.4/tests/10_files/07_delete_lines/234.cf������������������������������������������������0000644�0001750�0001750�00000003771�11715232734�016564� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������cfengine-3.2.4/tests/10_files/07_delete_lines/340.cf������������������������������������������������0000644�0001750�0001750�00000004045�11715232734�016555� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "eade", "EGI", "ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/426.cf������������������������������������������������0000644�0001750�0001750�00000004032�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which don't match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "header", " Two.*", "BEGIN", "END" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/418.cf������������������������������������������������0000644�0001750�0001750�00000003577�11715232734�016574� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way (different order than original) # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { " Three potatoe", "BEGIN", "END" }; delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/522.cf������������������������������������������������0000644�0001750�0001750�00000003575�11715232734�016566� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line, set a class # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN One potato Two potato Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => test_class("ok"), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body classes test_class(a) { promise_repaired => { "$(a)" }; } ####################################################### bundle agent check { reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/409.cf������������������������������������������������0000644�0001750�0001750�00000003537�11715232734�016570� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { "BEGIN", " Three potatoe", "END" }; delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/545.cf������������������������������������������������0000644�0001750�0001750�00000003447�11715232734�016571� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header One potato Two potato Three potatoe trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" not_matching => "true", select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/136.cf������������������������������������������������0000644�0001750�0001750�00000004106�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*C.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/622.cf������������������������������������������������0000644�0001750�0001750�00000004066�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line, set a class # Two regions - expect changes to occur in both # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END middle middle BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => test_class("ok"), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body classes test_class(a) { promise_repaired => { "$(a)" }; } ####################################################### bundle agent check { reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/115.cf������������������������������������������������0000644�0001750�0001750�00000004047�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines (different order than in original) # Region editing, include_start_delimiter and include_end_delimiter # Second edit destroys the region # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: # Second edit destroys the region " Three potatoe" select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/444.cf������������������������������������������������0000644�0001750�0001750�00000003772�11715232734�016570� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������cfengine-3.2.4/tests/10_files/07_delete_lines/423.cf������������������������������������������������0000644�0001750�0001750�00000003643�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete a line, set a class # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe "; # NOTE, DOES NOT MATCH! files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => test_class("ok"), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body classes test_class(a) { promise_kept => { "$(a)" }; } ####################################################### bundle agent check { reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/008.cf������������������������������������������������0000644�0001750�0001750�00000003255�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { "BEGIN", " Three potatoe", "END" }; delete_lines: "$(str)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/602.cf������������������������������������������������0000644�0001750�0001750�00000004077�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete a line # Two regions - expect changes to occur in both # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END middle middle BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe "; # NOTE, DOES NOT MATCH! files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/031.cf������������������������������������������������0000644�0001750�0001750�00000003447�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/022.cf������������������������������������������������0000644�0001750�0001750�00000003315�11715232734�016551� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line, set a class # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => test_class("ok"); } body classes test_class(a) { promise_repaired => { "$(a)" }; } ####################################################### bundle agent check { reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/344.cf������������������������������������������������0000644�0001750�0001750�00000004030�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/507.cf������������������������������������������������0000644�0001750�0001750�00000003554�11715232734�016566� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines, using regexes # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header header One potato Two potato Four trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "BEGIN" select_region => test_select; "\s+Three.*" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/536.cf������������������������������������������������0000644�0001750�0001750�00000003770�11715232734�016570� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header BEGIN header BEGIN Two potato Three potatoe Four END trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*C.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������cfengine-3.2.4/tests/10_files/07_delete_lines/131.cf������������������������������������������������0000644�0001750�0001750�00000004045�11715232734�016553� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*Three.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/506.cf������������������������������������������������0000644�0001750�0001750�00000003544�11715232734�016564� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines as separate lines # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header header One potato Two potato Four trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "BEGIN" select_region => test_select; " Three potatoe" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/503.cf������������������������������������������������0000644�0001750�0001750�00000003414�11715232734�016555� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a group of three lines at once # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN Three potatoe END trailer END trailer"; "expected" string => "header BEGIN header trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => "BEGIN Three potatoe END"; files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/335.cf������������������������������������������������0000644�0001750�0001750�00000004011�11715232734�016552� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/325.cf������������������������������������������������0000644�0001750�0001750�00000004152�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: # Note - regex doesn't qualify for "starts_with"! "tstr" slist => { " Three potatoe", " Two.*", "BEGIN", "END" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/510.cf������������������������������������������������0000644�0001750�0001750�00000003552�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way, different patterns # Double (nested) header/trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header BEGIN header BEGIN One potato Two potato Three potatoe Four END trailer END trailer"; "expected" string => "header header One potato Two potato Four trailer END trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { ".*BEGIN.*", ".*Three.*", ".*END.*" }; delete_lines: "$(str)" select_region => test_select; } body select_region test_select { select_start => "header"; select_end => "trailer"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/046.cf������������������������������������������������0000644�0001750�0001750�00000003150�11715232734�016554� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" not_matching => "false"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/239.cf������������������������������������������������0000644�0001750�0001750�00000004044�11715232734�016563� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which don't match # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "Three", "GI", "ND" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/129.cf������������������������������������������������0000644�0001750�0001750�00000004114�11715232734�016557� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/317.cf������������������������������������������������0000644�0001750�0001750�00000003722�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines, using regexes different way (different order than in original) # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "^\s+Three.*$" # Anchors should make no difference select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/338.cf������������������������������������������������0000644�0001750�0001750�00000003755�11715232734�016573� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "Three" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������cfengine-3.2.4/tests/10_files/07_delete_lines/028.cf������������������������������������������������0000644�0001750�0001750�00000003506�11715232734�016561� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}); } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/437.cf������������������������������������������������0000644�0001750�0001750�00000003777�11715232734�016577� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*O.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �cfengine-3.2.4/tests/10_files/07_delete_lines/143.cf������������������������������������������������0000644�0001750�0001750�00000004101�11715232734�016547� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { "T", "C" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_contains_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/217.cf������������������������������������������������0000644�0001750�0001750�00000003744�11715232734�016565� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines, using regexes different way (different order than in original) # select_region, include_start_delimiter, include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { delete_lines: "^\s+Three.*$" # Anchors should make no difference select_region => test_select; "BEGIN" select_region => test_select; "END" select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_end_delimiter => "true"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/019.cf������������������������������������������������0000644�0001750�0001750�00000003341�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a number of lines via an slist, different way, different patterns (different order than original) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header One potato Two potato Four trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_delete; } bundle edit_line test_delete { vars: "str" slist => { ".*Three.*", ".*BEGIN.*", ".*END.*" }; delete_lines: "$(str)"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/130.cf������������������������������������������������0000644�0001750�0001750�00000004130�11715232734�016545� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, all of which match # Region editing, include_start_delimiter and include_end_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T", " O" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; include_end_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/436.cf������������������������������������������������0000644�0001750�0001750�00000003761�11715232734�016567� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a list, some of which match # select_region, doesn't include header or trailer # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { ".*T.*", ".*C.*" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; } body delete_select test_match(m) { delete_if_not_match_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������cfengine-3.2.4/tests/10_files/07_delete_lines/328.cf������������������������������������������������0000644�0001750�0001750�00000004015�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Delete a line using a singleton list which matches # select_region, only include_start_delimiter # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" slist => { " T" }; files: "$(g.testfile).actual" edit_line => test_delete(".*potat.*", "@(test.tstr)"); } bundle edit_line test_delete(str, match) { delete_lines: "$(str)" delete_select => test_match(@{match}), select_region => test_select; } body select_region test_select { select_start => "BEGIN"; select_end => "END"; include_start_delimiter => "true"; } body delete_select test_match(m) { delete_if_not_startwith_from_list => { @{m} }; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/07_delete_lines/023.cf������������������������������������������������0000644�0001750�0001750�00000003372�11715232734�016555� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Don't delete a line, set a class # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; "expected" string => "header header BEGIN One potato Two potato Three potatoe Four END trailer trailer"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { vars: "tstr" string => " Three potatoe "; # NOTE, DOES NOT MATCH! files: "$(g.testfile).actual" edit_line => test_delete("$(test.tstr)"); } bundle edit_line test_delete(str) { delete_lines: "$(str)" classes => test_class("ok"); } body classes test_class(a) { promise_kept => { "$(a)" }; } ####################################################### bundle agent check { reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/01_create/������������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�014614� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/01_create/003.cf������������������������������������������������������0000644�0001750�0001750�00000003146�11715232734�015353� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, check initial permissions (odd mode) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0146"; files: "$(g.testfile)" create => "true", perms => test_perms; } body perms test_perms { mode => "$(test.mode)"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 \d+ \d+ 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => regcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/01_create/002.cf������������������������������������������������������0000644�0001750�0001750�00000003156�11715232734�015353� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, check initial permissions (predictable mode) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0641"; files: "$(g.testfile)" create => "true", perms => test_perms; } body perms test_perms { mode => "$(test.mode)"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 \d+ \d+ 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => regcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/01_create/009.cf������������������������������������������������������0000644�0001750�0001750�00000004214�11715232734�015356� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, check owners/mode, different order - assumption, this is run # by root (see notes below) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0644"; files: "$(g.testfile)" create => "true", perms => test_perms; } body perms test_perms { mode => "$(test.mode)"; # In the POSIX model, one cannot create a file for another user, one can only # create a file as you, and then change owners. This test file will be created # by root, but then changed to sys - and thus the promise to be owned by sys # is kept. linux:: owners => { "3", "daemon" }; groups => { "sys", "daemon" }; freebsd:: owners => { "bin", "root" }; groups => { "sys", "wheel" }; !(linux|freebsd):: owners => { "undefined-please-fix" }; groups => { "undefined-please-fix" }; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 3 3 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/01_create/004.cf������������������������������������������������������0000644�0001750�0001750�00000003153�11715232734�015352� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, check initial permissions (strange mode) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "01010"; files: "$(g.testfile)" create => "true", perms => test_perms; } body perms test_perms { mode => "$(test.mode)"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 \d+ \d+ 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => regcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/01_create/006.cf������������������������������������������������������0000644�0001750�0001750�00000003162�11715232734�015354� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, check initial permissions (strange setuid mode) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "04777"; files: "$(g.testfile)" create => "true", perms => test_perms; } body perms test_perms { mode => "$(test.mode)"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 \d+ \d+ 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => regcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/01_create/007.cf������������������������������������������������������0000644�0001750�0001750�00000003515�11715232734�015357� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, check owners/mode # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0644"; files: "$(g.testfile)" create => "true", perms => test_perms; } body perms test_perms { mode => "$(test.mode)"; linux:: owners => { "root", "sys" }; groups => { "root", "sys" }; freebsd:: owners => { "root", "bin" }; groups => { "wheel", "sys" }; !(linux|freebsd):: owners => { "undefined-please-fix" }; groups => { "undefined-please-fix" }; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 0 0 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/01_create/001.cf������������������������������������������������������0000644�0001750�0001750�00000003005�11715232734�015343� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, check defaults # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true"; } ####################################################### bundle agent check { vars: # We want default 0600, 1 link, zero size "expect" string => "600 1 \d+ \d+ 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => regcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/01_create/005.cf������������������������������������������������������0000644�0001750�0001750�00000003162�11715232734�015353� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, check initial permissions (strange setgid mode) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "02001"; files: "$(g.testfile)" create => "true", perms => test_perms; } body perms test_perms { mode => "$(test.mode)"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 \d+ \d+ 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => regcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/01_create/010.cf������������������������������������������������������0000644�0001750�0001750�00000003543�11715232734�015352� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, check owner/group (single choice) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0644"; files: "$(g.testfile)" create => "true", perms => test_perms; } body perms test_perms { mode => "$(test.mode)"; linux:: owners => { "3" }; # sys is not necessarily 3 on all linux groups => { "sys" }; freebsd:: owners => { "bin" }; groups => { "sys" }; !(linux|freebsd):: owners => { "undefined-please-fix" }; groups => { "undefined-please-fix" }; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 3 3 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/01_create/008.cf������������������������������������������������������0000644�0001750�0001750�00000004161�11715232734�015356� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, check owners/mode, different order - assumption, this is run # by root (see notes below) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0644"; files: "$(g.testfile)" create => "true", perms => test_perms; } body perms test_perms { mode => "$(test.mode)"; # In the POSIX model, one cannot create a file for another user, one can only # create a file as you, and then change owners. This test file will be created # # by root, and thus the promise to be owned by root is kept. linux:: owners => { "sys", "root" }; groups => { "sys", "root" }; freebsd:: owners => { "bin", "root" }; groups => { "sys", "wheel" }; !(linux|freebsd):: owners => { "undefined-please-fix" }; groups => { "undefined-please-fix" }; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 0 0 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/04_match/�������������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�014450� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/04_match/004.cf�������������������������������������������������������0000644�0001750�0001750�00000003243�11715232734�015206� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test exec_program on file_select (issue 294) - test negative match on existing file # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "find_this" string => "bibbetygargle"; files: "$(g.testfile)" create => "true", edit_line => init_data; } bundle edit_line init_data { insert_lines: "Gabba gabba hey!"; "yibbity $(find_this) bletch"; "torchecol bum adder"; } ####################################################### bundle agent test { vars: linux:: "prefix" string => ""; freebsd:: "prefix" string => "/usr"; !(linux|freebsd):: "prefix" string => "FIX ME"; files: "/tmp" file_select => test_hunt("$(prefix)"), delete => test_delete; } body file_select test_hunt(prefix) { exec_program => "$(prefix)/bin/grep XX$(init.find_this)XX $(this.promiser)"; file_result => "exec_program"; } body delete test_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent check { classes: "ok" expression => fileexists("$(g.testfile)"); reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/04_match/001.cf�������������������������������������������������������0000644�0001750�0001750�00000002204�11715232734�015177� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file and delete it - hoping that it matches (issue 365) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" create => "true"; } ####################################################### bundle agent test { files: "/tmp/TEST.cfengine" delete => test_delete; } body delete test_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent check { classes: "ok" not => fileexists("$(g.testfile)"); reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/�������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�015633� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/003.cf�������������������������������������������������0000644�0001750�0001750�00000003761�11715232734�016375� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Replace fields, simple case index 1 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:XXX:charlie:delta:echo apple:XXX:carrot:dogfood aardvark:XXX:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "set"; field_separator => ":"; field_value => "XXX"; select_field => "2"; start_fields_from_zero => "false"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������cfengine-3.2.4/tests/10_files/08_field_edits/007x.cf������������������������������������������������0000644�0001750�0001750�00000004006�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Replace fields, illegal select_field # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:XXX:charlie:delta:echo apple:XXX:carrot:dogfood aardvark:XXX:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "set"; field_separator => ":"; field_value => "XXX"; select_field => "xyz"; # Must be numeric start_fields_from_zero => "false"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/002.cf�������������������������������������������������0000644�0001750�0001750�00000003761�11715232734�016374� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Replace fields, simple case, index 0 # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:XXX:charlie:delta:echo apple:XXX:carrot:dogfood aardvark:XXX:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "set"; field_separator => ":"; field_value => "XXX"; select_field => "1"; start_fields_from_zero => "true"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������cfengine-3.2.4/tests/10_files/08_field_edits/027.cf�������������������������������������������������0000644�0001750�0001750�00000003754�11715232734�016405� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Set field, after end of some lists # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:baker,booker,banker:charlie:delta:echo:XXX apple:banana:carrot:dogfood::XXX aardvark:baboon:colugo:dingo::XXX ampallang:: :dydoe:,:XXX:::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "set"; field_separator => ":"; field_value => "XXX"; select_field => "6"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������cfengine-3.2.4/tests/10_files/08_field_edits/009.cf�������������������������������������������������0000644�0001750�0001750�00000003777�11715232734�016412� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Append field # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:baker,booker,banker,XXX:charlie:delta:echo apple:banana,XXX:carrot:dogfood aardvark:baboon,XXX:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "append"; field_separator => ":"; field_value => "XXX"; select_field => "2"; start_fields_from_zero => "false"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �cfengine-3.2.4/tests/10_files/08_field_edits/038x.cf������������������������������������������������0000644�0001750�0001750�00000003723�11715232734�016573� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Replace fields, illegal value_separator # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:XXX:charlie:delta:echo apple:XXX:carrot:dogfood aardvark:XXX:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "set"; field_separator => ":"; field_value => "XXX"; select_field => "2"; value_separator => ",+"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/020.cf�������������������������������������������������0000644�0001750�0001750�00000004072�11715232734�016370� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Prepend field, testing blank values (spaces, not completely blank) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe: , ::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:baker,booker,banker:charlie:delta:XXX,echo apple:banana:carrot:dogfood:XXX aardvark:baboon:colugo:dingo:XXX:fox ampallang:: :dydoe:XXX, , ::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "prepend"; field_separator => ":"; field_value => "XXX"; select_field => "5"; start_fields_from_zero => "false"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/004x.cf������������������������������������������������0000644�0001750�0001750�00000004014�11715232734�016556� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Replace fields, broken start_fields_from_zero # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:XXX:charlie:delta:echo apple:XXX:carrot:dogfood aardvark:XXX:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "set"; field_separator => ":"; field_value => "XXX"; select_field => "2"; start_fields_from_zero => "false "; # Illegal value value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/030.cf�������������������������������������������������0000644�0001750�0001750�00000003772�11715232734�016377� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Set field, after end of some lists without extend_fields # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::XXX ampallang:: :dydoe:,:XXX:::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "false"; field_operation => "set"; field_separator => ":"; field_value => "XXX"; select_field => "6"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������cfengine-3.2.4/tests/10_files/08_field_edits/006x.cf������������������������������������������������0000644�0001750�0001750�00000004014�11715232734�016560� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Replace fields, illegal select_field # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:XXX:charlie:delta:echo apple:XXX:carrot:dogfood aardvark:XXX:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "set"; field_separator => ":"; field_value => "XXX"; select_field => "-1"; # Must be greater than 1 start_fields_from_zero => "false"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/033.cf�������������������������������������������������0000644�0001750�0001750�00000004054�11715232734�016374� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Append field (default field_operation) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:baker,booker,banker,XXX:charlie:delta:echo apple:banana,XXX:carrot:dogfood aardvark:baboon,XXX:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; # field_operation => "append"; # Default value field_separator => ":"; field_value => "XXX"; select_field => "2"; start_fields_from_zero => "false"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/024.cf�������������������������������������������������0000644�0001750�0001750�00000004003�11715232734�016366� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Alphanum field # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,bo0ker,bonker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:XXX+baker,bo0ker,bonker:charlie:delta:echo apple:XXX+banana:carrot:dogfood aardvark:XXX+baboon:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "alphanum"; field_separator => ":"; field_value => "XXX"; select_field => "2"; start_fields_from_zero => "false"; value_separator => "+"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/001.cf�������������������������������������������������0000644�0001750�0001750�00000003706�11715232734�016372� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Replace fields, simple case # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:XXX:charlie:delta:echo apple:XXX:carrot:dogfood aardvark:XXX:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "set"; field_separator => ":"; field_value => "XXX"; select_field => "2"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/015.cf�������������������������������������������������0000644�0001750�0001750�00000004001�11715232734�016364� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Prepend field # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:XXX,baker,booker,banker:charlie:delta:echo apple:XXX,banana:carrot:dogfood aardvark:XXX,baboon:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "prepend"; field_separator => ":"; field_value => "XXX"; select_field => "2"; start_fields_from_zero => "false"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/016.cf�������������������������������������������������0000644�0001750�0001750�00000004001�11715232734�016365� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Prepend field # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:XXX+baker,booker,banker:charlie:delta:echo apple:XXX+banana:carrot:dogfood aardvark:XXX+baboon:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "prepend"; field_separator => ":"; field_value => "XXX"; select_field => "2"; start_fields_from_zero => "false"; value_separator => "+"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/010.cf�������������������������������������������������0000644�0001750�0001750�00000004032�11715232734�016363� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Append field, different value_separator # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:baker,booker,banker+XXX:charlie:delta:echo apple:banana+XXX:carrot:dogfood aardvark:baboon+XXX:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "append"; field_separator => ":"; field_value => "XXX"; select_field => "2"; start_fields_from_zero => "false"; value_separator => "+"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/029.cf�������������������������������������������������0000644�0001750�0001750�00000004016�11715232734�016377� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Alphanum field, lowercase # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:baker,banker,booker,xxx:charlie:delta:echo apple:banana,xxx:carrot:dogfood aardvark:baboon,xxx:colugo:dingo::fox ampallang:xxx: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "alphanum"; field_separator => ":"; field_value => "xxx"; select_field => "2"; start_fields_from_zero => "false"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/008x.cf������������������������������������������������0000644�0001750�0001750�00000004014�11715232734�016562� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Replace fields, illegal select_field # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:XXX:charlie:delta:echo apple:XXX:carrot:dogfood aardvark:XXX:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "set"; field_separator => ":"; field_value => "XXX"; select_field => "-1"; # Must be greater than 1 start_fields_from_zero => "false"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/028.cf�������������������������������������������������0000644�0001750�0001750�00000004016�11715232734�016376� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Alphanum field, lowercase # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:baker,booker,banker+xxx:charlie:delta:echo apple:banana+xxx:carrot:dogfood aardvark:baboon+xxx:colugo:dingo::fox ampallang:xxx: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "alphanum"; field_separator => ":"; field_value => "xxx"; select_field => "2"; start_fields_from_zero => "false"; value_separator => "+"; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/019.cf�������������������������������������������������0000644�0001750�0001750�00000004070�11715232734�016376� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Append field, testing blank values (spaces, not completely blank) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe: , ::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:baker,booker,banker:charlie:delta:echo,XXX apple:banana:carrot:dogfood:XXX aardvark:baboon:colugo:dingo:XXX:fox ampallang:: :dydoe: , ,XXX::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "append"; field_separator => ":"; field_value => "XXX"; select_field => "5"; start_fields_from_zero => "false"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/08_field_edits/023.cf�������������������������������������������������0000644�0001750�0001750�00000004003�11715232734�016365� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Alphanum field # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "states" slist => { "actual", "expected" }; "actual" string => "able:baker,booker,banker:charlie:delta:echo apple:banana:carrot:dogfood aardvark:baboon:colugo:dingo::fox ampallang:: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; "expected" string => "able:XXX,baker,banker,booker:charlie:delta:echo apple:XXX,banana:carrot:dogfood aardvark:XXX,baboon:colugo:dingo::fox ampallang:XXX: :dydoe:,::::: :blowfish:conger:dogfish:eel:flounder"; files: "$(g.testfile).$(states)" create => "true", edit_line => init_insert("$(init.$(states))"), edit_defaults => init_empty; } bundle edit_line init_insert(str) { insert_lines: "$(str)"; } body edit_defaults init_empty { empty_file_before_editing => "true"; } ####################################################### bundle agent test { files: "$(g.testfile).actual" edit_line => test_edit; } bundle edit_line test_edit { field_edits: "a.*" edit_field => test_col; } body edit_field test_col { allow_blank_fields => "true"; extend_fields => "true"; field_operation => "alphanum"; field_separator => ":"; field_value => "XXX"; select_field => "2"; start_fields_from_zero => "false"; value_separator => ","; } ####################################################### bundle agent check { methods: "any" usebundle => default_check_diff("$(g.testfile).actual", "$(g.testfile).expected", "$(this.promise_filename)"); } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/����������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�015152� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/119.cf����������������������������������������������������0000644�0001750�0001750�00000005107�11715232734�015720� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create an relative link to a file, expect subsequent symlink promise to # be unhappy with that (symlink is supposed to be synonymous with absolute) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the inode number of the linked file "command" string => 'printf "%d", (stat("$(g.testfile)"))[1]'; # This extracts the inode number of the symlink "Lcommand" string => 'printf "%d", (lstat("$(g.testfile)"))[1]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[1]'; "source_ino" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); "target" string => "/etc/group"; } ####################################################### bundle agent init { files: "$(g.testfile)" create => "true", move_obstructions => "true", link_from => init_link; } body link_from init_link { source => "$(g.target)"; link_type => "relative"; } ####################################################### bundle agent test { files: "$(g.testfile)" classes => test_if_ok("test_ok"), link_from => test_link; } body link_from test_link { source => "$(g.target)"; link_type => "symlink"; } body classes test_if_ok(c) { repair_failed => { "$(c)" }; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); "Lresult" string => execresult( "/usr/bin/perl -le '$(g.Lcommand)'", "noshell"); # This tells us where the link points "Tcommand" string => 'print readlink "$(g.testfile)"'; "link_target" string => execresult( "/usr/bin/perl -le '$(Tcommand)'", "noshell"); classes: "okL" not => strcmp("$(g.source_ino)", "$(Lresult)"); "okT" not => strcmp("$(link_target)", "$(g.target)"); "ok" and => { "test_ok", "okL", "okT", strcmp("$(g.source_ino)", "$(result)"), regcmp("\..*", "$(link_target)") }; reports: DEBUG:: "expected: '$(g.source_ino)'"; "got: '$(g.testfile)' => '$(link_target)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/102.cf����������������������������������������������������0000644�0001750�0001750�00000003204�11715232734�015704� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous hard link to fail # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0600"; files: "$(g.testfile)" create => "true", link_from => test_link; } body link_from test_link { source => "/etc/group"; link_type => "hardlink"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 0 0 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/003.cf����������������������������������������������������0000644�0001750�0001750�00000003215�11715232734�015706� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous copy with ctime compare to fail # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0600"; files: "$(g.testfile)" create => "true", copy_from => test_copy; } body copy_from test_copy { source => "/etc/group"; compare => "ctime"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 0 0 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/002.cf����������������������������������������������������0000644�0001750�0001750�00000003215�11715232734�015705� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous copy with mtime compare to fail # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0600"; files: "$(g.testfile)" create => "true", copy_from => test_copy; } body copy_from test_copy { source => "/etc/group"; compare => "mtime"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 0 0 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/118.cf����������������������������������������������������0000644�0001750�0001750�00000004775�11715232734�015731� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create an absolute link to a file, expect relative link promise to want # to change it to an relative link (but fail to) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the inode number of the linked file "command" string => 'printf "%d", (stat("$(g.testfile)"))[1]'; # This extracts the inode number of the symlink "Lcommand" string => 'printf "%d", (lstat("$(g.testfile)"))[1]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[1]'; "source_ino" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); "target" string => "/etc/group"; } ####################################################### bundle agent init { files: "$(g.testfile)" create => "true", move_obstructions => "true", link_from => init_link; } body link_from init_link { source => "$(g.target)"; link_type => "absolute"; } ####################################################### bundle agent test { files: "$(g.testfile)" classes => init_if_failed("test_ok"), link_from => test_link; } body link_from test_link { source => "$(g.target)"; link_type => "relative"; } body classes init_if_failed(c) { repair_failed => { "$(c)" }; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); "Lresult" string => execresult( "/usr/bin/perl -le '$(g.Lcommand)'", "noshell"); # This tells us where the link points "Tcommand" string => 'print readlink "$(g.testfile)"'; "link_target" string => execresult( "/usr/bin/perl -le '$(Tcommand)'", "noshell"); classes: "okL" not => strcmp("$(g.source_ino)", "$(Lresult)"); "ok" and => { "test_ok", "okL", strcmp("$(g.source_ino)", "$(result)"), strcmp("$(link_target)", "$(g.target)") }; reports: DEBUG:: "expected: '$(g.source_ino)'"; "got: '$(g.testfile)' => '$(link_target)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���cfengine-3.2.4/tests/10_files/02_maintain/013.cf����������������������������������������������������0000644�0001750�0001750�00000004175�11715232734�015715� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine.dir"; # This extracts the octal mode, and decimal nlink, uid, gid, size "type_command" string => 'use Fcntl; print Fcntl::S_ISDIR((lstat("$(g.testdir)/destdir"))[2]);'; } ####################################################### bundle agent init { files: "$(g.testdir)/srcdir/" create => "true"; "$(g.testdir)/srcdir/intermediate/" create => "true"; "$(g.testdir)/srcdir/intermediate/intermediate2/" create => "true"; "$(g.testdir)/srcdir/intermediate/intermediate2/foo" create => "true"; "$(g.testdir)/realdestdir/" create => "true"; "$(g.testdir)/destdir" comment => "Create a relative link to the target.", link_from => ln_s("$(g.testdir)/realdestdir"); } body link_from ln_s(x) { link_type => "relative"; source => "$(x)"; when_no_source => "nop"; } ####################################################### bundle agent test { files: "$(g.testdir)/destdir" copy_from => sync_cp("$(g.testdir)/srcdir"), depth_search => recurse("inf"); } body copy_from sync_cp(from) { source => "$(from)"; purge => "true"; preserve => "true"; } body depth_search recurse(d) { depth => "$(d)"; xdev => "true"; } ####################################################### bundle agent check { vars: "expect" string => ""; "result" string => execresult( "/usr/bin/perl -le '$(g.type_command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/111x.cf���������������������������������������������������0000644�0001750�0001750�00000003163�11715232734�016100� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous none no-filename link to fail # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0600"; files: "$(g.testfile)" create => "true", link_from => test_link; } body link_from test_link { link_type => "none"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 0 0 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/301.cf����������������������������������������������������0000644�0001750�0001750�00000004573�11715232734�015717� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file using copy, expect second copy to have "promise_kept" # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; classes: "cxl_succ" expression => "any"; "cxl_fail" expression => "any"; } ####################################################### bundle agent init { files: "$(g.testfile)" perms => init_mog, copy_from => init_copy("/etc/group"); } body perms init_mog { mode => "751"; owners => { "bin" }; groups => { "bin" }; } body copy_from init_copy(fn) { source => "$(fn)"; compare => "digest"; } ####################################################### bundle agent test { files: "$(g.testfile)" perms => init_mog, copy_from => init_copy("/etc/group"), classes => test_classes("success", "failure", "failure", "failure", "cxl_succ", "cxl_fail", "cxl_fail"); } body classes test_classes(kep, rep, fai, xxx, cxl_kep, cxl_rep, cxl_nkp) { promise_kept => { "$(kep)" }; promise_repaired => { "$(rep)" }; repair_failed => { "$(fai)" }; repair_denied => { "$(fai)" }; repair_timeout => { "$(fai)" }; cancel_kept => { "$(cxl_kep)" }; cancel_repaired => { "$(cxl_rep)" }; cancel_notkept => { "$(cxl_nkp)" }; } ####################################################### bundle agent check { classes: "ok" and => { "success", "!cxl_succ", "!failure", "cxl_fail" }; reports: DEBUG.success:: "class 'success' was set (should be)"; DEBUG.!success:: "class 'success' was not set (should be)"; DEBUG.cxl_succ:: "class 'cxl_succ' was still set (should not be)"; DEBUG.!cxl_succ:: "class 'cxl_succ' was not still set (should not be)"; DEBUG.failure:: "class 'failure' was set (should not be)"; DEBUG.!failure:: "class 'failure' was not set (should not be)"; DEBUG.cxl_fail:: "class 'cxl_fail' was still set (should be)"; DEBUG.!cxl_fail:: "class 'cxl_fail' was not still set (should not be)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/009.cf����������������������������������������������������0000644�0001750�0001750�00000004160�11715232734�015714� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test that copying file by relative symlink works # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testdir)/copy_file"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testdir)/linkdir/" comment => "Create a directory."; "$(g.testdir)/linkdir/another/" comment => "Create another directory."; "$(g.testdir)/linkdir/another/target" comment => "A target file.", create => "true"; "$(g.testdir)/linkdir/link" comment => "Create a relative link to the target.", link_from => ln_s("$(g.testdir)/linkdir/another/target"); } ####################################################### bundle agent test { files: "$(g.testdir)/copy_file" comment => "Copy the file behind the link.", copy_from => cp_2_file("$(g.testdir)/linkdir/link"); } body link_from ln_s(x) { link_type => "relative"; source => "$(x)"; when_no_source => "nop"; } body copy_from cp_2_file(x) { source => "$(x)"; compare => "binary"; copy_backup => "false"; copylink_patterns => { ".*" }; } ####################################################### bundle agent check { vars: "expect" string => "600 1 0 0 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/004.cf����������������������������������������������������0000644�0001750�0001750�00000004253�11715232734�015712� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous copy with atime compare to succeed # but not change owner/group # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[7]'; "source_size" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0600"; files: "$(g.testfile)" create => "true", perms => test_og, copy_from => test_copy; } body perms test_og { linux:: owners => { "3" }; # can't assume sys = 3 groups => { "sys" }; freebsd:: owners => { "bin" }; groups => { "sys" }; !(linux|freebsd):: owners => { "undefined-please-fix" }; groups => { "undefined-please-fix" }; } body copy_from test_copy { source => "/etc/group"; compare => "atime"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 3 3 $(g.source_size)"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/017.cf����������������������������������������������������0000644�0001750�0001750�00000002135�11715232734�015713� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test that copy_from body with source does not crash (Issue 687) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { files: "/tmp/$(g.testdir)/." create => "true", move_obstructions => "true", copy_from => update_nobackup; } body copy_from update_nobackup() { copy_backup => "false"; } ####################################################### bundle agent check { reports: cfengine_3:: "$(this.promise_filename) Pass"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/404x.cf���������������������������������������������������0000644�0001750�0001750�00000003243�11715232734�016104� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } body agent control { default_repository => "tmp"; # Intentionally wrong } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; "repofile" string => "/var/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.repofile).*" delete => init_delete; "$(g.testfile).*" delete => init_delete; "$(g.testfile)" move_obstructions => "true", copy_from => init_copy; } body copy_from init_copy { source => "/etc/group"; compare => "digest"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" move_obstructions => "true", copy_from => test_copy; } body copy_from test_copy { source => "/etc/motd"; compare => "digest"; } ####################################################### bundle agent check { classes: "test" not => fileexists("$(g.testfile).cfsaved"); "repo" expression => fileexists("$(g.repofile).cfsaved"); "ok" and => { "test", "repo" }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); "any" usebundle => default_fini("$(g.repofile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/018.cf����������������������������������������������������0000644�0001750�0001750�00000002566�11715232734�015724� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test that disable_mode => "000" in body rename works (Issue 688) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine"; "testfile" string => "$(testdir)/testfile"; "command" string => 'printf "%o %d", (stat("$(g.testfile).cfdisabled"))[2]&07777, (stat(_))[3]'; } ####################################################### bundle agent init { files: "$(g.testfile)" create => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" rename => disable_file; } body rename disable_file { disable_mode => "000"; disable => "true"; } ####################################################### bundle agent check { vars: "result" string => execresult("/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("0 1", "$(result)"); reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } ������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/014x.cf���������������������������������������������������0000644�0001750�0001750�00000002376�11715232734�016107� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test that we can't supply relative filename to copy_from # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine.dir"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } body link_from ln_s(x) { link_type => "relative"; source => "$(x)"; when_no_source => "nop"; } ####################################################### bundle agent test { files: "$(g.testdir)/destdir" copy_from => sync_cp("./srcdirrr"); } body copy_from sync_cp(from) { source => "$(from)"; purge => "true"; preserve => "true"; } ####################################################### bundle agent check { classes: "ok" expression => "any"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/116.cf����������������������������������������������������0000644�0001750�0001750�00000004622�11715232734�015716� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous link with relative and move_obstructions # to succeed # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the inode number of the linked file "command" string => 'printf "%d", (stat("$(g.testfile)"))[1]'; # This extracts the inode number of the symlink "Lcommand" string => 'printf "%d", (lstat("$(g.testfile)"))[1]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[1]'; "source_ino" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); "target" string => "/etc/group"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", move_obstructions => "true", link_from => test_link; } body link_from test_link { source => "$(g.target)"; link_type => "relative"; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); "Lresult" string => execresult( "/usr/bin/perl -le '$(g.Lcommand)'", "noshell"); # This tells us where the link points "Tcommand" string => 'print readlink "$(g.testfile)"'; "link_target" string => execresult( "/usr/bin/perl -le '$(Tcommand)'", "noshell"); classes: "okL" not => strcmp("$(g.source_ino)", "$(Lresult)"); "okT" not => strcmp("$(link_target)", "$(g.target)"); "ok" and => { "okL", "okT", strcmp("$(g.source_ino)", "$(result)"), regcmp("\..*", "$(link_target)") }; reports: DEBUG:: "expected: '$(g.source_ino)'"; "got: '$(g.testfile)' => '$(link_target)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/101.cf����������������������������������������������������0000644�0001750�0001750�00000003155�11715232734�015710� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous default link to fail # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0600"; files: "$(g.testfile)" create => "true", link_from => test_link; } body link_from test_link { source => "/etc/group"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 0 0 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/207.cf����������������������������������������������������0000644�0001750�0001750�00000005201�11715232734�015711� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Copy a file, then ensure that subsequent create=true doesn't # overwrite mode, size, but DOES change owner, group (numeric IDs) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%05o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[7]'; "source_size" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); } ####################################################### bundle agent init { vars: any:: "mode" int => "01751"; linux:: "owner" string => "sys"; "group" string => "sys"; freebsd:: "owner" string => "bin"; "group" string => "sys"; !(linux|freebsd):: "owner" string => "undefined-please-fix"; "group" string => "undefined-please-fix"; pass2:: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); files: "$(g.testfile)" copy_from => init_copy("$(g.source)"), perms => init_perms("$(mode)", "$(owner)", "$(group)"), classes => init_set_class("pass2"); } body copy_from init_copy(file) { source => "$(file)"; } body perms init_perms(m, o, g) { mode => "$(m)"; owners => { "$(o)" }; groups => { "$(g)" }; } body classes init_set_class(class) { promise_kept => { "$(class)" }; promise_repaired => { "$(class)" }; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", perms => test_perms("a+r"); } body perms test_perms(m) { mode => "$(m)"; owners => { "333" }; groups => { "444" }; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); "expected" string => "01755 1 333 444 $(g.source_size)"; classes: "ok" expression => strcmp("$(expected)", "$(result)"); reports: DEBUG:: "init.result is '$(init.result)'"; "expected is '$(expected)'"; "check.result is '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/011.cf����������������������������������������������������0000644�0001750�0001750�00000003657�11715232734�015717� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test that symlinks outside of copying root are NOT set aside while copying trees of directorise (Issue 585) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine.dir"; # This extracts the octal mode, and decimal nlink, uid, gid, size "type_command" string => 'use Fcntl; print Fcntl::S_ISDIR((lstat("$(g.testdir)/destdir"))[2]);'; } ####################################################### bundle agent init { files: "$(g.testdir)/srcdir/" create => "true"; "$(g.testdir)/srcdir/foo" create => "true"; "$(g.testdir)/realdestdir/" create => "true"; "$(g.testdir)/destdir" comment => "Create a relative link to the target.", link_from => ln_s("$(g.testdir)/realdestdir"); } body link_from ln_s(x) { link_type => "relative"; source => "$(x)"; when_no_source => "nop"; } ####################################################### bundle agent test { files: "$(g.testdir)/destdir/foo" copy_from => sync_cp("$(g.testdir)/srcdir/foo"); } body copy_from sync_cp(from) { source => "$(from)"; } ####################################################### bundle agent check { vars: "expect" string => ""; "result" string => execresult( "/usr/bin/perl -le '$(g.type_command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } ���������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/201.cf����������������������������������������������������0000644�0001750�0001750�00000003722�11715232734�015711� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Copy a file, then ensure that subsequent create=true doesn't # overwrite mode, size # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { vars: any:: "mode" int => "01751"; pass2:: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); files: "$(g.testfile)" copy_from => init_copy("/etc/group"), perms => init_perms("$(mode)"), classes => init_set_class("pass2"); } body copy_from init_copy(file) { source => "$(file)"; } body perms init_perms(m) { mode => "$(m)"; } body classes init_set_class(class) { promise_kept => { "$(class)" }; promise_repaired => { "$(class)" }; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", perms => test_perms("$(init.mode)"); } body perms test_perms(m) { mode => "$(m)"; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(init.result)", "$(result)"); reports: DEBUG:: "init.result is '$(init.result)'"; "check.result is '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/006.cf����������������������������������������������������0000644�0001750�0001750�00000004255�11715232734�015716� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous copy with digest compare to succeed # but not change owner/group # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[7]'; "source_size" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0600"; files: "$(g.testfile)" create => "true", perms => test_og, copy_from => test_copy; } body perms test_og { linux:: owners => { "3" }; # can't assume sys = 3 groups => { "sys" }; freebsd:: owners => { "bin" }; groups => { "sys" }; !(linux|freebsd):: owners => { "undefined-please-fix" }; groups => { "undefined-please-fix" }; } body copy_from test_copy { source => "/etc/group"; compare => "digest"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 3 3 $(g.source_size)"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/120.cf����������������������������������������������������0000644�0001750�0001750�00000004727�11715232734�015717� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create an absolute link to a file, expect subsequent symlink promise to # be happy with that # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the inode number of the linked file "command" string => 'printf "%d", (stat("$(g.testfile)"))[1]'; # This extracts the inode number of the symlink "Lcommand" string => 'printf "%d", (lstat("$(g.testfile)"))[1]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[1]'; "source_ino" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); "target" string => "/etc/group"; } ####################################################### bundle agent init { files: "$(g.testfile)" create => "true", move_obstructions => "true", link_from => init_link; } body link_from init_link { source => "$(g.target)"; link_type => "absolute"; } ####################################################### bundle agent test { files: "$(g.testfile)" classes => test_if_ok("test_ok"), link_from => test_link; } body link_from test_link { source => "$(g.target)"; link_type => "symlink"; } body classes test_if_ok(c) { promise_kept => { "$(c)" }; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); "Lresult" string => execresult( "/usr/bin/perl -le '$(g.Lcommand)'", "noshell"); # This tells us where the link points "Tcommand" string => 'print readlink "$(g.testfile)"'; "link_target" string => execresult( "/usr/bin/perl -le '$(Tcommand)'", "noshell"); classes: "okL" not => strcmp("$(g.source_ino)", "$(Lresult)"); "ok" and => { "test_ok", "okL", strcmp("$(g.source_ino)", "$(result)"), strcmp("$(link_target)", "$(g.target)") }; reports: DEBUG:: "expected: '$(g.source_ino)'"; "got: '$(g.testfile)' => '$(link_target)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/206.cf����������������������������������������������������0000644�0001750�0001750�00000005210�11715232734�015710� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Copy a file, then ensure that subsequent create=true doesn't # overwrite mode, size, but DOES change owner, group - numeric UID/GID # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; "srcfile" string => "/etc/group"; # # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%05o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; "sizecmd" string => 'printf "%d", (stat("$(srcfile)"))[7]'; } ####################################################### bundle agent init { vars: any:: "mode" int => "01751"; linux:: "owner" string => "sys"; "group" string => "sys"; freebsd:: "owner" string => "bin"; "group" string => "sys"; !(linux|freebsd):: "owner" string => "undefined-please-fix"; "group" string => "undefined-please-fix"; pass2:: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); files: "$(g.testfile)" copy_from => init_copy("/etc/group"), perms => init_perms("$(mode)", "$(owner)", "$(group)"), classes => init_set_class("pass2"); } body copy_from init_copy(file) { source => "$(file)"; } body perms init_perms(m, o, g) { mode => "$(m)"; owners => { "$(o)" }; groups => { "$(g)" }; } body classes init_set_class(class) { promise_kept => { "$(class)" }; promise_repaired => { "$(class)" }; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", perms => test_perms("a+r"); } body perms test_perms(m) { mode => "$(m)"; owners => { "456" }; groups => { "567" }; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); "srcfilesize" string => execresult("/usr/bin/perl -le '$(g.sizecmd)'", "noshell"); "expected" string => "01755 1 456 567 $(srcfilesize)"; classes: "ok" expression => strcmp("$(expected)", "$(result)"); reports: DEBUG:: "init.result is '$(init.result)'"; "expected is '$(expected)'"; "check.result is '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/209.cf����������������������������������������������������0000644�0001750�0001750�00000005115�11715232734�015717� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Copy a file, then ensure that subsequent create=true doesn't # overwrite mode, size, but DOES change owner, group, because # we start with a non-registered user/group name. # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[7]'; "source_size" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); } ####################################################### bundle agent init { vars: any:: "mode" int => "01751"; "owner" string => "786756"; "group" string => "786756"; pass2:: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); files: "$(g.testfile)" copy_from => init_copy("/etc/group"), perms => init_perms("$(mode)", "$(owner)", "$(group)"), classes => init_set_class("pass2"); } body copy_from init_copy(file) { source => "$(file)"; compare => "mtime"; } body perms init_perms(m, o, g) { mode => "$(m)"; owners => { "$(o)" }; groups => { "$(g)" }; } body classes init_set_class(class) { promise_kept => { "$(class)" }; promise_repaired => { "$(class)" }; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", perms => test_perms; } body perms test_perms { # Mode, owner is unspecified - should not change anything groups => { "23459", "none" }; # Should change to 23459 } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); "expected" string => "$(init.mode) 1 $(init.owner) 23459 $(g.source_size)"; classes: "ok" expression => strcmp("$(expected)", "$(result)"); reports: DEBUG:: "init.result is '$(init.result)'"; "expected is '$(expected)'"; "check.result is '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/202.cf����������������������������������������������������0000644�0001750�0001750�00000004666�11715232734�015722� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Copy a file, then ensure that subsequent create=true doesn't # overwrite mode, size, owner, group # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { vars: any:: "mode" int => "01751"; linux:: "owner" string => "sys"; "group" string => "sys"; freebsd:: "owner" string => "bin"; "group" string => "sys"; !(linux|freebsd):: "owner" string => "undefined-please-fix"; "group" string => "undefined-please-fix"; pass2:: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); files: "$(g.testfile)" copy_from => init_copy("/etc/group"), perms => init_perms("$(mode)", "$(owner)", "$(group)"), classes => init_set_class("pass2"); } body copy_from init_copy(file) { source => "$(file)"; } body perms init_perms(m, o, g) { mode => "$(m)"; owners => { "$(o)" }; groups => { "$(g)" }; } body classes init_set_class(class) { promise_kept => { "$(class)" }; promise_repaired => { "$(class)" }; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", perms => test_perms("$(init.mode)", "$(init.owner)", "$(init.group)"); } body perms test_perms(m, o, g) { mode => "$(m)"; owners => { "$(o)", "root" }; linux:: groups => { "$(g)", "root" }; freebsd:: groups => { "$(g)", "wheel" }; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(init.result)", "$(result)"); reports: DEBUG:: "init.result is '$(init.result)'"; "check.result is '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/408.cf����������������������������������������������������0000644�0001750�0001750�00000003060�11715232734�015715� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Copy symlink over file, test that file is correctly saved aside. # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; "srcfile" string => "/tmp/TEST.cfengine.source"; } ####################################################### bundle agent init { files: "$(g.testfile)" move_obstructions => "true", copy_from => init_copy; "$(g.srcfile)" move_obstructions => "true", link_from => init_link; } body copy_from init_copy { source => "/etc/group"; compare => "digest"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } body link_from init_link { source => "/bin/true"; } ####################################################### bundle agent test { files: "$(g.testfile)" move_obstructions => "true", copy_from => test_copy; } body copy_from test_copy { source => "$(g.srcfile)"; compare => "digest"; } ####################################################### bundle agent check { classes: "ok" expression => fileexists("$(g.testfile).cfsaved"); reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/012.cf����������������������������������������������������0000644�0001750�0001750�00000004044�11715232734�015707� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine.dir"; # This extracts the octal mode, and decimal nlink, uid, gid, size "type_command" string => 'use Fcntl; print Fcntl::S_ISDIR((lstat("$(g.testdir)/destdir"))[2]);'; } ####################################################### bundle agent init { files: "$(g.testdir)/srcdir/" create => "true"; "$(g.testdir)/srcdir/intermediate/" create => "true"; "$(g.testdir)/srcdir/intermediate/intermediate2/" create => "true"; "$(g.testdir)/srcdir/intermediate/intermediate2/foo" create => "true"; "$(g.testdir)/realdestdir/" create => "true"; "$(g.testdir)/destdir" comment => "Create a relative link to the target.", link_from => ln_s("$(g.testdir)/realdestdir"); } body link_from ln_s(x) { link_type => "relative"; source => "$(x)"; when_no_source => "nop"; } ####################################################### bundle agent test { files: "$(g.testdir)/destdir/intermediate/intermediate2/foo" copy_from => sync_cp("$(g.testdir)/srcdir/intermediate/intermediate2/foo"); } body copy_from sync_cp(from) { source => "$(from)"; } ####################################################### bundle agent check { vars: "expect" string => ""; "result" string => execresult( "/usr/bin/perl -le '$(g.type_command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/407x.cf���������������������������������������������������0000644�0001750�0001750�00000003204�11715232734�016104� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; "repofile" string => "/var/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.repofile).*" delete => init_delete; "$(g.testfile).*" delete => init_delete; "$(g.testfile)" move_obstructions => "true", copy_from => init_copy; } body copy_from init_copy { source => "/etc/group"; compare => "digest"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" repository => "tmp", # Intentionally wrong move_obstructions => "true", copy_from => test_copy; } body copy_from test_copy { source => "/etc/motd"; compare => "digest"; } ####################################################### bundle agent check { classes: "test" not => fileexists("$(g.testfile).cfsaved"); "repo" expression => fileexists("$(g.repofile).cfsaved"); "ok" and => { "test", "repo" }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); "any" usebundle => default_fini("$(g.repofile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/007.cf����������������������������������������������������0000644�0001750�0001750�00000004255�11715232734�015717� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous copy with binary compare to succeed # but not change owner/group # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[7]'; "source_size" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0600"; files: "$(g.testfile)" create => "true", perms => test_og, copy_from => test_copy; } body perms test_og { linux:: owners => { "3" }; # Can't assume sys = 3 groups => { "sys" }; freebsd:: owners => { "bin" }; groups => { "sys" }; !(linux|freebsd):: owners => { "undefined-please-fix" }; groups => { "undefined-please-fix" }; } body copy_from test_copy { source => "/etc/group"; compare => "binary"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 3 3 $(g.source_size)"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/103.cf����������������������������������������������������0000644�0001750�0001750�00000003207�11715232734�015710� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous symbolic link to fail # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0600"; files: "$(g.testfile)" create => "true", link_from => test_link; } body link_from test_link { source => "/etc/group"; link_type => "symlink"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 0 0 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/106x.cf���������������������������������������������������0000644�0001750�0001750�00000003151�11715232734�016101� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test wrong type of link_type. # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0600"; files: "$(g.testfile)" create => "true", link_from => test_link; } body link_from test_link { source => "/etc/group"; link_type => "none"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 0 0 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/104.cf����������������������������������������������������0000644�0001750�0001750�00000003221�11715232734�015705� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous relative symbolic link to fail # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0600"; files: "$(g.testfile)" create => "true", link_from => test_link; } body link_from test_link { source => "/etc/group"; link_type => "relative"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 0 0 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/117.cf����������������������������������������������������0000644�0001750�0001750�00000005064�11715232734�015720� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create an relative link to a file, expect absolute link promise to want # to change it to an absolute link (but fail to) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the inode number of the linked file "command" string => 'printf "%d", (stat("$(g.testfile)"))[1]'; # This extracts the inode number of the symlink "Lcommand" string => 'printf "%d", (lstat("$(g.testfile)"))[1]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[1]'; "source_ino" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); "target" string => "/etc/group"; } ####################################################### bundle agent init { files: "$(g.testfile)" create => "true", move_obstructions => "true", link_from => init_link; } body link_from init_link { source => "$(g.target)"; link_type => "relative"; } ####################################################### bundle agent test { files: "$(g.testfile)" classes => init_if_failed("test_ok"), link_from => test_link; } body link_from test_link { source => "$(g.target)"; link_type => "absolute"; } body classes init_if_failed(c) { repair_failed => { "$(c)" }; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); "Lresult" string => execresult( "/usr/bin/perl -le '$(g.Lcommand)'", "noshell"); # This tells us where the link points "Tcommand" string => 'print readlink "$(g.testfile)"'; "link_target" string => execresult( "/usr/bin/perl -le '$(Tcommand)'", "noshell"); classes: "okL" not => strcmp("$(g.source_ino)", "$(Lresult)"); "okT" not => strcmp("$(link_target)", "$(g.target)"); "ok" and => { "test_ok", "okL", "okT", strcmp("$(g.source_ino)", "$(result)"), regcmp("\..*", "$(link_target)") }; reports: DEBUG:: "expected: '$(g.source_ino)'"; "got: '$(g.testfile)' => '$(link_target)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/001.cf����������������������������������������������������0000644�0001750�0001750�00000003171�11715232734�015705� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous copy with default compare to fail # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "600"; files: "$(g.testfile)" create => "true", copy_from => test_copy; } body copy_from test_copy { source => "/etc/group"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 0 0 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/204.cf����������������������������������������������������0000644�0001750�0001750�00000004500�11715232734�015707� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Copy a file, then ensure that subsequent create=true doesn't # overwrite mode, size or change owner/group (different ordering of groups) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { vars: any:: "mode" int => "01751"; linux:: "owner" string => "sys"; "group" string => "sys"; freebsd:: "owner" string => "bin"; "group" string => "sys"; !(linux|freebsd):: "owner" string => "undefined-please-fix"; "group" string => "undefined-please-fix"; pass2:: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); files: "$(g.testfile)" copy_from => init_copy("/etc/group"), perms => init_perms("$(mode)", "$(owner)", "$(group)"), classes => init_set_class("pass2"); } body copy_from init_copy(file) { source => "$(file)"; } body perms init_perms(m, o, g) { mode => "$(m)"; owners => { "$(o)" }; groups => { "$(g)" }; } body classes init_set_class(class) { promise_kept => { "$(class)" }; promise_repaired => { "$(class)" }; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", perms => test_perms("$(init.mode)"); } body perms test_perms(m) { mode => "$(m)"; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(init.result)", "$(result)"); reports: DEBUG:: "init.result is '$(init.result)'"; "check.result is '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/113.cf����������������������������������������������������0000644�0001750�0001750�00000003537�11715232734�015717� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous link with hardlink and move_obstructions # to succeed # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; "sourcefile" string => "$(testfile).SOURCE"; # This extracts the inode number "command" string => 'printf "%d", (stat("$(g.testfile)"))[1]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; "$(g.sourcefile)" create => "true"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", move_obstructions => "true", link_from => test_link; } body link_from test_link { source => "$(g.sourcefile)"; link_type => "hardlink"; } ####################################################### bundle agent check { vars: "source_command" string => 'printf "%d", (stat("$(g.sourcefile)"))[1]'; "source_ino" string => execresult( "/usr/bin/perl -le '$(source_command)'", "noshell"); "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(source_ino)", "$(result)"); reports: DEBUG:: "expected: '$(source_ino)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/105.cf����������������������������������������������������0000644�0001750�0001750�00000003322�11715232734�015710� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous absolute symbolic link to fail # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; "$(g.testfile).SOURCE" create => "true"; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0600"; files: "$(g.testfile)" create => "true", link_from => test_link; } body link_from test_link { link_type => "absolute"; source => "$(g.testfile).SOURCE"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 0 0 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/015.cf����������������������������������������������������0000644�0001750�0001750�00000002316�11715232734�015712� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test that we can supply relative filename to link_from # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine.dir"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } body link_from ln_s(x) { link_type => "relative"; source => "$(x)"; when_no_source => "nop"; } ####################################################### bundle agent test { files: "$(g.testdir)/destdir" link_from => sync_cp("./srcdirrr"); } body link_from sync_cp(from) { source => "$(from)"; } ####################################################### bundle agent check { classes: "ok" expression => "any"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/005.cf����������������������������������������������������0000644�0001750�0001750�00000004251�11715232734�015711� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous copy with hash compare to succeed # but not change owner/group # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[7]'; "source_size" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0600"; files: "$(g.testfile)" create => "true", perms => test_og, copy_from => test_copy; } body perms test_og { linux:: owners => { "3" }; # can't assume sys = 3 groups => { "sys" }; freebsd:: owners => { "bin" }; groups => { "sys" }; !(linux|freebsd):: owners => { "undefined-please-fix" }; groups => { "undefined-please-fix" }; } body copy_from test_copy { source => "/etc/group"; compare => "hash"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 3 3 $(g.source_size)"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/203.cf����������������������������������������������������0000644�0001750�0001750�00000004725�11715232734�015717� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Copy a file, then ensure that subsequent create=true doesn't # overwrite mode, size, owner, group (different ordering of groups) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { vars: any:: "mode" int => "01751"; linux:: "owner" string => "sys"; "group" string => "sys"; freebsd:: "owner" string => "bin"; "group" string => "sys"; !(linux|freebsd):: "owner" string => "undefined-please-fix"; "group" string => "undefined-please-fix"; pass2:: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); files: "$(g.testfile)" copy_from => init_copy("/etc/group"), perms => init_perms("$(mode)", "$(owner)", "$(group)"), classes => init_set_class("pass2"); } body copy_from init_copy(file) { source => "$(file)"; } body perms init_perms(m, o, g) { mode => "$(m)"; owners => { "$(o)" }; groups => { "$(g)" }; } body classes init_set_class(class) { promise_kept => { "$(class)" }; promise_repaired => { "$(class)" }; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", perms => test_perms("$(init.mode)", "$(init.owner)", "$(init.group)"); } body perms test_perms(m, o, g) { mode => "$(m)"; owners => { "root", "$(o)" }; linux:: groups => { "root", "$(g)" }; freebsd:: groups => { "wheel", "$(g)" }; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(init.result)", "$(result)"); reports: DEBUG:: "init.result is '$(init.result)'"; "check.result is '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/016.cf����������������������������������������������������0000644�0001750�0001750�00000003121�11715232734�015706� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test that timestamped copying adds .cfsaved suffix (Issue 666) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testdir)/afile" create => "true"; # We can't use files promise here as it will remember we have created the file # and will not generate backup file which we are trying to get. commands: "/bin/echo LimpBizkit > $(g.testdir)/destfile" contain => shell; } body contain shell { useshell => "true"; } ####################################################### bundle agent test { files: "$(g.testdir)/destfile" copy_from => cp_2_file("$(g.testdir)/afile"); } body copy_from cp_2_file(x) { source => "$(x)"; copy_backup => "timestamp"; compare => "digest"; } ####################################################### bundle agent check { files: "$(g.testdir)/destfile.*\.cfsaved" touch => "true", classes => ifrepaired("ok"); reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } body classes ifrepaired(classname) { promise_repaired => { "$(classname)" }; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/208.cf����������������������������������������������������0000644�0001750�0001750�00000005171�11715232734�015720� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Copy a file, then ensure that subsequent create=true doesn't # overwrite mode, size, group but DOES change owner, because # we start with a non-registered user/group name. # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[7]'; "source_size" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); } ####################################################### bundle agent init { vars: any:: "mode" int => "01751"; "owner" string => "786756"; "group" string => "786756"; pass2:: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); files: "$(g.testfile)" copy_from => init_copy("/etc/group"), perms => init_perms("$(mode)", "$(owner)", "$(group)"), classes => init_set_class("pass2"); } body copy_from init_copy(file) { source => "$(file)"; compare => "mtime"; } body perms init_perms(m, o, g) { mode => "$(m)"; owners => { "$(o)" }; groups => { "$(g)" }; } body classes init_set_class(class) { promise_kept => { "$(class)" }; promise_repaired => { "$(class)" }; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", perms => test_perms; } body perms test_perms { # Mode is unspecified - should not change anything owners => { "12349", "none" }; # Should change to 12349 # Group is unspecified - should not change anything } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); "expected" string => "$(init.mode) 1 12349 $(init.group) $(g.source_size)"; classes: "ok" expression => strcmp("$(expected)", "$(result)"); reports: DEBUG:: "init.result is '$(init.result)'"; "expected is '$(expected)'"; "check.result is '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/112.cf����������������������������������������������������0000644�0001750�0001750�00000003364�11715232734�015714� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous link with default and move_obstructions # to succeed # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the inode number "command" string => 'printf "%d", (stat("$(g.testfile)"))[1]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[1]'; "source_ino" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", move_obstructions => "true", link_from => test_link; } body link_from test_link { source => "/etc/group"; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(g.source_ino)", "$(result)"); reports: DEBUG:: "expected: '$(g.source_ino)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/010.cf����������������������������������������������������0000644�0001750�0001750�00000004230�11715232734�015702� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test that symlinks are set aside while copying trees of directorise (Issue 569) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine.dir"; # This extracts the octal mode, and decimal nlink, uid, gid, size "type_command" string => 'use Fcntl; print Fcntl::S_ISDIR((lstat("$(g.testdir)/destdir"))[2]);'; } ####################################################### bundle agent init { files: "$(g.testdir)/srcdir/"; "$(g.testdir)/srcdir/foo" create => "true"; "$(g.testdir)/realdestdir/" create => "true"; "$(g.testdir)/destdir" comment => "Create a relative link to the target.", link_from => ln_s("$(g.testdir)/realdestdir"); } body link_from ln_s(x) { link_type => "relative"; source => "$(x)"; when_no_source => "nop"; } ####################################################### bundle agent test { files: "$(g.testdir)/destdir/" copy_from => sync_cp("$(g.testdir)/srcdir"), depth_search => recurse("inf"), move_obstructions => "true", action => if_elapsed(0); } body copy_from sync_cp(from) { source => "$(from)"; purge => "true"; preserve => "true"; } body depth_search recurse(d) { depth => "$(d)"; xdev => "true"; } body action if_elapsed(x) { ifelapsed => "$(x)"; expireafter => "$(x)"; } ####################################################### bundle agent check { vars: "expect" string => "1"; "result" string => execresult( "/usr/bin/perl -le '$(g.type_command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/115.cf����������������������������������������������������0000644�0001750�0001750�00000004533�11715232734�015716� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous link with absolute and move_obstructions # to succeed # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the inode number of the linked file "command" string => 'printf "%d", (stat("$(g.testfile)"))[1]'; # This extracts the inode number of the symlink "Lcommand" string => 'printf "%d", (lstat("$(g.testfile)"))[1]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[1]'; "source_ino" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); "target" string => "/etc/group"; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", move_obstructions => "true", link_from => test_link; } body link_from test_link { source => "$(g.target)"; link_type => "absolute"; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); "Lresult" string => execresult( "/usr/bin/perl -le '$(g.Lcommand)'", "noshell"); # This tells us where the link points "Tcommand" string => 'print readlink "$(g.testfile)"'; "link_target" string => execresult( "/usr/bin/perl -le '$(Tcommand)'", "noshell"); classes: "okL" not => strcmp("$(g.source_ino)", "$(Lresult)"); "ok" and => { "okL", strcmp("$(g.source_ino)", "$(result)"), strcmp("$(link_target)", "$(g.target)") }; reports: DEBUG:: "expected: '$(g.source_ino)'"; "got: '$(g.testfile)' => '$(link_target)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/008.cf����������������������������������������������������0000644�0001750�0001750�00000003217�11715232734�015715� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous copy with exists compare to fail # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { vars: "mode" int => "0600"; files: "$(g.testfile)" create => "true", copy_from => test_copy; } body copy_from test_copy { source => "/etc/group"; compare => "exists"; } ####################################################### bundle agent check { vars: "expect" string => "$(test.mode) 1 0 0 0"; "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("$(expect)", "$(result)"); reports: DEBUG:: "expected: '$(expect)'"; "got: '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/114.cf����������������������������������������������������0000644�0001750�0001750�00000004072�11715232734�015713� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Create a file, expect simultaneous link with symlink and move_obstructions # to succeed # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # This extracts the inode number of the linked file "command" string => 'printf "%d", (stat("$(g.testfile)"))[1]'; # This extracts the inode number of the symlink "Lcommand" string => 'printf "%d", (lstat("$(g.testfile)"))[1]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[1]'; "source_ino" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); } ####################################################### bundle agent init { files: "$(g.testfile)" delete => init_delete; } body delete init_delete { dirlinks => "delete"; rmdirs => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", move_obstructions => "true", link_from => test_link; } body link_from test_link { source => "/etc/group"; link_type => "symlink"; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); "Lresult" string => execresult( "/usr/bin/perl -le '$(g.Lcommand)'", "noshell"); classes: "okL" not => strcmp("$(g.source_ino)", "$(Lresult)"); "ok" and => { "okL", strcmp("$(g.source_ino)", "$(result)") }; reports: DEBUG:: "expected: '$(g.source_ino)'"; "got: '$(Lresult)' => '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/019.cf����������������������������������������������������0000644�0001750�0001750�00000002570�11715232734�015720� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test that disable_mode => "333" in body rename works (Issue 688) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine"; "testfile" string => "$(testdir)/testfile"; "command" string => 'printf "%o %d", (stat("$(g.testfile).cfdisabled"))[2]&07777, (stat(_))[3]'; } ####################################################### bundle agent init { files: "$(g.testfile)" create => "true"; } ####################################################### bundle agent test { files: "$(g.testfile)" rename => disable_file; } body rename disable_file { disable_mode => "333"; disable => "true"; } ####################################################### bundle agent check { vars: "result" string => execresult("/usr/bin/perl -le '$(g.command)'", "noshell"); classes: "ok" expression => strcmp("333 1", "$(result)"); reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } ����������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/02_maintain/205.cf����������������������������������������������������0000644�0001750�0001750�00000005261�11715232734�015715� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Copy a file, then ensure that subsequent create=true doesn't # overwrite mode, size, but DOES change owner, group (symbolic IDs) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; # # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%05o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[7]'; "source_size" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); } ####################################################### bundle agent init { vars: any:: "mode" int => "01751"; linux:: "owner" string => "sys"; "group" string => "sys"; freebsd:: "owner" string => "bin"; "group" string => "sys"; !(linux|freebsd):: "owner" string => "undefined-please-fix"; "group" string => "undefined-please-fix"; pass2:: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); files: "$(g.testfile)" copy_from => init_copy("$(g.source)"), perms => init_perms("$(mode)", "$(owner)", "$(group)"), classes => init_set_class("pass2"); } body copy_from init_copy(file) { source => "$(file)"; } body perms init_perms(m, o, g) { mode => "$(m)"; owners => { "$(o)" }; groups => { "$(g)" }; } body classes init_set_class(class) { promise_kept => { "$(class)" }; promise_repaired => { "$(class)" }; } ####################################################### bundle agent test { files: "$(g.testfile)" create => "true", perms => test_perms("a+r"); } body perms test_perms(m) { mode => "$(m)"; owners => { "root" }; linux:: groups => { "root" }; freebsd:: groups => { "wheel" }; } ####################################################### bundle agent check { vars: "result" string => execresult( "/usr/bin/perl -le '$(g.command)'", "noshell"); "expected" string => "01755 1 0 0 $(g.source_size)"; classes: "ok" expression => strcmp("$(expected)", "$(result)"); reports: DEBUG:: "init.result is '$(init.result)'"; "expected is '$(expected)'"; "check.result is '$(result)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testfile)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/03_transform/���������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�015366� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/03_transform/003.cf���������������������������������������������������0000644�0001750�0001750�00000004240�11715232734�016121� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Ensure that the transformer runs only once for every file in a recursive tree # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine"; # # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%#o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[7]'; "source_size" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); } ####################################################### bundle agent init { vars: "files" slist => { "1", "2", "3" }; files: "$(g.testdir)/." create => "true"; "$(g.testdir)/$(files)" copy_from => init_copy("/etc/group"); } body copy_from init_copy(file) { source => "$(file)"; } body classes init_set_class(class) { promise_kept => { "$(class)" }; promise_repaired => { "$(class)" }; } ####################################################### bundle agent test { vars: "counter" string => "$(g.testdir)/counter"; files: "$(g.testdir)" transformer => "/bin/sh -c 'echo $(this.promiser) >> $(counter)'", file_select => test_plain, depth_search => test_recurse; } body file_select test_plain { file_types => { "plain" }; file_result => "file_types"; } body depth_search test_recurse { depth => "inf"; } ####################################################### bundle agent check { vars: "count" string => execresult("/usr/bin/wc $(test.counter)", "noshell"); classes: "ok" expression => regcmp("\s*3\s.*", "$(count)"); reports: DEBUG:: "3 transformations expected, saw '$(count)'"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/03_transform/002.cf���������������������������������������������������0000644�0001750�0001750�00000005041�11715232734�016120� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Ensure that the transformer does not run when --dry-run is used # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { vars: any:: "files" slist => { "1", "2", "3" }; bin_gzip:: "gzip" string => "/bin/gzip", policy => "free"; usr_bin_gzip:: "gzip" string => "/usr/bin/gzip", policy => "free"; classes: "bin_gzip" expression => fileexists("/bin/gzip"); "usr_bin_gzip" expression => fileexists("/usr/bin/gzip"); files: "$(g.testdir)/." create => "true"; "$(g.testdir)/$(files)" copy_from => init_copy("/etc/group"); } body copy_from init_copy(file) { source => "$(file)"; } body classes init_set_class(class) { promise_kept => { "$(class)" }; promise_repaired => { "$(class)" }; } ####################################################### bundle agent test { commands: "$(sys.cf_agent) -f $(this.promise_filename) -D AUTO -K -b init,test_dry_run --dry-run" contain => start_from_cwd; } body contain start_from_cwd { chdir => "$(G.cwd)"; } bundle agent test_dry_run { files: "$(g.testdir)" transformer => "$(init.gzip) $(this.promiser)", file_select => test_plain, depth_search => test_recurse; reports: !opt_dry_run:: "$(this.promise_filename) --dry-run FAIL"; } body file_select test_plain { file_types => { "plain" }; file_result => "file_types"; } body depth_search test_recurse { depth => "inf"; } ####################################################### bundle agent check { vars: "files" slist => { @{init.files} }; classes: "ok$(files)" expression => fileexists("$(g.testdir)/$(files)"); "no$(files)" expression => fileexists("$(g.testdir)/$(files).gz"); "ok" and => { "ok1", "ok2", "ok3", "!no1", "!no2", "!no3", }; reports: DEBUG:: "$(g.testdir)/$(files) exists with no $(g.testdir)/$(files).gz" ifvarclass => "ok$(files).!no$(files)"; "$(g.testdir)/$(files).gz was created during --dry-run!" ifvarclass => "no$(files)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/10_files/03_transform/001.cf���������������������������������������������������0000644�0001750�0001750�00000004744�11715232734�016130� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Ensure that the transformer runs for every file in a recursive tree # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testdir" string => "/tmp/TEST.cfengine"; # # This extracts the octal mode, and decimal nlink, uid, gid, size "command" string => 'printf "%#o" . " %d" x 4, (stat("$(g.testfile)"))[2]&07777, (stat(_))[3..5,7]'; "source" string => "/etc/group"; "source_command" string => 'printf "%d", (stat("$(g.source)"))[7]'; "source_size" string => execresult( "/usr/bin/perl -le '$(g.source_command)'", "noshell"); } ####################################################### bundle agent init { vars: any:: "files" slist => { "1", "2", "3" }; bin_gzip:: "gzip" string => "/bin/gzip", policy => "free"; usr_bin_gzip:: "gzip" string => "/usr/bin/gzip", policy => "free"; classes: "bin_gzip" expression => fileexists("/bin/gzip"); "usr_bin_gzip" expression => fileexists("/usr/bin/gzip"); files: "$(g.testdir)/." create => "true"; "$(g.testdir)/$(files)" copy_from => init_copy("/etc/group"); } body copy_from init_copy(file) { source => "$(file)"; } body classes init_set_class(class) { promise_kept => { "$(class)" }; promise_repaired => { "$(class)" }; } ####################################################### bundle agent test { files: "$(g.testdir)" transformer => "$(init.gzip) $(this.promiser)", file_select => test_plain, depth_search => test_recurse; } body file_select test_plain { file_types => { "plain" }; file_result => "file_types"; } body depth_search test_recurse { depth => "inf"; } ####################################################### bundle agent check { vars: "files" slist => { @{init.files} }; classes: "ok$(files)" expression => fileexists("$(g.testdir)/$(files).gz"); "ok" and => { "ok1", "ok2", "ok3" }; reports: DEBUG:: "$(g.testdir)/$(files).gz exists as expected" ifvarclass => "ok$(files)"; "$(g.testdir)/$(files).gz was not created!" ifvarclass => "!ok$(files)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { methods: "any" usebundle => default_fini("$(g.testdir)"); } ����������������������������cfengine-3.2.4/tests/testall������������������������������������������������������������������������0000755�0001750�0001750�00000014466�11715232734�012777� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/sh # # Copyright (C) Cfengine AS # # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # # 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; version 3. # # 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 # # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # LOG=test.log SUMMARY=summary.log QUIET= NOVA= STAGING= NETWORK=1 DEFAGENT=/var/cfengine/bin/cf-agent AGENT=${DEFAGENT} PASSED_TESTS=0 FAILED_TESTS=0 FAILED_TO_CRASH_TESTS=0 SKIPPED_TESTS=0 usage() { echo "testall [-q] [--no-nova] [--staging] [--no-network] [--agent=<agent>] [<test> <test>...]" echo echo "If no test is given, all tests are run:" echo " Tests with names of form NNN.cf are expected to run succesfully" echo " Tests with names of form NNNx.cf are expected to crash" echo " Tests with names of form NNNn.cf and NNNnx.cf are run only under Nova" echo " (and may be disabled by --no-nova option)" echo " Tests inside directories called 'staging' are not run" echo " (unless --staging option is passed)" echo " Tests inside directories called 'network' are not run" echo " if --no-network option is passed" echo echo "If arguments are given, those are executed as tests" echo echo " -q makes script much quieter" echo echo " --agent provides a way to specify non-default cf-agent location," echo " and defaults to $DEFAGENT." } runtest() { AGENT="$1" TEST="$2" if [ -z "$QUIET" ]; then echo -n "$TEST " fi if echo "$TEST" | grep -q -F -e x.cf ; then EXPECTED_CRASH=1 else EXPECTED_CRASH= fi if [ -z "$NOVA" ] && echo "$TEST" | grep -q -e 'nx\?\.cf'; then SKIP=1 SKIPREASON="Nova tests are disabled" elif [ -z "$STAGING" ] && echo "$TEST" | grep -q -e 'staging'; then SKIP=1 SKIPREASON="Staging tests are disabled" elif [ -z "$NETWORK" ] && echo "$TEST" | grep -q -e 'network'; then SKIP=1 SKIPREASON="Network-dependent tests are disabled" else SKIP= SKIPREASON= fi ( echo ---------------------------------------------------------------------- echo "$TEST"${EXPECTED_CRASH:+ \(expected to crash\)}${SKIPREASON:+ \($SKIPREASON\)} echo ---------------------------------------------------------------------- ) >> $LOG if [ -z "$SKIP" ]; then OUT=$(sudo $AGENT -Kf "$TEST" -D AUTO,DEBUG 2>&1) RETVAL=$? echo "$OUT" >> $LOG echo >> $LOG echo "Return code is $RETVAL." >> $LOG if [ -z "$EXPECTED_CRASH" ]; then if [ $RETVAL -eq 0 ] && echo "$OUT" | grep -q -F -e "R: $TEST Pass"; then RESULT=Pass else RESULT=FAIL fi else if [ $RETVAL -ne 0 ]; then RESULT=Pass else RESULT="FAILed to crash" fi fi FLATNAME=$(echo "$TEST" | sed 's,[./],_,g') if [ "$RESULT" != Pass ] && [ -e .succeeded/"$FLATNAME" ]; then echo $TEST $RESULT '(UNEXPECTED FAILURE)' >> $SUMMARY else echo $TEST $RESULT >> $SUMMARY fi if [ -z "$QUIET" ]; then if [ "$RESULT" != Pass ] && [ -e .succeeded/"$FLATNAME" ]; then echo $RESULT '(UNEXPECTED FAILURE)' else echo $RESULT fi else if [ "$RESULT" = Pass ]; then echo -n '.' else if [ -n "$EXPECTED_CRASH" ]; then echo -n '!' else echo -n 'x' fi fi fi ( echo echo ' ==>' $RESULT echo ) >> $LOG if [ "$RESULT" = Pass ]; then PASSED_TESTS=$(($PASSED_TESTS + 1)) mkdir -p '.succeeded' touch .succeeded/"$FLATNAME" elif [ "$RESULT" = FAIL ]; then FAILED_TESTS=$(($FAILED_TESTS + 1)) elif [ "$RESULT" = "FAILed to crash" ]; then FAILED_TO_CRASH_TESTS=$(($FAILED_TO_CRASH_TESTS + 1)) fi else echo $TEST Skipped >> $SUMMARY if [ -z "$QUIET" ]; then echo Skipped else printf '-' fi SKIPPED_TESTS=$(($SKIPPED_TESTS + 1)) fi } while true; do case "$1" in --help) usage exit;; -q) QUIET=1;; --no-nova) NOVA=;; --staging) STAGING=1;; --no-network) NETWORK=;; --agent=*) AGENT=${1#--agent=};; -*) echo "Unknown option: $1" exit 1;; *) break;; esac shift done if $AGENT -V | grep -q 'Nova'; then NOVA=1 fi if [ $# -gt 0 ]; then for test in "$@"; do if ! expr "$test" : '[/.]' >/dev/null; then test="./$test" fi if [ -f $test ]; then TESTS="$TESTS $test" elif [ -d $test ]; then ADDTESTS=$(find $test -name '[0-9][0-9][0-9]*.cf' | sort) TESTS="$TESTS $ADDTESTS" else echo "Unable to open test file/directory: $test" fi done else TESTS=$(find $(dirname $0) -name '[0-9][0-9][0-9]*.cf' | sort) fi TESTS_COUNT=$(echo $TESTS | wc -w) START_TIME=$(date +%s) : > $SUMMARY ( echo ====================================================================== echo Testsuite started at $(date "+%F %T") echo ---------------------------------------------------------------------- echo Total tests: $TESTS_COUNT ) > $LOG for test in $TESTS; do if [ -n "$USE_VALGRIND" ]; then runtest "valgrind --leak-check=full --show-reachable=yes $AGENT" "$test" else runtest $AGENT "$test" fi done END_TIME=$(date +%s) ( echo echo ====================================================================== echo Testsuite finished at $(date "+%F %T") \($(($END_TIME - $START_TIME)) seconds\) echo echo Passed tests: $PASSED_TESTS echo Failed tests: $FAILED_TESTS echo Failed to crash tests: $FAILED_TO_CRASH_TESTS echo Skipped tests: $SKIPPED_TESTS ) | tee -a $LOG if [ "$FAILED_TESTS" -ne 0 ] || [ "$FAILED_TO_CRASH_TESTS" -ne 0 ]; then exit 1 else exit 0 fi ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/08_commands/�������������������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�013557� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/08_commands/02_syntax/���������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�015406� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/08_commands/02_syntax/001.cf���������������������������������������������������0000644�0001750�0001750�00000003720�11715232734�016141� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test that backslashes are correctly passed to commands (Issue 471) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "testfile" string => "/tmp/TEST.cfengine"; } ####################################################### bundle agent init { files: "$(g.testfile)" create => "true", edit_defaults => empty, edit_line => setup_lines; } body edit_defaults empty { empty_file_before_editing => "true"; } bundle edit_line setup_lines { insert_lines: "a test"; "a.test"; "nottest"; } ####################################################### bundle agent test { vars: "all_lines" string => execresult("/bin/egrep -c '.' $(g.testfile)", "useshell"); "re_lines" string => execresult("/bin/egrep -c 'a.test' $(g.testfile)", "useshell"); "lit_lines" string => execresult("/bin/egrep -c 'a\.test' $(g.testfile)", "useshell"); "doubleslash_lit_lines" string => execresult("/bin/egrep -c 'a\\.test' $(g.testfile)", "useshell"); } ####################################################### bundle agent check { classes: "ok" and => { strcmp("$(test.all_lines)", "3"), strcmp("$(test.re_lines)", "2"), strcmp("$(test.lit_lines)", "1"), strcmp("$(test.doubleslash_lit_lines)", "1") }; reports: DEBUG:: "all_lines: $(test.all_lines) =?= 3"; "re_lines: $(test.re_lines) =?= 2"; "lit_lines: $(test.lit_lines) =?= 1"; "doubleslash_lit_lines: $(test.doubleslash_lit_lines) =?= 1"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������������������������������������������cfengine-3.2.4/tests/08_commands/01_modules/��������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�015527� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/08_commands/01_modules/001.cf.script�������������������������������������������0000755�0001750�0001750�00000000107�11715232734�017564� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/sh echo +CLASSTOBEDEFINED echo -UNDEFINEDCLASS echo =answer=42 ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/08_commands/01_modules/001.cf��������������������������������������������������0000644�0001750�0001750�00000002762�11715232734�016267� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test command modules # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "script_name" string => "$(this.promise_filename).script"; } ####################################################### bundle agent test { classes: "matched" expression => regextract(".+/([^/]+)$", "${init.script_name}", "script_basename"); commands: "$(this.promise_filename).script" module => "true"; } ####################################################### bundle agent check { vars: "canonical_script_basename" string => canonify("${test.script_basename[1]}"); classes: CLASSTOBEDEFINED.!UNDEFINEDCLASS:: "classok" expression => "any"; any:: "varok" expression => strcmp("${${canonical_script_basename}.answer}", "42"); "ok" and => { "classok", "varok" }; reports: DEBUG:: "${${canonical_script_basename}.answer} =?= 42"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ��������������cfengine-3.2.4/tests/14_reports/��������������������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�013451� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/14_reports/00_output/����������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�015310� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/14_reports/00_output/001.cf.sub.in���������������������������������������������0000644�0001750�0001750�00000000025�11715232734�017233� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������firstline secondline �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/14_reports/00_output/001.cf����������������������������������������������������0000644�0001750�0001750�00000002344�11715232734�016044� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test that printfile honors number_of_lines constraint (Issue 686) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "subout" string => execresult("$(sys.cf_agent) -Kf $(this.promise_filename).sub", "noshell"); } ####################################################### bundle agent check { classes: "firstline" expression => regcmp(".*firstline.*", "$(test.subout)"); "nosecondline" not => regcmp(".*secondline.*", "$(test.subout)"); "ok" and => { "firstline", "nosecondline" }; reports: DEBUG:: "$(test.subout)"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/14_reports/00_output/001.cf.sub������������������������������������������������0000644�0001750�0001750�00000000470�11715232734�016632� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������body common control { bundlesequence => { 'test' }; } bundle agent test { vars: "cwd" string => execresult("/bin/pwd", "noshell"); reports: cfengine_3:: "doesnotmatterr" printfile => p; } body printfile p { file_to_print => "$(test.cwd)/$(this.promise_filename).in"; number_of_lines => "1"; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/��������������������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�013405� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/�����������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�014766� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/003.cf�����������������������������������������������������0000644�0001750�0001750�00000001665�11715232734�015531� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test and # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" and => { "cfengine_3" }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/002.cf�����������������������������������������������������0000644�0001750�0001750�00000001671�11715232734�015525� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test not # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "not_ok" not => "any"; "ok" not => "not_ok"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/013.cf�����������������������������������������������������0000644�0001750�0001750�00000001724�11715232734�015526� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test xor # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" xor => { "cfengine_3", "this_was_not_defined", }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ��������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/027.cf�����������������������������������������������������0000644�0001750�0001750�00000001747�11715232734�015540� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Check canonification in ifvarclass # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { commands: "/bin/true" classes => if_repaired("/test"); } body classes if_repaired(z) { promise_repaired => { "$(z)" }; } ####################################################### bundle agent check { classes: "ok" expression => "_test"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �������������������������cfengine-3.2.4/tests/02_classes/01_basic/009.cf�����������������������������������������������������0000644�0001750�0001750�00000001754�11715232734�015536� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test or # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" or => { "this_was_not_defined", "cfengine_3", "neither_was_this", }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ��������������������cfengine-3.2.4/tests/02_classes/01_basic/004.cf�����������������������������������������������������0000644�0001750�0001750�00000001702�11715232734�015522� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test and # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" and => { "any", "cfengine_3" }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ��������������������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/017.cf�����������������������������������������������������0000644�0001750�0001750�00000001720�11715232734�015526� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test brackets on "and" (Issue 234) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" and => { userexists("root") }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/018.cf�����������������������������������������������������0000644�0001750�0001750�00000001716�11715232734�015534� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test brackets on "or" (Issue 234) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" or => { userexists("root") }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ��������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/025.cf�����������������������������������������������������0000644�0001750�0001750�00000002045�11715232734�015526� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Check ifvarclass with array # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { classes: "classtotest" expression => "any"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { vars: "foobar[0]" string => "classtotest"; classes: "ok" expression => "any", ifvarclass => "$(foobar[0])"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/011.cf�����������������������������������������������������0000644�0001750�0001750�00000001736�11715232734�015527� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test xor # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "not_ok" xor => { "cfengine_3", "any", }; "ok" not => "not_ok"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ����������������������������������cfengine-3.2.4/tests/02_classes/01_basic/006.cf�����������������������������������������������������0000644�0001750�0001750�00000001726�11715232734�015532� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test and # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "not_ok" and => { "this_was_not_defined" }; "ok" not => "ok"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/026.cf�����������������������������������������������������0000644�0001750�0001750�00000002013�11715232734�015522� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Check ifvarclass with qualified variable # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { classes: "classtotest" expression => "any"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "foobar" string => "classtotest"; } ####################################################### bundle agent check { classes: "ok" expression => "any", ifvarclass => "$(test.foobar)"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/012.cf�����������������������������������������������������0000644�0001750�0001750�00000001765�11715232734�015532� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test xor # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "not_ok" xor => { "this_was_not_defined", "neither_was_this", }; "ok" not => "not_ok"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������cfengine-3.2.4/tests/02_classes/01_basic/007.cf�����������������������������������������������������0000644�0001750�0001750�00000001724�11715232734�015531� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test or # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "not_ok" or => { "this_was_not_defined" }; "ok" not => "ok"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ��������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/118x.cf����������������������������������������������������0000644�0001750�0001750�00000001723�11715232734�015723� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test no brackets on "or" (Issue 234) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" or => userexists("root"); reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/119x.cf����������������������������������������������������0000644�0001750�0001750�00000001725�11715232734�015726� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test no brackets on "xor" (Issue 234) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" xor => userexists("root"); reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/024.cf�����������������������������������������������������0000644�0001750�0001750�00000002156�11715232734�015530� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test complex expression (issue 487) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "class1" expression => "any"; "class2" expression => "any"; "class3" expression => "any"; "class4" expression => "any"; class1.(class2|class3.class4):: "ok" expression => "any"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/001.cf�����������������������������������������������������0000644�0001750�0001750�00000001656�11715232734�015527� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test not # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" not => "class_never_defined"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ����������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/022x.cf����������������������������������������������������0000644�0001750�0001750�00000001744�11715232734�015720� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test syntactically errorneous class expression # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { vars: !.!:: "undererror" string => "undererror"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ����������������������������cfengine-3.2.4/tests/02_classes/01_basic/014.cf�����������������������������������������������������0000644�0001750�0001750�00000001704�11715232734�015525� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test xor # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" xor => { "cfengine_3", "!any", }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/015.cf�����������������������������������������������������0000644�0001750�0001750�00000001713�11715232734�015526� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test xor # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" xor => { "!any", "!any", "any", }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/005.cf�����������������������������������������������������0000644�0001750�0001750�00000001767�11715232734�015536� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test and # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "not_ok" and => { "any", "cfengine_3", "this_was_not_defined" }; "ok" not => "ok"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������cfengine-3.2.4/tests/02_classes/01_basic/016.cf�����������������������������������������������������0000644�0001750�0001750�00000001711�11715232734�015525� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test xor # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" xor => { "any", "any", "any", }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �������������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/010.cf�����������������������������������������������������0000644�0001750�0001750�00000001701�11715232734�015516� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test or # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" or => { "cfengine_3", "any", }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/008.cf�����������������������������������������������������0000644�0001750�0001750�00000001757�11715232734�015540� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test or # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "not_ok" or => { "this_was_not_defined", "neither_was_this", }; "ok" not => "ok"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������cfengine-3.2.4/tests/02_classes/01_basic/117x.cf����������������������������������������������������0000644�0001750�0001750�00000001725�11715232734�015724� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test no brackets on "and" (Issue 234) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" and => userexists("root"); reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/028.cf�����������������������������������������������������0000644�0001750�0001750�00000002214�11715232734�015527� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Check that we can use || in class expressions # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: any||something:: "oklhs" expression => "any"; something||any:: "okrhs" expression => "any"; any||any:: "okboth" expression => "any"; something||something:: "okno" expression => "any"; any:: "ok" and => { "oklhs", "okrhs", "okboth", "!okno" }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/019.cf�����������������������������������������������������0000644�0001750�0001750�00000001720�11715232734�015530� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test brackets on "xor" (Issue 234) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" xor => { userexists("root") }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������������������������������������������cfengine-3.2.4/tests/02_classes/01_basic/023.cf�����������������������������������������������������0000644�0001750�0001750�00000002160�11715232734�015522� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test complex expression (issue 487) # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "class1" expression => "any"; "class2" expression => "any"; "class3" expression => "any"; "class4" expression => "any"; class1.(class2|(class3.class4)):: "ok" expression => "any"; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/02_functions/�������������������������������������������������������0000755�0001750�0001750�00000000000�11715233356�015716� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/02_functions/003.cf�������������������������������������������������0000644�0001750�0001750�00000002214�11715232734�016450� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test isvariable() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { vars: "present" int => "1"; classes: "should_fail" or => { isvariable("x"), isvariable("g.x") }; "should_pass" not => "should_fail"; "ok" and => { "should_pass", isvariable("present"), isvariable("g.dummy") }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/02_functions/002.cf�������������������������������������������������0000644�0001750�0001750�00000003077�11715232734�016457� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test islessthan() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok1" expression => islessthan("0", "1"); "ok2" expression => islessthan("1", "2.7e3"); "ok3" expression => islessthan("1.1", "2"); "ok4" expression => islessthan("2.7e3", "1e9"); "ok5" expression => islessthan("2z", "3b"); "ok6" expression => islessthan("alpha", "beta"); "ok7" expression => islessthan("", "beta"); "ok8" expression => islessthan("-75", "beta"); "ok9" expression => islessthan("", "3"); "ok" and => { ok1, ok2, ok3, ok4, ok5, ok6, ok7, ok8, ok9 }; reports: DEBUG.ok1:: "ok1"; DEBUG.ok2:: "ok2"; DEBUG.ok3:: "ok3"; DEBUG.ok4:: "ok4"; DEBUG.ok5:: "ok5"; DEBUG.ok6:: "ok6"; DEBUG.ok7:: "ok7"; DEBUG.ok8:: "ok8"; DEBUG.ok9:: "ok9"; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/02_functions/013.cf�������������������������������������������������0000644�0001750�0001750�00000001667�11715232734�016464� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test isplain() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" not => isplain("/xxgobbleroot"); reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/02_functions/009.cf�������������������������������������������������0000644�0001750�0001750�00000001753�11715232734�016465� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test groupexists() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" xor => { groupexists("bin"), groupexists("xxxscrabblebin"), }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������cfengine-3.2.4/tests/02_classes/02_functions/004.cf�������������������������������������������������0000644�0001750�0001750�00000002357�11715232734�016461� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test strcmp() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { vars: "null" string => ""; "one" int => "1"; classes: "should_fail" or => { strcmp("$(null)", "$(one)"), strcmp("01", "$(one)"), strcmp("g.x", "$(g.x)") }; "should_pass" not => "should_fail"; "ok" and => { "should_pass", strcmp("", "$(null)"), strcmp("1", "$(one)"), strcmp("dummy", "$(g.dummy)") }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/02_functions/011.cf�������������������������������������������������0000644�0001750�0001750�00000001735�11715232734�016456� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test isplain() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" xor => { isplain("/etc/passwd"), isplain("/etc"), }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������cfengine-3.2.4/tests/02_classes/02_functions/030.cf�������������������������������������������������0000644�0001750�0001750�00000002612�11715232734�016452� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test concat() function # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { vars: "a" string => "a"; "b" string => "b"; "c" string => "c"; "str" string => "str"; "nil" string => ""; classes: "noarg" expression => strcmp(concat(), ""); "a" expression => strcmp(concat("$(a)"), "a"); "a_b" expression => strcmp(concat("$(a)", "$(b)"), "ab"); "a_b_c" expression => strcmp(concat("$(a)", "$(b)", "$(c)"), "abc"); "nil_nil" expression => strcmp(concat("$(nil)", "$(nil)"), ""); "str_str" expression => strcmp(concat("$(str)", "$(str)"), "strstr"); "ok" and => { "noarg", "a", "a_b", "a_b_c", "nil_nil", "str_str" }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ����������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/02_functions/012.cf�������������������������������������������������0000644�0001750�0001750�00000001663�11715232734�016457� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test isdir() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" not => isdir("/xxgobbleroot"); reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/02_functions/001.cf�������������������������������������������������0000644�0001750�0001750�00000002340�11715232734�016446� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test isgreaterthan() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" and => { isgreaterthan("1", "0"), isgreaterthan("2.7e3", "1"), isgreaterthan("2", "1.1"), isgreaterthan("2.7e3", "9e1"), isgreaterthan("3b", "2z"), isgreaterthan("beta", "alpha"), isgreaterthan("beta", ""), isgreaterthan("beta", "-75"), isgreaterthan("3", ""), }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/02_functions/005.cf�������������������������������������������������0000644�0001750�0001750�00000004330�11715232734�016453� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test join() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { vars: "zeros" slist => { "solo" }; "zero" string => join("NOISE", "zeros"); "ones" slist => { "a", "bb", "ccc" }; "one" string => join(":", "ones"); "twos" slist => { "xx", "xx", "xx" }; "two" string => join("..", "twos"); "threes" slist => { "" }; "three" string => join("", "threes"); "fours" slist => { "1", "", "3" }; "four" string => join("", "fours"); "fives" slist => { "1", "", "3" }; "five" string => join(",", "fives"); "sixs" slist => { "one ", " two ", " three" }; "six" string => join(" and ", "sixs"); classes: "ok1" expression => strcmp("solo", "$(zero)"); "ok2" expression => strcmp("a:bb:ccc", "$(one)"); "ok3" expression => strcmp("xx..xx..xx", "$(two)"); "ok4" expression => strcmp("", "$(three)"); "ok5" expression => strcmp("13", "$(four)"); "ok6" expression => strcmp("1,,3", "$(five)"); "ok7" expression => strcmp("one and two and three", "$(six)"); "ok" and => { ok1, ok2, ok3, ok4, ok5, ok6, ok7 }; reports: DEBUG.ok1:: "ok1"; DEBUG.ok2:: "ok2"; DEBUG.ok3:: "ok3"; DEBUG.ok4:: "ok4"; DEBUG.ok5:: "ok5"; DEBUG.ok6:: "ok6"; DEBUG.ok7:: "ok7"; DEBUG:: 'strcmp("solo", "$(zero)")'; 'strcmp("a:bb:ccc", "$(one)")'; 'strcmp("xx..xx..xx", "$(two)")'; 'strcmp("", "$(three)")'; 'strcmp("13", "$(four)")'; 'strcmp("1,,3", "$(five)")'; 'strcmp("one and two and three", "$(six)")'; ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/02_functions/010.cf�������������������������������������������������0000644�0001750�0001750�00000001727�11715232734�016456� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test isdir() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" xor => { isdir("/etc"), isdir("/etc/passwd"), }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������������cfengine-3.2.4/tests/02_classes/02_functions/029.cf�������������������������������������������������0000644�0001750�0001750�00000005575�11715232734�016475� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test logical functions in ifvarclass # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "and_yes_both" expression => "any", ifvarclass => and("any", "any"); "and_no_left" expression => "any", ifvarclass => and("any", "none"); "and_no_right" expression => "any", ifvarclass => and("none", "any"); "and_no_none" expression => "any", ifvarclass => and("none", "none"); "and_arg_fun" expression => "any", ifvarclass => and(isdir("/")); "and_no_arg_fun" expression => "any", ifvarclass => and(isdir("/bin/sh")); "and_two_args_fun" expression => "any", ifvarclass => and(isdir("/"), isdir("/")); "and_long" expression => "any", ifvarclass => and("any", "any", "any", "any", "any", "any", "any", "any"); "and_ok" and => { "and_yes_both", "!and_no_left", "!and_no_right", "!and_no_none", "and_arg_fun", "!and_no_arg_fun", "and_two_args_fun", "and_long" }; # "or_yes_both" expression => "any", ifvarclass => or("any", "any"); "or_yes_left" expression => "any", ifvarclass => or("any", "none"); "or_yes_right" expression => "any", ifvarclass => or("none", "any"); "or_no_none" expression => "any", ifvarclass => or("none", "none"); "or_arg_fun" expression => "any", ifvarclass => or(isdir("/")); "or_no_arg_fun" expression => "any", ifvarclass => or(isdir("/bin/sh")); "or_two_args_fun" expression => "any", ifvarclass => or(isdir("/"), isexecutable("/")); "or_long" expression => "any", ifvarclass => or("any", "any", "any", "any", "any", "any", "any", "any"); "or_ok" and => { "or_yes_both", "or_yes_left", "or_yes_right", "!or_no_none", "or_arg_fun", "!or_no_arg_fun", "or_two_args_fun", "or_long" }; # "not_yes_no" expression => "any", ifvarclass => not("none"); "not_no_yes" expression => "any", ifvarclass => not("any"); "not_arg_fun" expression => "any", ifvarclass => not(islink("/")); "not_ok" and => { "not_yes_no", "!not_no_yes", "not_arg_fun" }; "ok" and => { "and_ok", "or_ok", "not_ok" }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } �����������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/tests/02_classes/02_functions/008.cf�������������������������������������������������0000644�0001750�0001750�00000001752�11715232734�016463� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������####################################################### # # Test userexists() # ####################################################### body common control { inputs => { "../../default.cf" }; bundlesequence => { "g", default("$(this.promise_filename)") }; version => "1.0"; nova_edition:: host_licenses_paid => "5"; } bundle common g { vars: "dummy" string => "dummy"; } ####################################################### bundle agent init { vars: "dummy" string => "dummy"; } ####################################################### bundle agent test { vars: "dummy" string => "dummy"; } ####################################################### bundle agent check { classes: "ok" xor => { userexists("root"), userexists("xxxscrabbleroot"), }; reports: ok:: "$(this.promise_filename) Pass"; !ok:: "$(this.promise_filename) FAIL"; } ####################################################### bundle agent fini { vars: "dummy" string => "dummy"; } ����������������������cfengine-3.2.4/config.guess�������������������������������������������������������������������������0000755�0001750�0001750�00000126730�11715232774�012561� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#! /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, # 2011 Free Software Foundation, Inc. timestamp='2011-05-11' # 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 <config-patches@gnu.org> 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 <config-patches@gnu.org>." 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, 2011 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'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; 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 <stdio.h> /* 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 <sys/systemcfg.h> 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:*:[4567]) 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 <stdlib.h> #include <unistd.h> 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 <unistd.h> 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 if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-gnueabi else echo ${UNAME_MACHINE}-unknown-linux-gnueabihf fi 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 ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-tilera-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' </usr/options/cb.name` echo ${UNAME_MACHINE}-pc-isc$UNAME_REL elif /bin/uname -X 2>/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 <Richard.M.Bartel@ccMail.Census.GOV> echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes <hewes@openmarket.com>. # 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 ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} 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 <<EOF #ifdef _SEQUENT_ # include <sys/types.h> # include <sys/utsname.h> #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 <sys/param.h> 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 <sys/param.h> # 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 <<EOF $0: unable to guess system type This script, last modified $timestamp, has failed to recognize the operating system you are using. It is advised that you download the most up to date version of the config scripts from http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD and http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD If the version you run ($0) is already up to date, please send the following data and any information you think might be pertinent to <config-patches@gnu.org> 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: ����������������������������������������cfengine-3.2.4/docs/��������������������������������������������������������������������������������0000755�0001750�0001750�00000000000�11715233355�011234� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/docs/cf-serverd.8��������������������������������������������������������������������0000644�0001750�0001750�00000004143�11715233353�013305� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������.TH cf-serverd 8 "Maintenance Commands" .SH NAME cf-serverd - cfengine's server agent .SH SYNOPSIS: cf-serverd [options] .SH DESCRIPTION: The server daemon provides two services: it acts as a file server for remote file copying and it allows an authorized cf-runagent to start start a cf-agent process and set certain additional classes with role-based access control. .B cfengine is a self-healing configuration and change management based system. You can think of.B cfengine as a very high level language, much higher level than Perl or shell. Asingle statement is called a promise, and compliance can result in many hundreds of filesbeing created, or the permissions of many hundreds offiles being set. The idea of .B cfengine is to create a one or more sets of configuration files which willclassify and describe the setup of every host in a network. .SH COMMAND LINE OPTIONS: .IP "--help, -h" Print the help message .IP "--debug, -d" value Set debugging level 0,1,2,3 .IP "--verbose, -v" Output verbose information about the behaviour of the agent .IP "--version, -V" Output the version of the software .IP "--file, -f" value Specify an alternative input file than the default .IP "--define, -D" value Define a list of comma separated classes to be defined at the start of execution .IP "--negate, -N" value Define a list of comma separated classes to be undefined at the start of execution .IP "--no-lock, -K" Ignore locking constraints during execution (ifelapsed/expireafter) if "too soon" to run .IP "--inform, -I" Print basic information about changes made to the system, i.e. promises repaired .IP "--diagnostic, -x" Activate internal diagnostics (developers only) .IP "--no-fork, -F" Run as a foreground processes (do not fork) .IP "--ld-library-path, -L" value Set the internal value of LD_LIBRARY_PATH for child processes .SH AUTHOR Mark Burgess and CFEngine AS .SH INFORMATION Bug reports: http://bug.cfengine.com, .pp Community help: http://forum.cfengine.com .pp Community info: http://www.cfengine.com/pages/community .pp Support services: http://www.cfengine.com .pp This software is Copyright (C) 2008-2012 CFEngine AS. �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/docs/cf-runagent.8�������������������������������������������������������������������0000644�0001750�0001750�00000005170�11715233353�013457� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������.TH cf-runagent 8 "Maintenance Commands" .SH NAME cf-runagent - Run agent .SH SYNOPSIS: cf-runagent [options] .SH DESCRIPTION: The run agent connects to a list of running instances of the cf-serverd service. The agent allows a user to forego the usual scheduling interval for the agent and activate cf-agent on a remote host. Additionally, a user can send additional classes to be defined on the remote host. Two kinds of classes may be sent: classes to decide on which hosts the agent will be started, and classes that the user requests the agent should define on execution. The latter type is regulated by cf-serverd's role based access control. .B cfengine is a self-healing configuration and change management based system. You can think of.B cfengine as a very high level language, much higher level than Perl or shell. Asingle statement is called a promise, and compliance can result in many hundreds of filesbeing created, or the permissions of many hundreds offiles being set. The idea of .B cfengine is to create a one or more sets of configuration files which willclassify and describe the setup of every host in a network. .SH COMMAND LINE OPTIONS: .IP "--help, -h" Print the help message .IP "--background, -b" value Parallelize connections (50 by default) .IP "--debug, -d" value Set debugging level 0,1,2,3 .IP "--verbose, -v" Output verbose information about the behaviour of the agent .IP "--dry-run, -n" All talk and no action mode - make no changes, only inform of promises not kept .IP "--version, -V" Output the version of the software .IP "--file, -f" value Specify an alternative input file than the default .IP "--define-class, -D" value Define a list of comma separated classes to be sent to a remote agent .IP "--select-class, -s" value Define a list of comma separated classes to be used to select remote agents by constraint .IP "--inform, -I" Print basic information about changes made to the system, i.e. promises repaired .IP "--remote-options, -o" value Pass options to a remote server process .IP "--diagnostic, -x" Activate internal diagnostics (developers only) .IP "--hail, -H" value Hail the following comma-separated lists of hosts, overriding default list .IP "--interactive, -i" Enable interactive mode for key trust .IP "--query, -q" value Query a server for a knowledge menu .IP "--timeout, -t" value Connection timeout, seconds .SH AUTHOR Mark Burgess and CFEngine AS .SH INFORMATION Bug reports: http://bug.cfengine.com, .pp Community help: http://forum.cfengine.com .pp Community info: http://www.cfengine.com/pages/community .pp Support services: http://www.cfengine.com .pp This software is Copyright (C) 2008-2012 CFEngine AS. ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������cfengine-3.2.4/docs/cf3_variables.html��������������������������������������������������������������0000644�0001750�0001750�00000001550�11707771421�014550� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Variables in cfengine 3

Variables in cfengine 3

Here is an important distinction. All variables are defined in bundles, because a variable assignment is a promise for a container to hold a value. There are no variable declarations in bodies, so the following email => "mark@cfengine.com"; is not a variable declaration, but represents the setting of a static attribute email to a value. If you want to think of this as a reserved variable that is okay, but you cannot use the value of this in an expression.
Mark Burgess
Last modified: Thu Jan 3 08:47:50 CET 2008 cfengine-3.2.4/docs/ConvergenceAndForcedChanges.html0000644000175000017500000000267511707771421017353 00000000000000 Convergence and Forced Operations

Convergence and Forced Operations

Cfengine is about convergence to a stable state. The state of the system should normally be at a fixed point, or else it should be returned to a fixed point. Occasionally changes in dependencies lead us to force changes, e.g. kill and restart a daemon.
commands:

    "Stop command";
    "Start command";
or
processes:

    "myprocess" signal => "term";

commands:

    "start command";
The problem with these commands is that they are not "guarded" (in the sense of Dijkstra's guarded commands). Such a command is not a convergent change unless it is qualified by a guarding class. e.g.
processes:

  change_in_dependency::

    "myprocess" signal => "term";


commands:

  change_in_dependency::

    "start command"
or
execution:

 change_in_dependency::

    "Stop command";
    "Start command";
or even
processes:

  change_in_dependency::

    "myprocess" 
        signal => "term"
        # define newclass ;


commands:

  new_class::

    "start command"

Mark Burgess
Last modified: Sat Aug 2 09:58:12 CEST 2008 cfengine-3.2.4/docs/cf-monitord.80000644000175000017500000000404211715233353013464 00000000000000.TH cf-monitord 8 "Maintenance Commands" .SH NAME cf-monitord - cfengine's monitoring agent .SH SYNOPSIS: cf-monitord [options] .SH DESCRIPTION: The monitoring agent is a machine-learning, sampling daemon which learns the normal state of the current host and classifies new observations in terms of the patterns formed by previous ones. The data are made available to and read by cf-agent for classification of responses to anomalous states. .B cfengine is a self-healing configuration and change management based system. You can think of.B cfengine as a very high level language, much higher level than Perl or shell. Asingle statement is called a promise, and compliance can result in many hundreds of filesbeing created, or the permissions of many hundreds offiles being set. The idea of .B cfengine is to create a one or more sets of configuration files which willclassify and describe the setup of every host in a network. .SH COMMAND LINE OPTIONS: .IP "--help, -h" Print the help message .IP "--debug, -d" value Set debugging level 0,1,2,3 .IP "--verbose, -v" Output verbose information about the behaviour of the agent .IP "--dry-run, -n" All talk and no action mode - make no changes, only inform of promises not kept .IP "--version, -V" Output the version of the software .IP "--no-lock, -K" Ignore system lock .IP "--file, -f" value Specify an alternative input file than the default .IP "--inform, -I" Print basic information about changes made to the system, i.e. promises repaired .IP "--diagnostic, -x" Activate internal diagnostics (developers only) .IP "--no-fork, -F" Run process in foreground, not as a daemon .IP "--histograms, -H" Ignored for backward compatibility .IP "--tcpdump, -T" Interface with tcpdump if available to collect data about network .SH AUTHOR Mark Burgess and CFEngine AS .SH INFORMATION Bug reports: http://bug.cfengine.com, .pp Community help: http://forum.cfengine.com .pp Community info: http://www.cfengine.com/pages/community .pp Support services: http://www.cfengine.com .pp This software is Copyright (C) 2008-2012 CFEngine AS. cfengine-3.2.4/docs/cf-promises.80000644000175000017500000000422211715233353013472 00000000000000.TH cf-promises 8 "Maintenance Commands" .SH NAME cf-promises - cfengine's promise analyzer .SH SYNOPSIS: cf-promises [options] .SH DESCRIPTION: The promise agent is a validator and analysis tool for configuration files belonging to any of the components of Cfengine. Configurations that make changes must be approved by this validator before being executed. .B cfengine is a self-healing configuration and change management based system. You can think of.B cfengine as a very high level language, much higher level than Perl or shell. Asingle statement is called a promise, and compliance can result in many hundreds of filesbeing created, or the permissions of many hundreds offiles being set. The idea of .B cfengine is to create a one or more sets of configuration files which willclassify and describe the setup of every host in a network. .SH COMMAND LINE OPTIONS: .IP "--help, -h" Print the help message .IP "--bundlesequence, -b" value Use the specified bundlesequence for verification .IP "--debug, -d" value Set debugging level 0,1,2,3 .IP "--verbose, -v" Output verbose information about the behaviour of the agent .IP "--dry-run, -n" All talk and no action mode - make no changes, only inform of promises not kept .IP "--version, -V" Output the version of the software .IP "--file, -f" value Specify an alternative input file than the default .IP "--define, -D" value Define a list of comma separated classes to be defined at the start of execution .IP "--negate, -N" value Define a list of comma separated classes to be undefined at the start of execution .IP "--inform, -I" Print basic information about changes made to the system, i.e. promises repaired .IP "--diagnostic, -x" Activate internal diagnostics (developers only) .IP "--analysis, -a" Perform additional analysis of configuration .IP "--reports, -r" Generate reports about configuration and insert into CFDB .SH AUTHOR Mark Burgess and CFEngine AS .SH INFORMATION Bug reports: http://bug.cfengine.com, .pp Community help: http://forum.cfengine.com .pp Community info: http://www.cfengine.com/pages/community .pp Support services: http://www.cfengine.com .pp This software is Copyright (C) 2008-2012 CFEngine AS. cfengine-3.2.4/docs/Makefile.am0000644000175000017500000000154411715232733013213 00000000000000 if !CROSS_COMPILING man_MANS = cf-agent.8 cf-serverd.8 cf-execd.8 cf-monitord.8 cf-report.8 cf-know.8 cf-runagent.8 cf-promises.8 cf-key.8 if HAVE_NOVA man_MANS += cf-hub.8 endif endif # Make sure these get distributed with everything else. EXTRA_DIST = $(man_MANS) $(srcdir)/*.png $(srcdir)/*.html %.8 : ../src/% $(MAKE) -C ../src $< ../src/$< -M > `echo $<.8 | sed s/src/docs/` # # Some basic clean ups # MOSTLYCLEANFILES = *~ *.orig # # Get everything removed down to where rebuilding requires: # "make; make install" # CLEANFILES = $(man_MANS) # # Get everything removed down to where rebuilding requires: # "configure; make; make install" # DISTCLEANFILES = # # Get everything removed down to where rebuilding requires: # "aclocal; autoconf; autoheader; automake --add-missing" # "configure; make; make install" # MAINTAINERCLEANFILES = Makefile.in cfengine-3.2.4/docs/cf-know.80000644000175000017500000000425711715233353012617 00000000000000.TH cf-know 8 "Maintenance Commands" .SH NAME cf-know - cfengine's knowledge agent .SH SYNOPSIS: cf-know [options] .SH DESCRIPTION: The knowledge management agent is capable of building and analysing a semantic knowledge network. It can configure a relational database to contain an ISO standard topic map and permit regular-expression based searching of the map. Analysis of the semantic network can be performed providing graphical output of the data, and cf-know can assemble and converge the reference manual for the current version of the Cfengine software. .B cfengine is a self-healing configuration and change management based system. You can think of.B cfengine as a very high level language, much higher level than Perl or shell. Asingle statement is called a promise, and compliance can result in many hundreds of filesbeing created, or the permissions of many hundreds offiles being set. The idea of .B cfengine is to create a one or more sets of configuration files which willclassify and describe the setup of every host in a network. .SH COMMAND LINE OPTIONS: .IP "--help, -h" Print the help message .IP "--build, -b" Build and store topic map in the CFDB .IP "--debug, -d" value Set debugging level 0,1,2,3 .IP "--verbose, -v" Output verbose information about the behaviour of the agent .IP "--version, -V" Output the version of the software .IP "--file, -f" value Specify an alternative input file than the default .IP "--manual, -m" Generate reference manual from internal data .IP "--manpage, -M" Generate reference manpage from internal data .IP "--stories, -z" value Look up stories for a given topic on the command line .IP "--syntax, -S" value Print a syntax summary of the optional keyword or this cfengine version .IP "--topics, -T" Show all topic names in CFEngine .IP "--test, -t" value Generate test data .IP "--removetest, -r" Remove test data .IP "--updatetest, -u" Update test data .SH AUTHOR Mark Burgess and CFEngine AS .SH INFORMATION Bug reports: http://bug.cfengine.com, .pp Community help: http://forum.cfengine.com .pp Community info: http://www.cfengine.com/pages/community .pp Support services: http://www.cfengine.com .pp This software is Copyright (C) 2008-2012 CFEngine AS. cfengine-3.2.4/docs/package-behaviour.html0000644000175000017500000000522611707771422015427 00000000000000
Identified package matches version constraints
add never
delete =,>=,<=
reinstall =,>=,<=
upgrade =,>=,<=
patch =,>=,<=
Identified package matched by name but not version
Dumb Manager Smart Manager
add unable Never
delete unable Attempt deletion
reinstall unable Attempt delete/add
upgrade unable Upgrade if capable
patch unable Patch if capable
Package not installed
Dumb Manager Smart Manager
add attempt to install named install any version
delete unable unable
reinstall attempt to install named unable
upgrade unable unable
patch unable unable
cfengine-3.2.4/docs/agents.html0000644000175000017500000000310711707771421013326 00000000000000 The agents of cfengine 3

The agents of cfengine 3

A generic agent can do some preprocessing of promise rules. This includes ordering and suppressing, or deleting rules. It also includes expanding parameterized rules and looking for broken promises. In order to process promises in an approximately optimal order, we must take into account several things:
  • Natural ordering within a bundle: interfaces, files, processes,
  • Parameterization and list expansion of bundles using variables and occurrences in the bundle list
  • Precondition precedence: rules that rely on other rules must come after them.
  • Class context: when are bundles, promises and attributes defined.
All this ends up being summarized by a sorted operational "playlist". We start with the bundlesequence from the "common control" body and make a list of these promises, placing any promises with "classes =>" bodies at the head so that they will precede any occurrences of rules that come later. Dependencies can occur in classes and variables: vars and classes defined by modules/processes outcome context/classes from actions Variable from context XXX was used in context YYY but XXX does not precede YYY in the bundlesequence. Class used in context XXX but cannot be defined cfengine-3.2.4/docs/modus_operandi.html0000644000175000017500000000231411707771422015055 00000000000000 Modus operandi

Modus operandi

Ordering

Promises can be simultaneous or given in a particular order. The ordering is defined below. repeat: Enable Garbage collection Resource Creation Resouce Modification until done Interfaces # enable communication Process_stop Signals # garbage kill etc Files: rename Tidy # garbage Create|Copy Permissions Edit Process_start (we don't say anything about how long it will last? - timeout) Mount (could depend on processes)

Relationships

A line/text item is a property of a file's state (present) A process is a property of an executable's state (running) A signal is sent to a PID - this is a raw resource A restart command is sent to a service name. This is a wrapping of a process/file association. bundle it. Restart should be a body body start name { start_command => ""; }
Mark Burgess
Last modified: Sat May 3 14:55:34 CEST 2008 cfengine-3.2.4/docs/Makefile.in0000644000175000017500000004026411715232775013234 00000000000000# Makefile.in generated by automake 1.11.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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@ target_triplet = @target@ @CROSS_COMPILING_FALSE@@HAVE_NOVA_TRUE@am__append_1 = cf-hub.8 subdir = docs DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \ $(top_srcdir)/m4/cf3_with_library.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)/src/conf.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 = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } man8dir = $(mandir)/man8 am__installdirs = "$(DESTDIR)$(man8dir)" NROFF = nroff MANS = $(man_MANS) 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@ BERKELEYDB_CFLAGS = @BERKELEYDB_CFLAGS@ BERKELEYDB_LDFLAGS = @BERKELEYDB_LDFLAGS@ BERKELEYDB_LIBS = @BERKELEYDB_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EIGHTBIT = @EIGHTBIT@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GCC_CFLAG = @GCC_CFLAG@ GETCONF = @GETCONF@ GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ GREP = @GREP@ HOSTNAME = @HOSTNAME@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ KMEM_GROUP = @KMEM_GROUP@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_SELINUX = @LIB_SELINUX@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MYSQL_CFLAGS = @MYSQL_CFLAGS@ MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@ MYSQL_LDFLAGS = @MYSQL_LDFLAGS@ MYSQL_LIBS = @MYSQL_LIBS@ MYSQL_PATH = @MYSQL_PATH@ NEED_SETGID = @NEED_SETGID@ NM = @NM@ NMEDIT = @NMEDIT@ NOWRAP = @NOWRAP@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_CPPFLAGS = @OPENSSL_CPPFLAGS@ OPENSSL_LDFLAGS = @OPENSSL_LDFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OPENSSL_PATH = @OPENSSL_PATH@ 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@ PCRE_CFLAGS = @PCRE_CFLAGS@ PCRE_CPPFLAGS = @PCRE_CPPFLAGS@ PCRE_LDFLAGS = @PCRE_LDFLAGS@ PCRE_LIBS = @PCRE_LIBS@ PCRE_PATH = @PCRE_PATH@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_CPPFLAGS = @POSTGRESQL_CPPFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_LIBS = @POSTGRESQL_LIBS@ POSTGRESQL_PATH = @POSTGRESQL_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ TOKYOCABINET_CFLAGS = @TOKYOCABINET_CFLAGS@ TOKYOCABINET_CPPFLAGS = @TOKYOCABINET_CPPFLAGS@ TOKYOCABINET_LDFLAGS = @TOKYOCABINET_LDFLAGS@ TOKYOCABINET_LIBS = @TOKYOCABINET_LIBS@ TOKYOCABINET_PATH = @TOKYOCABINET_PATH@ 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_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ workdir = @workdir@ @CROSS_COMPILING_FALSE@man_MANS = cf-agent.8 cf-serverd.8 cf-execd.8 \ @CROSS_COMPILING_FALSE@ cf-monitord.8 cf-report.8 cf-know.8 \ @CROSS_COMPILING_FALSE@ cf-runagent.8 cf-promises.8 cf-key.8 \ @CROSS_COMPILING_FALSE@ $(am__append_1) # Make sure these get distributed with everything else. EXTRA_DIST = $(man_MANS) $(srcdir)/*.png $(srcdir)/*.html # # Some basic clean ups # MOSTLYCLEANFILES = *~ *.orig # # Get everything removed down to where rebuilding requires: # "make; make install" # CLEANFILES = $(man_MANS) # # Get everything removed down to where rebuilding requires: # "configure; make; make install" # DISTCLEANFILES = # # Get everything removed down to where rebuilding requires: # "aclocal; autoconf; autoheader; automake --add-missing" # "configure; make; make install" # MAINTAINERCLEANFILES = Makefile.in all: all-am .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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) --gnu docs/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu docs/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(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 install-man8: $(man_MANS) @$(NORMAL_INSTALL) test -z "$(man8dir)" || $(MKDIR_P) "$(DESTDIR)$(man8dir)" @list=''; test -n "$(man8dir)" || exit 0; \ { for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.8[a-z]*$$/p'; \ } | 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=''; test -n "$(man8dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.8[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man8dir)'; $(am__uninstall_files_from_dir) tags: TAGS TAGS: ctags: CTAGS CTAGS: 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 @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 $(MANS) installdirs: for dir in "$(DESTDIR)$(man8dir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) 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) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) 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 "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) 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-man 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-man8 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: uninstall-man uninstall-man: uninstall-man8 .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-man8 \ 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 uninstall-man uninstall-man8 %.8 : ../src/% $(MAKE) -C ../src $< ../src/$< -M > `echo $<.8 | sed s/src/docs/` # 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: cfengine-3.2.4/docs/cf-agent.80000644000175000017500000000443311715233353012733 00000000000000.TH cf-agent 8 "Maintenance Commands" .SH NAME cf-agent - cfengine's change agent .SH SYNOPSIS: cf-agent [options] .SH DESCRIPTION: The main Cfengine agent is the instigator of change in the system. In that sense it is the most important part of the Cfengine suite. .B cfengine is a self-healing configuration and change management based system. You can think of.B cfengine as a very high level language, much higher level than Perl or shell. Asingle statement is called a promise, and compliance can result in many hundreds of filesbeing created, or the permissions of many hundreds offiles being set. The idea of .B cfengine is to create a one or more sets of configuration files which willclassify and describe the setup of every host in a network. .SH COMMAND LINE OPTIONS: .IP "--bootstrap, -B" Bootstrap/repair a cfengine configuration from failsafe file in the WORKDIR else in current directory .IP "--bundlesequence, -b" value Set or override bundlesequence from command line .IP "--debug, -d" value Set debugging level 0,1,2 .IP "--define, -D" value Define a list of comma separated classes to be defined at the start of execution .IP "--diagnostic, -x" value Do internal diagnostic (developers only) level in optional argument .IP "--dry-run, -n" All talk and no action mode - make no changes, only inform of promises not kept .IP "--file, -f" value Specify an alternative input file than the default .IP "--help, -h" Print the help message .IP "--inform, -I" Print basic information about changes made to the system, i.e. promises repaired .IP "--negate, -N" value Define a list of comma separated classes to be undefined at the start of execution .IP "--no-lock, -K" Ignore locking constraints during execution (ifelapsed/expireafter) if "too soon" to run .IP "--policy-server, -s" value Define the server name or IP address of the a policy server (for use with bootstrap) .IP "--verbose, -v" Output verbose information about the behaviour of the agent .IP "--version, -V" Output the version of the software .SH AUTHOR Mark Burgess and CFEngine AS .SH INFORMATION Bug reports: http://bug.cfengine.com, .pp Community help: http://forum.cfengine.com .pp Community info: http://www.cfengine.com/pages/community .pp Support services: http://www.cfengine.com .pp This software is Copyright (C) 2008-2012 CFEngine AS. cfengine-3.2.4/docs/filelogic.html0000644000175000017500000001566411707771421014015 00000000000000 File handling in cfengine 3

File handling in cfengine 3

File handling in cfengine 3 is more integrated than in cfengine 3. This helps both the logic and the efficiency of implementation. File handling is now more powerful, and uses regular expressions everywhere for pattern matching. The old "wildcard" expressions * and ? are deprecated, and everything is based consistently on POSIX extended regular expressions.

There is a natural ordering in file processing that obviates the need for the actionsequence. The trick of using multiple actionsequence items with different classes, e.g.

 actionsequence = ( ... files.one  ..  files.two )
can now be handled more elegantly using bundles. The natural ordering uses that fact that some operations are mutually exclusive and that some operations do not make sense in reverse order. For example, editing a file and then copying onto it would be nonsense. Similarly, you cannot both remove a file and rename it.

File copying

One of the first things you will notice is that copying is now "backwards". Instead of the default object being source and the option being the destination, in cfengine 3 the destination is paramount and the source is an option. This is because the model fo voluntary cooperation tells us that it is the object that is changed which is the agent making the promise. One cannot force change onto a destination with cfengine, one can only invite change from a source.

Normal ordering

Delete-create (normal ordering) makes sense
Create-delete does not

The diagram below shows the ordering. Notice that the same ordering applies regardless of file type (plain-file or directory).

 for each file promise-object
    {
    if (depth_search) 

      do 
        DepthSearch (HandleLeaf)
      else 
        (HandleLeaf)
      done
    }

 HandleLeaf()
   {
   Does leaf-file exist?

     NO:  create
     YES: rename,delete,touch, 

     do
      for all servers in {localhost, @(servers)}
         {
         if (server-will-provide)
            do
              if (depth_search)
                 embedded source-depth-search (use file source)
                 break
              else
                 (use file source)
                 break
              done
            done
         }
     done
      
   Do all links (always local)

   Check Permissions

   Do edits
   }

Depth searches (recursion) and path matches

In cfengine 2 there was the concept of recursion during file searches. Recursion is now called "depth-search". In addition, in both cfengine 2 and 3 it was possible to specify wildcards in the base-path for this search. e.g.
 
      Cfengine 2               Cfengine 3

/one/*/two/thr*/four    /one/.*/two/thr.*/four
When we talk about a depth search it refers to a search which starts from the one or more matched base-paths.

Promise theory tells us that there are two distinct kinds of depth search:

  • A local search over promiser agents.
  • A remote search over provider agents.
It is the destination or resulting files that all promises in cfengine, not the source. That is due to voluntary cooperation, i.e. because we never push files, only pull.

When we are copying or linking to a source, it is the search over the remote source that drives the content of a promise. In general, the sources are on a different device to the images that make the promises. For all other promises, we search over existing local objects.

If we specify depth search together with copy of a directory, then the implied remote source search is assumed, and it is made after the search over local objects. Since this could lead to confusion a warning is issued. In general it is not recommended to mix searches without a full understanding of the consequences, but this might occasionally be useful, e.g. tidy and then copy. This would not be a convergent operation however.

Depth search is not allowed with editfiles promises.

File editing in cfengine 3

Cfengine 2 assumed that all files were line-edited, because it was based on Unix traditions. Since then many new file formats have emerged, including XML. Cfengine 3 opens up the possibiltiy for multiple models of file editing. Line based editing is still present and is both much simplified and much more powerful than previously.

File editing is not just a single kind of promise but a whole range of "promises within files". It is therefore not merely a body to a single promise but a bundle of sub-promises. After all, inside each file is a new world of objects that can make promises, quite separate from files' external attributes.

A typical file editing stanza has the elements in the following example.

######################################################################
#
# File editing
#
######################################################################


body common control

{
version => "1.2.3";
bundlesequence  => { "outerbundle"  };
}

########################################################

bundle agent outerbundle

{
files:

  "/home/mark/tmp/cf3_test"

       create    => "true",            # Like autocreate in cf2
       edit_line => inner_bundle;
}

########################################################

bundle edit_line inner_bundle
  {
  vars:

   "edit_variable" string => "private edit variable"; 
  
  replace_patterns:

   # replace shell comments with C comments

   "#(.*)"

      replace_with => C_comment,
     select_region => MySection("New section");

  }

########################################
# Bodies for the library ...
########################################

body replace_with C_comment

{
replace_value => "/* $(1) */"; # backreference 0
occurrences => "all";          # first, last all
}

########################################################

body select_region MySection(x)

{
select_start => "\[$(x)\]";
select_end => "\[.*\]";
}

There are several things to notice:
  • The line-editing promises are all convergent promises about patterns within the file. They have bodies, just like other attributes do and these allow us to make simple templates about file editing while extending the power of the basic primitives.
  • All pattern matching is through perl compatible regular expressions
  • Editing takes place within a marked region (which default to the whole file).
  • Search/replace functions now allow back-references
  • The line edit model now contains a column model for dealing with tabular files such as Unix passwd and group files. We can now apply powerful convergent editing operations to single fields inside a table, to append, order and delete items from lists inside fields.
In the example above, back references are used to allow conversion of comments from shell-style to C-style. cfengine-3.2.4/docs/cf-report.80000644000175000017500000000615111715233353013147 00000000000000.TH cf-report 8 "Maintenance Commands" .SH NAME cf-report - cfengine's reporting agent .SH SYNOPSIS: cf-report [options] .SH DESCRIPTION: The reporting agent is a merger between the older cfengine programs cfshow and cfenvgraph. It outputs data stored in cfengine's embedded databases in human readable form. .B cfengine is a self-healing configuration and change management based system. You can think of.B cfengine as a very high level language, much higher level than Perl or shell. Asingle statement is called a promise, and compliance can result in many hundreds of filesbeing created, or the permissions of many hundreds offiles being set. The idea of .B cfengine is to create a one or more sets of configuration files which willclassify and describe the setup of every host in a network. .SH COMMAND LINE OPTIONS: .IP "--help, -h" Print the help message .IP "--class-regex, -c" value Specify a class regular expression to search for .IP "--csv, -C" Enable CSV output mode in hub queries .IP "--debug, -d" value Set debugging level 0,1,2,3 .IP "--verbose, -v" Output verbose information about the behaviour of the agent .IP "--inform, -I" Output information about actions performed by the agent .IP "--version, -V" Output the version of the software .IP "--no-lock, -K" Ignore ifelapsed locks .IP "--file, -f" value Specify an alternative input file than the default .IP "--hostkey, -k" value Specify a hostkey to lookup .IP "--html, -H" Print output in HTML .IP "--xml, -X" Print output in XML .IP "--version, -V" Print version string for software .IP "--purge, -P" Purge data about peers not seen beyond the threshold horizon for assumed-dead .IP "--erasehistory, -E" value Erase historical data from the cf-monitord monitoring database .IP "--nova-export, -x" value Export Nova reports to file - delta or full report .IP "--nova-import, -i" value Import Nova reports from file - specify the path (only on Nova policy hub) .IP "--outputdir, -o" value Set output directory for printing graph data .IP "--promise-handle, -p" value Specify a promise-handle to look up .IP "--query-hub, -q" value Query hub database interactively with optional regex search string .IP "--titles, -t" Add title data to generated graph files .IP "--timestamps, -T" Add a time stamp to directory name for graph file data .IP "--resolution, -R" Print graph data in high resolution .IP "--show, -1" value Show data matching named criteria (software,variables,classes) .IP "--syntax, -S" Print a syntax summary for this cfengine version .IP "--syntax-export, -s" Export a syntax tree in Javascript format .IP "--no-error-bars, -e" Do not add error bars to the printed graphs .IP "--no-scaling, -n" Do not automatically scale the axes .IP "--verbose, -v" Generate verbose output .IP "--remove-hosts, -r" value Remove comma separated list of key hash entries from the hosts-seen database .SH AUTHOR Mark Burgess and CFEngine AS .SH INFORMATION Bug reports: http://bug.cfengine.com, .pp Community help: http://forum.cfengine.com .pp Community info: http://www.cfengine.com/pages/community .pp Support services: http://www.cfengine.com .pp This software is Copyright (C) 2008-2012 CFEngine AS. cfengine-3.2.4/docs/cf-key.80000644000175000017500000000267711715233353012435 00000000000000.TH cf-key 8 "Maintenance Commands" .SH NAME cf-key - cfengine's key generator .SH SYNOPSIS: cf-key [options] .SH DESCRIPTION: The cfengine's generator makes key pairs for remote authentication. .B cfengine is a self-healing configuration and change management based system. You can think of.B cfengine as a very high level language, much higher level than Perl or shell. Asingle statement is called a promise, and compliance can result in many hundreds of filesbeing created, or the permissions of many hundreds offiles being set. The idea of .B cfengine is to create a one or more sets of configuration files which willclassify and describe the setup of every host in a network. .SH COMMAND LINE OPTIONS: .IP "--help, -h" Print the help message .IP "--debug, -d" value Set debugging level 0,1,2,3 .IP "--verbose, -v" Output verbose information about the behaviour of the agent .IP "--version, -V" Output the version of the software .IP "--output-file, -f" value Specify an alternative output file than the default (localhost) .IP "--show-hosts, -s" Show lastseen hostnames and IP addresses .IP "--remove-keys, -r" value Remove keys for specified hostname/IP .SH AUTHOR Mark Burgess and CFEngine AS .SH INFORMATION Bug reports: http://bug.cfengine.com, .pp Community help: http://forum.cfengine.com .pp Community info: http://www.cfengine.com/pages/community .pp Support services: http://www.cfengine.com .pp This software is Copyright (C) 2008-2012 CFEngine AS. cfengine-3.2.4/docs/cf-execd.80000644000175000017500000000453311715233353012726 00000000000000.TH cf-execd 8 "Maintenance Commands" .SH NAME cf-execd - cfengine's execution agent .SH SYNOPSIS: cf-execd [options] .SH DESCRIPTION: The executor daemon is a scheduler and wrapper for execution of cf-agent. It collects the output of the agent and can email it to a specified address. It can splay the start time of executions across the network and work as a class-based clock for scheduling. .B cfengine is a self-healing configuration and change management based system. You can think of.B cfengine as a very high level language, much higher level than Perl or shell. Asingle statement is called a promise, and compliance can result in many hundreds of filesbeing created, or the permissions of many hundreds offiles being set. The idea of .B cfengine is to create a one or more sets of configuration files which willclassify and describe the setup of every host in a network. .SH COMMAND LINE OPTIONS: .IP "--help, -h" Print the help message .IP "--debug, -d" value Set debugging level 0,1,2,3 .IP "--verbose, -v" Output verbose information about the behaviour of the agent .IP "--dry-run, -n" All talk and no action mode - make no changes, only inform of promises not kept .IP "--version, -V" Output the version of the software .IP "--file, -f" value Specify an alternative input file than the default .IP "--define, -D" value Define a list of comma separated classes to be defined at the start of execution .IP "--negate, -N" value Define a list of comma separated classes to be undefined at the start of execution .IP "--no-lock, -K" Ignore locking constraints during execution (ifelapsed/expireafter) if "too soon" to run .IP "--inform, -I" Print basic information about changes made to the system, i.e. promises repaired .IP "--diagnostic, -x" Activate internal diagnostics (developers only) .IP "--no-fork, -F" Run as a foreground processes (do not fork) .IP "--no-winsrv, -W" Do not run as a service on windows - use this when running from a command shell (Cfengine Nova only) .IP "--ld-library-path, -L" value Set the internal value of LD_LIBRARY_PATH for child processes .SH AUTHOR Mark Burgess and CFEngine AS .SH INFORMATION Bug reports: http://bug.cfengine.com, .pp Community help: http://forum.cfengine.com .pp Community info: http://www.cfengine.com/pages/community .pp Support services: http://www.cfengine.com .pp This software is Copyright (C) 2008-2012 CFEngine AS. cfengine-3.2.4/docs/filelogic.png0000644000175000017500000003370011707771421013624 00000000000000PNG  IHDR[[ pHYs M MέNtEXtSoftwareESP Ghostscript 8.15 ޜ IDATxa֫*ФOfRwl5t"D={DOO^z>Oi,C$ @ (1DC$ @ (1Y}sysϿhpoKpcn=}U<T>4R8ռ%jnpy2;@ (1DC$ @ (1DC$ @o,?w|S2U$Z𜙂&v>,f_(g1SQn\>bGuPx[v;SPa.ց3 4& @WDC$ @ (1DC$ @ (1Dĸկ}s?S1|{š˵2cC$ @ DږSTM+3& @ (1DC$ @ (1DC$ @ (1D@z>.u=s!S̸r3"~=oxEUY|p)Tx@>O|"`-l_enipڬ ygs͓)m:VhPeo-TH)*rk9F);3-C: *wy氪m6\kzUW˚]`5g^jP})jm)<5ӽH[ë5xFZm/s= 'P%ՠ6D5!GB~wiQҫ mw6|jZS,@_jt'w3a!NZkD@.[V5.Zv}9stۚ^sӚ‰Dt{q"inxmQ"9u0& dVru!d^pڲ0](^A喫TvD AX4*m52fd簹3;N4wW[#ߵ݆?xD>7›o_?XAcsX`<萑y;٦ 3DFS,9(scI$ } VN8Ʈ!Qm_+ Drͻf_i55<PkB}m6|x[n琸sx,(<Ȯ< 6)vU "hC$ @ (1DC$ @ (1Dh}lbjelh)cC$ @u f478O{$ 0Np*͍Jf! H"QbD! H"Qbl?o,or oLE C-*z5;O$:~sM/~ 2Q(@껅ΞAp63; 0韹Os[*2=nObLt@c̊ma@t,pn!jq.u+wmWq`!zg=[{7+%][{׭LjװǸ¸ܻ6H$:y/sH_]@t r`hfǔf;c-˽[e%,E-pn!Dν{߃DTps a|wi<hViwʿ [x 3DT={lg5 S-t r`E9|w~4\ݶO-[( w+,pI`L`qYw&k;1Qb0&~Yk8~tz#z^O2 ~o66մ){+2E\+-ՠACs9fmvη}R|0xXޙohjߝh@Au8zާ{ ftĮ_m{[ʮÛyv1; TX"gWEFhh\u>02P< M ,-O3}zt,Jm&Lr皡6dzߟgP@vz1 +?3$ffRxjL$nuմMz;2绫mSCAHz }fבh!1C2iW3iOJ5kԎ! $aS3X3-kpc'L'׊:5]?=~L.F6?cE.'vg[ 'oq@9C/Df3Q5Y3r5\:9kn|L _MO9FwiWu3ۦᆲp-C ~}Qj鹵Z*97gyi/i&5ϛ`ϜgZ}kռ;zao ]yo!r2{7/#' _mwJ]OZC8I>[oxzm06_xm;K~Y`so[=Gu#r.wʞOa;OMz7Oή{ `!:}oj7^n޻v]l: {P6` տD{g I]x ͽZ1֮{{˒Ͳvb=3& Ћt,'{7y;޳9<߲|')n޻[d7itRKM$ ux1h>.S3^y7@`U˱c6=Qv]}+;pҴWݼ`!،6vm޽ ]?׻.|]>3;:YF`fpOKA15{<[J/Z:;\#67N#ݽwdL њҷJߚoZqV8ͣjLߪٸ6)z =pg̒bʲ\<0ORQq,דX~)fٚ<e0%[p"Q,Hz20 coݦ? 'Zise9VX,^/t+ѻI{n=}|wn>q3y{,g#&ص8yҋS>49DǕzifWEGG?_z6"kʣWNEG+ 3-x81sOi2Jgs.fooDsl'<.(X>{ܗ#)ZYVWn1IV7=3[ct>/k6~׷َx7n4)܂K'nn&}cE3fe9\t[bCER7qQS<B;u[hut6Bw> ػVIbkN6nvy;j4\fAT jVH}SnlʓM&=jlsC.jtiwG^m6}Mvׇ\kf͘ix S]^pѱqdž"Q,`Qy}t-͸vt_|c k!< L*>dgBslLZ6?F0Ǟ mһ0>:Q0_ZNkUZI;(Īr˚ks6R]UG>QzWhR0a^։dS¹gv=jyFԓOagxsF(S¹'冾KYBj|%喦e ez }HD# .C"'\iu9ru [LDD؃"D-ڠ|7wc-Ԙ(dFkauױ`I/D!uQ4HÅ_BÎcOU}`r''>|DC̿!T@6?W~9~t8yڻ v|b $ȺYr/zk[9ΗEЅܚա߿D ̿6bYMV^P·%[ 웛(l3Nb(`ʱiQ]݂q}ֶ滯"T(B [_LI}@J"=g-Wߝ/+u,ױw.S<ӵzv~P=N5߁;{r։\S¹''(0& sL S$ @ (1|eL'3-x8(@g$@=D1Q`J8D(<#N% 9<ncX촫ͽzCG?@|>Wgwm liS]=4当ʻ9k\o!x8;)GwGΟW(=o+U_Df! H"QbD! ,Np[i6p9(V}R-IyжRiC H"QbDKY|Sd=[ _a?I;~K+;H`S~}{Hib3;0?Ӂib!03f{}>(Jwc&v*Ռss(L__򻯵<9}["7kw{K+;K.}tM]͢{:ii[@ﴲDpz\iRr4 O13uݚ:IՍVJ$گ)@VEŦ G㗱J"~Gs P*ՈQunl$fq_QF(J։ʷ־Fkfem{ ]7O{=D޲'pߛsw<4z嘝Vej.560/[og鿪_~o&@$z2 *kT[P=N S_r#״+KEnib/lh/|Aps]{ػs]bkeDzNRUG[sDfK$?ybD! up[):Ϙ-Us׷9Hn+MC=z\)HT}C H"QbD! H8XqOǃLg롕ibhlKgK;3`5N`K$oV+k!>>=uoӸyRiŭLu0&z'i!HEW^RcOcsx*k)UQs |]/W'5 |⫳ c՜F9/v8)NE)lfߟbn`LpVpO o]vnLqƁ`N+;@b)L[QE]k(uف(i%wWVcieDW8 k=f  o]vJW&5ÆRh*u*UREƽk_ZY'|c`+bip6VfLx돵4~9+^%Nieݶ2j@[{_YXvzD,{++ IVx 9C$ @ (1|c n+MSҖ| 7 yIDATej.迪_~Hn>=uo$j=uo$jm"Ƕ·7("f! H"QbD! Hmx{lFeQrvۼԩ-q[^KE"Q4 uJ UsREly.@8 I$ @ (1DC$ @ (1Js2Cd꿪v~):/[O+۪OO=nFiCVsJ~KqR-bv"QbD! H"QbD!(V}fT*gJ;TT,JP!P(=*o+U_R TlDC$ @ (1DC>Q4-3$K&Jzo9h痢R"QfTٻ[8jk1 ')w#::YV\kV6#:o盌n(w!ҦUZ-u2zwa,5hLD7||*| Z|iNгQ:Uhp,FmB>Ufu)iOi}J]v ~Tsu2w~vz͉]m-Lrr$>%UGxMooj(uفRBNf~A"ǶAulq*,]^u2b<49sZkrû:ɣDǓ[g fNQ侮VN %&i]^vT=XO-Cv2nD'C?oVvSLǹsfߏQͽJPs,=w2d; .<0a\њL5;\,nvkFceH[9;%gen X=▣B]Y \I$ U/9ťW6w+޽5mY~WHn>=uo! xN"p7KrkuC$ @ (1DC$ @ Dsu1[P7y:)ujKܕmr'JE"Q4 uJ UsREly.@8 I$ @ (1DC$ @ (1Js2Cd꿪v~):/[O+۪OO=nFiCVsJ~KqR-bv"QbD! H"QbD!(V}fT*gJ;TT,JP!P(=*o+U_R TlDC$ @ (1DC>Q4-3$K&Jzo9h痢R"QfTٻ[8jYybD! H"QI;2TIENDB`PNG  IHDR[[ pHYs M MέNtEXtSoftwareESP Ghostscript 8.15 ޜ MIDATx1 0$ zvN( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( ' @Ép4( gtIENDB`cfengine-3.2.4/docs/CollectingDefinitions.html0000644000175000017500000000141111707771421016320 00000000000000 Collecting Definitions

Collecting Definitions

To make global definitions that can be used in all of your cfengine components, use a bundle that is typed "common". Note that classes are always global, but variables have scope. Use a simple scope label like "G" for global to keep the references short:
bundle common G
{
vars:

  "myvariable" string => "Refer to me as \$(G.myvariable)";

classes:


}


Mark Burgess
Last modified: Thu May 1 13:38:16 CEST 2008 cfengine-3.2.4/docs/add_modules.html0000644000175000017500000000342611715232733014326 00000000000000 Adding Modules to cfengine 3

Adding Modules to cfengine 3

Cfengine 3 is designed to be highly modular and uniform in syntax. To add a new functionality, you Plan a model based on promises What are the promises you want to make? What promise types will you need? file: newtype: What attributes (lvalues) will the promise body have? What datatypes will the attributes have? Then you start in src/mod_common.c
/*********************************************************/
/* THIS IS WHERE TO ATTACH SYNTAX MODULES                */
/*********************************************************/

/* Read in all parsable Bundle definitions */

struct SubTypeSyntax *CF_ALL_SUBTYPES[CF3_MODULES] =
   {
   CF_COMMON_SUBTYPES, /* Add modules after this */
   CF_FILES_SUBTYPES,  /* mod_files.c */
   CF_EXEC_SUBTYPES,   /* mod_exec.c */
   CF_PROCESS_SUBTYPES,/* mod_process.c */
   
   /* update CF3_MODULES in cf3.defs.h */
   };

Remember to increase the constant CF3_MODULES when you increase the size of this. Add a reference to the new module here. Take an existing module, e.g. mod_exec.c and copy it to your new module. Rename the parts consistently with the module name and edit this to add the required promises with attributes. Don't forget the preprocessor labels CF3_MOD_NEW You will have to add the mod_new.c file to Makefile.am Add a section to cf3.extern.h to declare the new variables, following the pattern there.
Mark Burgess
Last modified: Fri Jan 4 15:55:46 CET 2008 cfengine-3.2.4/docs/list_expand.png0000644000175000017500000002477011707771422014211 00000000000000PNG  IHDRcx pHYs M MέNtEXtSoftwareESP Ghostscript 8.15 ޜyIDATxY֣:P8 U\FF{?J >BaxUӋ[ lFD"i n\P5SpݩCaX-4B4Ёr (šBE Xuvjoz,`JwiƅwѬ.N{T \N^Njwz w|DŽӺh3 hN#?0KWMtV{B=Ն|'qDJMڡ!D̆ǙLxV*-0^ s АLbNӐNKT’dڄ'R!D F n2@ x!Hw Dw DB)q DB)q DBW}|%OCr CEw]:c RaHSdx>q DB)q DB)q DB)q DB)q DB)q DB)q DB)q DB)q DB)?oop m[kxksNwekހQw Z6 fuWn^})) ӣ4vtć7s%]̯ZŶ66НO-РY*qwX}Dw x\kyj$ZvL7WdUpdRVp'hu*zf&I,^*GUL+_R%N(-:J8j4t[]RK([ËOoF%Bw-gcxM2Gέv72gJ}8x0@v?G/ՌETi5~7%غuwj (8uVhvxqk^gQl4b@tf:4Fz4`ߣfC{@tΘFci[S_g:-(8unI/zrzc2"NS!@8"NS!@5_S0@z&  a DB)q DB)q DB)q DB)q DB)q DB)q DB)q DB)q DpaxkK&)204bݢ-~;t $NUfYUl8AҴ\P^m@8Dɯ< Xp><_V̭ ZoT^x"8Ұ:"XeVy\u NffOnJ;Ύ5W'I.0sy:.X("KGkʯ& lewm*)>[ny\8; \.\jMN]౏=:qrYޝ3tw&Db1 kdNS Ů[6s3Ǟ4hEN0WZ@]}6')2p5rT(SP)8xS!ԍDPm]@8uG3T(8"N# ^'NSWrH=gS!@8"NS!@K>_`Jף3;uO~xf9}O/߭ĩ+9i[?i<\~v9׎ JxYfD.#Q%NݢqᖘP19MQԣeI^ZT Ir:ẌSXJWPqiU6 'Kp6!ԕ }hB)q DB)q DB)q DB)q DB)q DB)q DB)q DB)q DB)q D@JӋ0L,|Vf%QF8M6zPH|>ޑ>:.BU >%tٕD4q׌ek趏8f åX=Z]?O hLt* S:x&)#BwY+b%=*PH NqM%Jw0eSoz\8=!:ewS~KVO33r6CIDxZrm n]O?ZD 3DNI,|38Lݙ}Yꃪp>SUI>Bw[6M>Hw* S!WGMJ$NOqq D*(uS\L~k)(E8@ 8J )'E)GX%NSEWۛ@ X.[ NJӴpCvO1"NS!@8"NS!@8Ŏ7ѽ-v@VcP(8Gf!맷~b9ݽuwka?gw]Z,ݥ}q#,zj~hm5|d񀇋F"X(vR;)3eAz3=f6z`w<.Z,,)R`WO/7%dip%©E⿶ ˙^Ka̮غukY j,9ѣH}qζ;͜57Vv\S/GBAt-Z6ϚZ[İukv+_/,ѐKZ{yQ{J7;ZqPt7 GjU[{NS]. U4;̻.U4vyu>Ewi5TV@F,7iu=[-wN֣,822kZ,7~֤M[fj (n\ݙiܭƎ['sv|1"LN]wڭ͘-9{3Kۊ  Oueq֝z':4| 'Vhr]нjK<<3JSy mOӛw?]+ݚDb$G2 v5wu.`FBZmU_ %5q"6NQH]~U(z/ mC$yv~a9|sd (mْNW|6Px9-g,^OTĽK.;RC '9AN%Jd=ġ;Nڳ|{?5&2י2 'dm\492-+if?5wb\iw<E\[.?[rwy:})+=ٌuήYnJfssrVl*7Q;,1uӂۘ&凤`?[+.ˋ}$=x5CјZ8duog*%VRSn̐gYh5|%,Eڋ!KRNE a:fopnFiStpeMڋ!V(ܟn>㇞Ԋ /vg-iLcO;n+9$wKΨ_0&r|I9yuI7p8<^rju,Hz?M\N?߈ۺۃл_斛TΫv'-݆ٺ5^dkÞuf'd,y|)2̉,\J yJyoU{TY[CgY|J?2scj=۸]]^x'Lz.t8]zs*7ev?ڰ> O 2$MJwOܷUG:SiGD˃ȜИ?c1rt,m0C[N=vN]|ѓL+df.}]' ,Si'T3px68tݩ68׹?m*q ˉx$Q'NsP|887J &_Y"qЏ~;(@ĩQH`T*4GCGV~ϋr+pߡ{x.@ V*%q 8Fޖ\E) |pҘg4Iw 8Q-(S HTS5$*)2MpJ NITS-$*;).pCJ*%NS>xES$aM`]~Ss$ ahTE2TD&*h6U-r3 )/8E#IT@)!Q(- Fĵ2Wxq q,>vo%Q!NNtK}@ALgj$NeS@q$*.@8H 8ʉ~@-)hzT@)PZS@-)h&QM[SP8q (a>.P *dP֔DK b8,A)Mw x١,AH^3$Q1 mG]~ *i (8 @Ѡ^^ܫHT^}?"^O17Jr-5[)x==@MB)O"{\.$NJ4n+MbB? BTőD)J4vg i][h3UˉShy옳ءY p9}|Aw DMq DM}@;t^!NS!@8"N0x8"Nϲ58H"q vWgI t*f@U48 2͎x8"NӚJ NBS!P%)PY (8"NњJ#N5S@5d)L@8Ak (8T@J +}?pd)pS@d)|Ͳn,TA5xv bxqS@q4"Khqd)6}yq8EkJ}/K2w x TM*"x2 >TYT%AS H8@S h8 j藓 (@K),0uZPb[AJh8E5% S677)O +tBt@✸MVo]~UAs(8E2P@[Nj4^_!1G˖hLQŀJ};EV&N8m'>Z6;NQi$?e.3ta9YDe+)ꙏ)q p,`nfs0AS,`B)0O>YNЂ)8@ r>q DB)q DB)q DB)q DB)?ooM 2 ۛf D1P1."p,HIENDB`PNG  IHDRcx pHYs M MέNtEXtSoftwareESP Ghostscript 8.15 ޜ IDATx w>v dOg|oN$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$v SH@b;)N$\RIENDB`cfengine-3.2.4/missing0000755000175000017500000002623311715232774011635 00000000000000#! /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: cfengine-3.2.4/masterfiles/0000755000175000017500000000000011715233356012623 500000000000000cfengine-3.2.4/masterfiles/promises.cf0000644000175000017500000001524511715232734014724 00000000000000############################################################################### # # promises.cf - Basic Policy for Community # ############################################################################### body common control { bundlesequence => { "main" }; inputs => { "cfengine_stdlib.cf", }; version => "Community Promises.cf 1.0.0"; } ############################################################################### bundle agent main { reports: cfengine_3:: "--> CFE is running on $(sys.fqhost)" comment => "Display message on screen/email", handle => "main_reports_cfe_running"; } ############################################################################### # # common def # - common/global variables and classes here # ############################################################################### bundle common def { vars: # Begin change # Your domain name, for use in access control "domain" string => "example.com", comment => "Define a global domain for all hosts", handle => "common_def_vars_domain"; # List here the IP masks that we grant access to on the server "acl" slist => { "$(sys.policy_hub)/16" # Assume /16 LAN clients to start with # "2001:700:700:3.*", # "217.77.34.18", # "217.77.34.19", }, comment => "Define an acl for the machines to be granted accesses", handle => "common_def_vars_acl"; # End change # "dir_masterfiles" string => translatepath("$(sys.workdir)/masterfiles"), comment => "Define masterfiles path", handle => "common_def_vars_dir_masterfiles"; } ############################################################################### # This part is for cf-agent # # Settings describing the details of the fixed behavioural promises made by # cf-agent. ############################################################################### body agent control { # Global default for time that must elapse before promise will be rechecked. # Don't keep any promises. any:: # This should normally be set to an interval like 1-5 mins # We set it to zero initially to avoid confusion. ifelapsed => "0"; # Do not send IP/name during server connection if address resolution is broken. # Comment it out if you do NOT have a problem with DNS skipidentify => "true"; # Environment variables based on Distro debian:: environment => { "DEBIAN_FRONTEND=noninteractive", }; } ############################################################################### # This part is for cf-serverd # # Server controls are mainly about determining access policy for the connection # protocol: i.e. access to the server itself. # Access to specific files must be granted in addition. ############################################################################### body server control { denybadclocks => "false"; allowconnects => { "127.0.0.1" , "::1", @(def.acl) }; allowallconnects => { "127.0.0.1" , "::1", @(def.acl) }; trustkeysfrom => { "127.0.0.1" , "::1", @(def.acl) }; skipverify => { ".*$(def.domain)", "127.0.0.1" , "::1", @(def.acl) }; allowusers => { "root" }; # Uncomment the line below to allow remote users to run # cf-agent through cf-runagent # cfruncommand => "$(sys.cf_agent)"; } ############################################################################### bundle server access_rules() { access: any:: "$(def.dir_masterfiles)" handle => "server_access_grant_access_policy", comment => "Grant access to the policy updates", admit => { ".*$(def.domain)", @(def.acl) }; # Uncomment the promise below to allow cf-runagent to # access cf-agent on Windows machines # # "c:\program files\cfengine\bin\cf-agent.exe" # # handle => "grant_access_policy_agent", # comment => "Grant access to the agent (for cf-runagent)", # admit => { ".*$(def.domain)", @(def.acl) }; roles: # Use roles to allow specific remote cf-runagent users to # define certain soft-classes when running cf-agent on this host # "emergency" authorize => { "root" }; } ############################################################################### # This part is for cf-execd # # These body settings determine the behaviour of cf-execd, including scheduling # times and output capture to $(sys.workdir)/outputs and relay via email. ############################################################################### body executor control { any:: splaytime => "1"; mailto => "cfengine@$(def.domain)"; mailfrom => "cfengine@$(sys.host).$(def.domain)"; smtpserver => "localhost"; # Default: # # schedule => { "Min00", "Min05", "Min10", "Min15", "Min20", # "Min25", "Min30", "Min35", "Min40", "Min45", # "Min50", "Min55" }; # The full path and command to the executable run by default (overriding builtin). # cf-twin needs its own safe environment because of the update mechanism linux:: exec_command => "$(sys.cf_twin) -f failsafe.cf && $(sys.cf_agent)"; } ############################################################################### # This part is for cf-report # # Determines a list of reports to write into the build directory. # The format may be in text, html or xml format. ############################################################################### body reporter control { any:: reports => { "all" }; build_directory => "$(sys.workdir)/reports"; report_output => "html"; style_sheet => "/cf_enterprise.css"; } ############################################################################### # This part is for cf-runagent # # The most important parameter here is the list of hosts that the agent will # poll for connections. ############################################################################### body runagent control { # A list of hosts to contact when using cf-runagent any:: hosts => { "127.0.0.1" }; # , "myhost.example.com:5308", ... } ############################################################################### # This part is for cf-monitord # # The system defaults will be sufficient for most users. # This configurability potential, however, will be a key to developing # the integrated monitoring capabilities of CFE. ############################################################################### body monitor control { any:: forgetrate => "0.7"; histograms => "true"; # tcpdump => "false"; # tcpdumpcommand => "/usr/sbin/tcpdump -t -n -v"; } ############################################################################### cfengine-3.2.4/masterfiles/Makefile.am0000644000175000017500000000113111715232734014572 00000000000000masterfilesdir = $(pkgdatadir)/masterfiles dist_masterfiles_DATA = $(srcdir)/failsafe.cf $(srcdir)/cfengine_stdlib.cf $(srcdir)/promises.cf # # Some basic clean ups # MOSTLYCLEANFILES = *~ # # Get everything removed down to where rebuilding requires: # "make; make install" # CLEANFILES = # # Get everything removed down to where rebuilding requires: # "configure; make; make install" # DISTCLEANFILES = # # Get everything removed down to where rebuilding requires: # "aclocal; autoconf; autoheader; automake --add-missing" # "configure; make; make install" # MAINTAINERCLEANFILES = Makefile.in cfengine-3.2.4/masterfiles/failsafe.cf0000644000175000017500000001573611715232734014642 00000000000000############################################################################### # # failsafe.cf - Basic Failsafe Policy for Community # ############################################################################### body common control { bundlesequence => { "update" }; version => "Community Failsafe.cf 1.0.0"; } ############################################################################# body agent control { ifelapsed => "0"; skipidentify => "true"; } ############################################################################# bundle agent update { vars: "inputs_dir" string => translatepath("$(sys.workdir)/inputs"), comment => "Directory containing Cfengine policies", handle => "update_vars_inputs_dir"; "ppkeys_file" string => translatepath("$(sys.workdir)/ppkeys/localhost.pub"), comment => "Path to public key file", handle => "update_vars_ppkeys_file"; "file_check" string => translatepath("$(inputs_dir)/promises.cf"), comment => "Path to a policy file", handle => "update_vars_file_check"; "master_location" string => "/var/cfengine/masterfiles", comment => "The master cfengine policy directory on the policy host", handle => "update_vars_master_location"; # classes: "have_ppkeys" expression => fileexists("$(ppkeys_file)"), comment => "Check for /var/cfengine/ppkeys/localhost.pub", handle => "update_classes_have_ppkeys"; "files_ok" expression => fileexists("$(file_check)"), comment => "Check for /var/cfengine/masterfiles/promises.cf", handle => "update_classes_files_ok"; # processes: files_ok:: "cf-serverd" restart_class => "start_server", comment => "Monitor cf-serverd process", handle => "update_processes_cf_serverd"; "cf-monitord" restart_class => "start_monitor", comment => "Monitor cf-monitord process", handle => "update_processes_cf_monitord"; files_ok.!windows:: "cf-execd" restart_class => "start_exec", comment => "Monitor cf-execd process", handle => "update_processes_cf_execd"; # commands: start_server:: "$(sys.cf_serverd)" comment => "Start cf-serverd process", handle => "update_commands_start_cf_serverd"; start_monitor:: "$(sys.cf_monitord)" comment => "Start cf-monitord process", handle => "update_commands_start_cf_monitord"; !windows.start_exec:: "$(sys.cf_execd)" comment => "Start cf-execd process", handle => "update_commands_start_cf_execd_not_windows"; !have_ppkeys:: "$(sys.cf_key)", comment => "Generate cfengine encryption keys if necessary", handle => "update_commands_generate_keys"; # files: !am_policy_hub:: # policy hub should not alter inputs/ uneccessary "$(inputs_dir)/cf_promises_validated" comment => "Check whether a validation stamp is available for a new policy update to reduce the distributed load", handle => "check_valid_update", copy_from => u_dcp("$(master_location)/cf_promises_validated","$(sys.policy_hub)"), action => u_immediate, classes => u_if_repaired("validated_updates_ready"); am_policy_hub|validated_updates_ready:: # policy hub should always put masterfiles in inputs in order to check new policy "$(inputs_dir)" comment => "Copy policy updates from master source on policy server if a new validation was acquired", handle => "update_files_inputs_dir", copy_from => u_rcp("$(master_location)","$(sys.policy_hub)"), depth_search => u_recurse("inf"), file_select => u_input_files, depends_on => { "grant_access_policy", "check_valid_update" }, action => u_immediate, classes => u_if_repaired("update_report"); !windows:: "$(sys.workdir)/bin" comment => "Make sure cfengine binaries have right file permissions", handle => "update_files_sys_workdir_bin", perms => u_m("755"), depth_search => u_recurse_basedir("inf"), action => u_immediate; "$(sys.workdir)/lib" comment => "Make sure cfengine libraries have right file permissions", handle => "update_files_sys_workdir_lib", perms => u_m("644"), depth_search => u_recurse_basedir("inf"), action => u_immediate; "/usr/local/sbin" comment => "Ensure cfengine binaries were copied to /usr/local/sbin", handle => "update_files_usr_local_sbin", perms => u_m("755"), copy_from => u_cp_nobck("$(sys.workdir)/bin"), file_select => u_cf3_files, depth_search => u_recurse("1"), action => u_immediate; am_policy_hub:: "$(master_location)/." comment => "Make sure masterfiles folder has right file permissions", handle => "update_files_sys_workdir_masterfiles", perms => u_m("644"), depth_search => u_recurse_basedir("inf"), action => u_immediate; } ######################################################### # Self-contained bodies from the lib to avoid dependencies ######################################################### body perms u_m(p) { mode => "$(p)"; } ######################################################### body file_select u_cf3_files { leaf_name => { "cf-.*" }; file_result => "leaf_name"; } ######################################################### body file_select u_input_files { leaf_name => { ".*.cf",".*.dat",".*.txt" }; file_result => "leaf_name"; } ######################################################### body copy_from u_rcp(from,server) { source => "$(from)"; compare => "digest"; trustkey => "true"; !am_policy_hub:: servers => { "$(server)" }; } ######################################################### body copy_from u_dcp(from,server) { source => "$(from)"; compare => "mtime"; trustkey => "true"; !am_policy_hub:: servers => { "$(server)" }; } ######################################################### body copy_from u_cp_nobck(from) { source => "$(from)"; compare => "digest"; copy_backup => "false"; } ######################################################### body action u_immediate { ifelapsed => "0"; } ######################################################### body depth_search u_recurse(d) { depth => "$(d)"; exclude_dirs => { "\.svn" }; } ######################################################### body depth_search u_recurse_basedir(d) { include_basedir => "true"; depth => "$(d)"; exclude_dirs => { "\.svn" }; } ######################################################### body classes u_if_repaired(x) { promise_repaired => { "$(x)" }; } ######################################################### cfengine-3.2.4/masterfiles/Makefile.in0000644000175000017500000003475711715232775014634 00000000000000# Makefile.in generated by automake 1.11.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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@ target_triplet = @target@ subdir = masterfiles DIST_COMMON = $(dist_masterfiles_DATA) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \ $(top_srcdir)/m4/cf3_with_library.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)/src/conf.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 = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(masterfilesdir)" DATA = $(dist_masterfiles_DATA) 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@ BERKELEYDB_CFLAGS = @BERKELEYDB_CFLAGS@ BERKELEYDB_LDFLAGS = @BERKELEYDB_LDFLAGS@ BERKELEYDB_LIBS = @BERKELEYDB_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EIGHTBIT = @EIGHTBIT@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GCC_CFLAG = @GCC_CFLAG@ GETCONF = @GETCONF@ GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ GREP = @GREP@ HOSTNAME = @HOSTNAME@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ KMEM_GROUP = @KMEM_GROUP@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_SELINUX = @LIB_SELINUX@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MYSQL_CFLAGS = @MYSQL_CFLAGS@ MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@ MYSQL_LDFLAGS = @MYSQL_LDFLAGS@ MYSQL_LIBS = @MYSQL_LIBS@ MYSQL_PATH = @MYSQL_PATH@ NEED_SETGID = @NEED_SETGID@ NM = @NM@ NMEDIT = @NMEDIT@ NOWRAP = @NOWRAP@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_CPPFLAGS = @OPENSSL_CPPFLAGS@ OPENSSL_LDFLAGS = @OPENSSL_LDFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OPENSSL_PATH = @OPENSSL_PATH@ 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@ PCRE_CFLAGS = @PCRE_CFLAGS@ PCRE_CPPFLAGS = @PCRE_CPPFLAGS@ PCRE_LDFLAGS = @PCRE_LDFLAGS@ PCRE_LIBS = @PCRE_LIBS@ PCRE_PATH = @PCRE_PATH@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_CPPFLAGS = @POSTGRESQL_CPPFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_LIBS = @POSTGRESQL_LIBS@ POSTGRESQL_PATH = @POSTGRESQL_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ TOKYOCABINET_CFLAGS = @TOKYOCABINET_CFLAGS@ TOKYOCABINET_CPPFLAGS = @TOKYOCABINET_CPPFLAGS@ TOKYOCABINET_LDFLAGS = @TOKYOCABINET_LDFLAGS@ TOKYOCABINET_LIBS = @TOKYOCABINET_LIBS@ TOKYOCABINET_PATH = @TOKYOCABINET_PATH@ 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_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ workdir = @workdir@ masterfilesdir = $(pkgdatadir)/masterfiles dist_masterfiles_DATA = $(srcdir)/failsafe.cf $(srcdir)/cfengine_stdlib.cf $(srcdir)/promises.cf # # Some basic clean ups # MOSTLYCLEANFILES = *~ # # Get everything removed down to where rebuilding requires: # "make; make install" # CLEANFILES = # # Get everything removed down to where rebuilding requires: # "configure; make; make install" # DISTCLEANFILES = # # Get everything removed down to where rebuilding requires: # "aclocal; autoconf; autoheader; automake --add-missing" # "configure; make; make install" # MAINTAINERCLEANFILES = Makefile.in all: all-am .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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) --gnu masterfiles/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu masterfiles/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(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 install-dist_masterfilesDATA: $(dist_masterfiles_DATA) @$(NORMAL_INSTALL) test -z "$(masterfilesdir)" || $(MKDIR_P) "$(DESTDIR)$(masterfilesdir)" @list='$(dist_masterfiles_DATA)'; test -n "$(masterfilesdir)" || 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)$(masterfilesdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(masterfilesdir)" || exit $$?; \ done uninstall-dist_masterfilesDATA: @$(NORMAL_UNINSTALL) @list='$(dist_masterfiles_DATA)'; test -n "$(masterfilesdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(masterfilesdir)'; $(am__uninstall_files_from_dir) 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 $(DATA) installdirs: for dir in "$(DESTDIR)$(masterfilesdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) 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) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) 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 "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) 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-dist_masterfilesDATA 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: uninstall-dist_masterfilesDATA .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-dist_masterfilesDATA \ 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 uninstall-dist_masterfilesDATA # 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: cfengine-3.2.4/masterfiles/cfengine_stdlib.cf0000644000175000017500000007766111715232734016214 00000000000000########################################################################### # Copyright (C) Cfengine AS # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License LGPL as published by the # Free Software Foundation; version 3. # # 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. # # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ########################################################################### # # Cfengine Community Open Promise-Body Library # # This initiative started by Cfengine promotes a # standardized set of names and promise specifications # for template functionality within Cfengine 3. # # The aim is to promote an industry standard for # naming of configuration patterns, leading to a # de facto middleware of standardized syntax. # # Names should be intuitive and parameters should be # minimal to assist readability and comprehensibility. # Contributions to this file are voluntarily given to # the cfengine community, and are moderated by Cfengine. # No liability or warranty for misuse is implied. # # If you add to this file, please try to make the # contributions "self-documenting". Comments made # after the bundle/body statement are retained in # the online docs # # Subversion : $Rev: 84 $ # For Cfengine Core: 3.1.0 ################################################### # If you find Cfengine useful, please consider # # purchasing a commercial version of the software.# ################################################### ################################################### # edit_line bundles ################################################### bundle edit_line insert_lines(lines) { insert_lines: "$(lines)" comment => "Append lines if they don't exist"; } ## bundle edit_line insert_file(templatefile) { insert_lines: "$(templatefile)" comment => "Insert the template file into the file being edited", insert_type => "file"; } ## bundle edit_line comment_lines_matching(regex,comment) # Comment lines of a file matching a regex { replace_patterns: "^($(regex))$" replace_with => comment("$(comment)"), comment => "Search and replace string"; } ## bundle edit_line uncomment_lines_matching(regex,comment) # Uncomment lines of a file where the regex matches # the text after the comment string { replace_patterns: "^$(comment)\s?($(regex))$" replace_with => uncomment, comment => "Uncomment lines matching a regular expression"; } ## bundle edit_line comment_lines_containing(regex,comment) # Comment lines of a file containing a regex { replace_patterns: "^(.*$(regex).*)$" replace_with => comment("$(comment)"), comment => "Comment out lines in a file"; } ## bundle edit_line uncomment_lines_containing(regex,comment) # Uncomment lines of a file where the regex matches # the text after the comment string { replace_patterns: "^$(comment)\s?(.*$(regex).*)$" replace_with => uncomment, comment => "Uncomment a line containing a fragment"; } ## bundle edit_line delete_lines_matching(regex) { delete_lines: "$(regex)" comment => "Delete lines matching regular expressions"; } ## bundle edit_line warn_lines_matching(regex) { delete_lines: "$(regex)" comment => "Warn about lines in a file", action => warn_only; } ## bundle edit_line append_if_no_line(str) { insert_lines: "$(str)" comment => "Append a line to the file if it doesn't already exist"; } ## bundle edit_line append_if_no_lines(list) { insert_lines: "$(list)" comment => "Append lines to the file if they don't already exist"; } ## bundle edit_line resolvconf(search,list) # search is the search domains with space # list is an slist of nameserver addresses { delete_lines: "search.*" comment => "Reset search lines from resolver"; "nameserver.*" comment => "Reset nameservers in resolver"; insert_lines: "search $(search)" comment => "Add search domains to resolver"; "nameserver $(list)" comment => "Add name servers to resolver"; } ## bundle edit_line set_variable_values(v) # Sets the RHS of variables in the file of the form # LHS = RHS # Adds a new line if no LHS exists, repairs RHS values if one does exist # # To use: # 1) Define an array, where the keys are the LHS and the values are the RHS # "stuff[lhs-1]" string => "rhs1"; # "stuff[lhs-2]" string => "rhs2"; # 2) The parameter passed to the edit_line promise is the fully qualified # name of the array (i.e., "bundlename.stuff") WITHOUT any "$" or "@" { vars: "index" slist => getindices("$(v)"); # Be careful if the index string contains funny chars "cindex[$(index)]" string => canonify("$(index)"); field_edits: # match a line starting like the key = something "\s*$(index)\s*=.*" edit_field => col("=","2","$($(v)[$(index)])","set"), classes => if_ok("$(cindex[$(index)])_in_file"), comment => "Match a line starting like key = something"; insert_lines: "$(index)=$($(v)[$(index)])", comment => "Insert a variable definition", ifvarclass => "!$(cindex[$(index)])_in_file"; } ## bundle edit_line set_variable_values2(file,v) # # Another implementation of set_variable_values. # The input and output should be exactly the same (except the file name), # but in some Cfengine versions there are bugs, # so this bundle can be used as a workaround. # { vars: "index" slist => getindices("$(v)"); # Be careful if the index string contains funny chars "cindex[$(index)]" string => canonify("$(index)"); "fieldc_$(cindex[$(index)])" int => getfields("$(index).*","$(file)","=","FIELD_$(cindex[$(index)])"); classes: "$(cindex[$(index)])_in_file" expression => strcmp("$(index)=$($(v)[$(index)])", "$(FIELD_$(index)[1])=$(FIELD_$(index)[2])"); delete_lines: # delete any lhs when no match "$(index)=.*", ifvarclass => "!$(cindex[$(index)])_in_file"; insert_lines: "$(index)=$($(v)[$(index)])", comment => "Insert a variable definition", ifvarclass => "!$(cindex[$(index)])_in_file"; } ## bundle edit_line append_users_starting(v) # For adding to /etc/passwd or etc/shadow, needs # an array v[username] string => "line..." { vars: "index" slist => getindices("$(v)"); classes: "add_$(index)" not => userexists("$(index)"); insert_lines: "$($(v)[$(index)])", comment => "Append users into a password file format", ifvarclass => "add_$(index)"; } ## bundle edit_line append_groups_starting(v) # For adding groups to /etc/group, needs # an array v[groupname] string => "line..." { vars: "index" slist => getindices("$(v)"); classes: "add_$(index)" not => groupexists("$(index)"); insert_lines: "$($(v)[$(index)])", comment => "Append users into a group file format", ifvarclass => "add_$(index)"; } ## bundle edit_line set_user_field(user,field,val) # Set the value of field number "field" in # a :-field formatted file like /etc/passwd { field_edits: "$(user):.*" comment => "Edit a user attribute in the password file", edit_field => col(":","$(field)","$(val)","set"); } ## bundle edit_line append_user_field(group,field,allusers) # For adding users to to a file like /etc/group # at field position "field", comma separated subfields { vars: "val" slist => { @(allusers) }; field_edits: "$(group):.*" comment => "Append users into a password file format", edit_field => col(":","$(field)","$(val)","alphanum"); } ## bundle edit_line expand_template(templatefile) # Read in the named text file and expand $(var) # inside the file { insert_lines: "$(templatefile)" insert_type => "file", comment => "Expand variables in the template file", expand_scalars => "true"; } ## bundle agent cronjob(commands,user,hours,mins) # For adding lines to crontab for a user # methods: # "cron" usebundle => cronjob("/bin/ls","mark","*","5,10"); { vars: SuSE:: "crontab" string => "/var/spool/cron/tabs"; redhat|fedora:: "crontab" string => "/var/spool/cron"; !(SuSE|redhat|fedora):: "crontab" string => "/var/spool/cron/crontabs"; files: "$(crontab)/$(user)" comment => "A user's regular batch jobs are added to this file", create => "true", edit_line => append_if_no_line("$(mins) $(hours) * * * $(commands)"), perms => mo("644","$(user)"); processes: "cron" comment => "Most crons need to be huped after file changes", signals => { "hup" }; } ## ## editing bodies ## body edit_field quoted_var(newval,method) { field_separator => "\""; select_field => "2"; value_separator => " "; field_value => "$(newval)"; field_operation => "$(method)"; extend_fields => "false"; allow_blank_fields => "true"; } ## body edit_field col(split,col,newval,method) { field_separator => "$(split)"; select_field => "$(col)"; value_separator => ","; field_value => "$(newval)"; field_operation => "$(method)"; extend_fields => "true"; allow_blank_fields => "true"; } ## body replace_with value(x) { replace_value => "$(x)"; occurrences => "all"; } ## body select_region INI_section(x) { select_start => "\[$(x)\]\s*"; select_end => "\[.*\]\s*"; } ## ## edit_defaults ## body edit_defaults std_defs { empty_file_before_editing => "false"; edit_backup => "false"; max_file_size => "300000"; } ## body edit_defaults empty { empty_file_before_editing => "true"; edit_backup => "false"; max_file_size => "300000"; } ## body edit_defaults no_backup { edit_backup => "false"; } ## ## location ## body location start { before_after => "before"; } ## body location after(str) { before_after => "after"; select_line_matching => "$(str)"; } ## ## replace_with ## ## body replace_with comment(c) { replace_value => "$(c) $(match.1)"; occurrences => "all"; } ## body replace_with uncomment { replace_value => "$(match.1)"; occurrences => "all"; } #################################################### ## agent bodyparts #################################################### ## ## action ## body action if_elapsed(x) { ifelapsed => "$(x)"; expireafter => "$(x)"; } ## body action measure_performance(x) { measurement_class => "Detect changes in $(this.promiser)"; ifelapsed => "$(x)"; expireafter => "$(x)"; } ## body action warn_only { action_policy => "warn"; ifelapsed => "60"; } ## body action bg(elapsed,expire) { ifelapsed => "$(elapsed)"; expireafter => "$(expire)"; background => "true"; } ## body action ifwin_bg { windows:: background => "true"; } ## body action immediate { ifelapsed => "0"; } ## body action policy(p) { action_policy => "$(p)"; } ## # Log a message to log=[/file|stdout] body action log_repaired(log,message) { log_string => "$(sys.date), $(message)"; log_repaired => "$(log)"; } ## ## contain ## body contain silent { no_output => "true"; } ## body contain in_dir(s) { chdir => "$(s)"; } ## body contain in_dir_shell(s) { chdir => "$(s)"; useshell => "true"; } ## body contain silent_in_dir(s) { chdir => "$(s)"; no_output => "true"; } ## body contain in_shell { useshell => "true"; } ## body contain in_shell_and_silent { useshell => "true"; no_output => "true"; } ## body contain setuid(x) { exec_owner => "$(x)"; useshell => "false"; } ## body contain setuid_sh(x) { exec_owner => "$(x)"; useshell => "true"; } ## body contain setuidgid_sh(owner,group) { exec_owner => "$(owner)"; exec_group => "$(group)"; useshell => "true"; } ## body contain jail(owner,root,dir) { exec_owner => "$(owner)"; useshell => "true"; chdir => "$(dir)"; chroot => "$(root)"; } ## ## classes ## body classes if_repaired(x) { promise_repaired => { "$(x)" }; } ## body classes if_else(yes,no) { promise_kept => { "$(yes)" }; promise_repaired => { "$(yes)" }; repair_failed => { "$(no)" }; repair_denied => { "$(no)" }; repair_timeout => { "$(no)" }; } ## body classes cf2_if_else(yes,no) # meant to match cf2 semantics { promise_repaired => { "$(yes)" }; repair_failed => { "$(no)" }; repair_denied => { "$(no)" }; repair_timeout => { "$(no)" }; } ## body classes if_notkept(x) { repair_failed => { "$(x)" }; repair_denied => { "$(x)" }; repair_timeout => { "$(x)" }; } ## body classes if_ok(x) { promise_repaired => { "$(x)" }; promise_kept => { "$(x)" }; } ## body classes cmd_repair(code,cl) { repaired_returncodes => { "$(code)" }; promise_repaired => { "$(cl)" }; } ## ## Persistent classes ## body classes state_repaired(x) { promise_repaired => { "$(x)" }; persist_time => "10"; } ## body classes enumerate(x) # # This is used by commercial editions to count # instances of jobs in a cluster # { promise_repaired => { "mXC_$(x)" }; promise_kept => { "mXC_$(x)" }; persist_time => "15"; } ################################################### # agent bundles ################################################### ##.................................................. ## files promises ##.................................................. ## ## copy_from ## body copy_from secure_cp(from,server) { source => "$(from)"; servers => { "$(server)" }; compare => "digest"; encrypt => "true"; verify => "true"; } ## body copy_from remote_cp(from,server) { servers => { "$(server)" }; source => "$(from)"; compare => "mtime"; } ## body copy_from remote_dcp(from,server) { servers => { "$(server)" }; source => "$(from)"; compare => "digest"; } ## body copy_from local_cp(from) { source => "$(from)"; } ## body copy_from local_dcp(from) { source => "$(from)"; compare => "digest"; } ## body copy_from perms_cp(from) { source => "$(from)"; preserve => "true"; } ## # Copy only if the file does not already exist, i.e. seed the placement body copy_from seed_cp(from) { source => "$(from)"; compare => "exists"; } ## body copy_from sync_cp(from,server) { servers => { "$(server)" }; source => "$(from)"; purge => "true"; preserve => "true"; type_check => "false"; } ## body copy_from no_backup_cp(from) { source => "$(from)"; copy_backup => "false"; } ## body copy_from no_backup_dcp(from) { source => "$(from)"; copy_backup => "false"; compare => "digest"; } ## body copy_from no_backup_rcp(from,server) { servers => { "$(server)" }; source => "$(from)"; compare => "mtime"; copy_backup => "false"; } ## ## link_from ## body link_from ln_s(x) { link_type => "symlink"; source => "$(x)"; when_no_source => "force"; } ## body link_from linkchildren(tofile) { source => "$(tofile)"; link_type => "symlink"; when_no_source => "force"; link_children => "true"; when_linking_children => "if_no_such_file"; # "override_file"; } ## ## perms ## body perms m(mode) { mode => "$(mode)"; } ## body perms mo(mode,user) { owners => { "$(user)" }; mode => "$(mode)"; } ## body perms mog(mode,user,group) { owners => { "$(user)" }; groups => { "$(group)" }; mode => "$(mode)"; } ## body perms og(u,g) { owners => { "$(u)" }; groups => { "$(g)" }; } ## body perms owner(user) { owners => { "$(user)" }; } ## ## ACLS (extended Unix perms) ## body acl access_generic(acl) # default/inherited ACLs are left unchanged, # applicable for both files and directory on all platforms { acl_method => "overwrite"; aces => { "@(acl)" }; } ## body acl strict # NOTE: May need to take ownership of file/dir # to be sure no-one else is allowed access { acl_method => "overwrite"; windows:: aces => { "user:Administrator:rwx" }; !windows:: aces => { "user:root:rwx" }; } ## ## depth_search ## body depth_search recurse(d) { depth => "$(d)"; xdev => "true"; } ## body depth_search recurse_ignore(d,list) { depth => "$(d)"; exclude_dirs => { @(list) }; } ## ## delete ## body delete tidy { dirlinks => "delete"; rmdirs => "true"; } ## ## rename ## body rename disable { disable => "true"; } ## body rename rotate(level) { rotate => "$(level)"; } ## body rename to(file) { newname => "$(file)"; } ## ## file_select ## body file_select name_age(name,days) { leaf_name => { "$(name)" }; mtime => irange(0,ago(0,0,"$(days)",0,0,0)); file_result => "mtime.leaf_name"; } ## body file_select days_old(days) { mtime => irange(0,ago(0,0,"$(days)",0,0,0)); file_result => "mtime"; } ## body file_select size_range(from,to) { search_size => irange("$(from)","$(to)"); file_result => "size"; } ## body file_select exclude(name) { leaf_name => { "$(name)"}; file_result => "!leaf_name"; } ## body file_select plain { file_types => { "plain" }; file_result => "file_types"; } body file_select dirs { file_types => { "dir" }; file_result => "file_types"; } ## body file_select by_name(names) { leaf_name => { @(names)}; file_result => "leaf_name"; } ## body file_select ex_list(names) { leaf_name => { @(names)}; file_result => "!leaf_name"; } ## ## changes ## body changes detect_all_change # This is fierce, and will cost disk cycles { hash => "best"; report_changes => "all"; update_hashes => "yes"; } ## body changes detect_content # This is a cheaper alternative { hash => "md5"; report_changes => "content"; update_hashes => "yes"; } ## body changes noupdate # Use on (small) files that should never change { hash => "sha256"; report_changes => "content"; update_hashes => "no"; } ## body changes diff # Generates diff report (Nova and above) { hash => "sha256"; report_changes => "content"; report_diffs => "true"; update_hashes => "yes"; } ## body changes diff_noupdate { hash => "sha256"; report_changes => "content"; report_diffs => "true"; update_hashes => "no"; } ##-------------------------------------------------------------- ## Packages promises ##-------------------------------------------------------------- body package_method zypper { package_changes => "bulk"; package_list_command => "/bin/rpm -qa --queryformat \"i | repos | %{name} | %{version}-%{release} | %{arch}\n\""; # set it to "0" to avoid caching of list during upgrade package_list_update_ifelapsed => "240"; package_patch_list_command => "/usr/bin/zypper patches"; package_installed_regex => "i.*"; package_list_name_regex => "[^|]+\|[^|]+\|\s+([^\s]+).*"; package_list_version_regex => "[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_list_arch_regex => "[^|]+\|[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_patch_installed_regex => ".*Installed.*|.*Not Applicable.*"; package_patch_name_regex => "[^|]+\|\s+([^\s]+).*"; package_patch_version_regex => "[^|]+\|[^|]+\|\s+([^\s]+).*"; package_name_convention => "$(name)"; package_add_command => "/usr/bin/zypper --non-interactive install"; package_delete_command => "/usr/bin/zypper --non-interactive remove --force-resolution"; package_update_command => "/usr/bin/zypper --non-interactive update"; package_patch_command => "/usr/bin/zypper --non-interactive patch$"; # $ means no args package_verify_command => "/usr/bin/zypper --non-interactive verify$"; } ## body package_method apt { package_changes => "bulk"; package_list_command => "/usr/bin/dpkg -l"; package_list_name_regex => "ii\s+([^\s]+).*"; package_list_version_regex => "ii\s+[^\s]+\s+([^\s]+).*"; package_installed_regex => ".*"; # all reported are installed package_name_convention => "$(name)"; # set it to "0" to avoid caching of list during upgrade package_list_update_ifelapsed => "240"; have_aptitude:: package_add_command => "/usr/bin/aptitude --assume-yes install"; package_list_update_command => "/usr/bin/aptitude update"; package_delete_command => "/usr/bin/aptitude --assume-yes remove"; package_update_command => "/usr/bin/aptitude --assume-yes install"; package_verify_command => "/usr/bin/aptitude show"; package_noverify_regex => "(State: not installed|E: Unable to locate package .*)"; !have_aptitude:: package_add_command => "/usr/bin/apt-get --yes install"; package_list_update_command => "/usr/bin/apt-get update"; package_delete_command => "/usr/bin/apt-get --yes remove"; package_update_command => "/usr/bin/apt-get --yes install"; package_verify_command => "/usr/bin/dpkg -s"; package_noverify_returncode => "1"; } ## body package_method dpkg_version(repo) { package_changes => "individual"; package_list_command => "/usr/bin/dpkg -l"; # set it to "0" to avoid caching of list during upgrade package_list_update_ifelapsed => "240"; package_list_name_regex => "ii\s+([^\s]+).*"; package_list_version_regex => "ii\s+[^\s]+\s+([^\s]+).*"; package_installed_regex => ".*"; # all reported are installed package_file_repositories => { "$(repo)" }; debian.x86_64:: package_name_convention => "$(name)_$(version)_amd64.deb"; debian.i686:: package_name_convention => "$(name)_$(version)_i386.deb"; debian:: package_add_command => "/usr/bin/dpkg --install"; package_delete_command => "/usr/bin/dpkg --purge"; package_update_command => "/usr/bin/dpkg --install"; } ## body package_method rpm_version(repo) { package_changes => "individual"; package_list_command => "/bin/rpm -qa --queryformat \"i | repos | %{name} | %{version}-%{release} | %{arch}\n\""; # set it to "0" to avoid caching of list during upgrade package_list_update_ifelapsed => "240"; package_list_name_regex => "[^|]+\|[^|]+\|\s+([^\s|]+).*"; package_list_version_regex => "[^|]+\|[^|]+\|[^|]+\|\s+([^\s|]+).*"; package_list_arch_regex => "[^|]+\|[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_installed_regex => "i.*"; package_file_repositories => { "$(repo)" }; package_name_convention => "$(name)-$(version).$(arch).rpm"; package_add_command => "/bin/rpm -ivh "; package_update_command => "/bin/rpm -Uvh "; package_delete_command => "/bin/rpm -e --nodeps"; package_noverify_regex => ".*[^\s].*"; } ## body package_method msi_implicit(repo) # Use whole file name as promiser, e.g. "7-Zip-4.50-x86_64.msi", # the name, version and arch is then deduced from the promiser { package_changes => "individual"; package_file_repositories => { "$(repo)" }; package_installed_regex => ".*"; package_name_convention => "$(name)-$(version)-$(arch).msi"; package_delete_convention => "$(firstrepo)$(name)-$(version)-$(arch).msi"; package_name_regex => "^(\S+)-(\d+\.?)+"; package_version_regex => "^\S+-((\d+\.?)+)"; package_arch_regex => "^\S+-[\d\.]+-(.*).msi"; package_add_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_update_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_delete_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /x"; } ## body package_method msi_explicit(repo) # use software name as promiser, e.g. "7-Zip", and explicitly # specify any package_version and package_arch { package_changes => "individual"; package_file_repositories => { "$(repo)" }; package_installed_regex => ".*"; package_name_convention => "$(name)-$(version)-$(arch).msi"; package_delete_convention => "$(firstrepo)$(name)-$(version)-$(arch).msi"; package_add_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_update_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_delete_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /x"; } ## body package_method yum { package_changes => "bulk"; package_list_command => "/usr/bin/yum list installed"; package_patch_list_command => "/usr/bin/yum check-update"; # Remember to escape special characters like | package_list_name_regex => "([^.]+).*"; package_list_version_regex => "[^\s]\s+([^\s]+).*"; package_list_arch_regex => "[^.]+\.([^\s]+).*"; package_installed_regex => ".*(installed|\s+@).*"; package_name_convention => "$(name).$(arch)"; # set it to "0" to avoid caching of list during upgrade package_list_update_ifelapsed => "240"; package_patch_installed_regex => "^\s.*"; package_patch_name_regex => "([^.]+).*"; package_patch_version_regex => "[^\s]\s+([^\s]+).*"; package_patch_arch_regex => "[^.]+\.([^\s]+).*"; package_add_command => "/usr/bin/yum -y install"; package_update_command => "/usr/bin/yum -y update"; package_delete_command => "/bin/rpm -e --nodeps"; package_verify_command => "/bin/rpm -V"; } ## body package_method yum_rpm # Contributed by Trond Hasle Amundsen # More efficient package method for RedHat - uses rpm to list instead of yum # Notes: # - using $(name).$(arch) instead of $(name) for package_name_convention # causes uninstallation to fail. # - using allmatches to remove for all architectures # { package_changes => "bulk"; package_list_command => "/bin/rpm -qa --qf '%{name} %{version}-%{release} %{arch}\n'"; package_patch_list_command => "/usr/bin/yum check-update"; package_list_name_regex => "^(\S+?)\s\S+?\s\S+$"; package_list_version_regex => "^\S+?\s(\S+?)\s\S+$"; package_list_arch_regex => "^\S+?\s\S+?\s(\S+)$"; package_installed_regex => ".*"; package_name_convention => "$(name)"; package_patch_installed_regex => "^\s.*"; package_patch_name_regex => "([^.]+).*"; package_patch_version_regex => "[^\s]\s+([^\s]+).*"; package_patch_arch_regex => "[^.]+\.([^\s]+).*"; package_add_command => "/usr/bin/yum -y install"; package_update_command => "/usr/bin/yum -y update"; package_delete_command => "/bin/rpm -e --nodeps --allmatches"; package_verify_command => "/bin/rpm -V"; } ## # The solaris package system is poorly designed, with too many different # names to track. See the example in tests/units/unit_package_solaris.cf # to see how to use this body package_method solaris (pkgname, spoolfile, adminfile) { package_changes => "individual"; package_list_command => "/usr/bin/pkginfo -l"; package_multiline_start => "\s*PKGINST:\s+[^\s]+"; package_list_name_regex => "\s*PKGINST:\s+([^\s]+)"; package_list_version_regex => "\s*VERSION:\s+([^\s]+)"; package_list_arch_regex => "\s*ARCH:\s+([^\s]+)"; package_installed_regex => "\s*STATUS:\s*(completely|partially)\s+installed.*"; package_name_convention => "$(name)"; package_add_command => "/usr/sbin/pkgadd -n -a /tmp/$(adminfile) -d /tmp/$(spoolfile)"; package_delete_command => "/usr/sbin/pkgrm -n -a /tmp/$(adminfile)"; } ## body package_method freebsd { package_changes => "individual"; # Could use rpm for this package_list_command => "/usr/sbin/pkg_info"; # Remember to escape special characters like | package_list_name_regex => "([^\s]+)-.*"; package_list_version_regex => "[^\s]+-([^\s]+).*"; package_name_regex => "([^\s]+)-.*"; package_version_regex => "[^\s]+-([^\s]+).*"; package_installed_regex => ".*"; package_name_convention => "$(name)-$(version)"; package_add_command => "/usr/sbin/pkg_add -r"; package_delete_command => "/usr/sbin/pkg_delete"; } ## # Single bundle for all the similar managers simplifies promises body package_method generic { SuSE:: package_changes => "bulk"; package_list_command => "/usr/bin/zypper packages"; package_patch_list_command => "/usr/bin/zypper patches"; package_installed_regex => "i.*"; package_list_name_regex => "[^|]+\|[^|]+\|\s+([^\s]+).*"; package_list_version_regex => "[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_list_arch_regex => "[^|]+\|[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_patch_installed_regex => ".*Installed.*|.*Not Applicable.*"; package_patch_name_regex => "[^|]+\|\s+([^\s]+).*"; package_patch_version_regex => "[^|]+\|[^|]+\|\s+([^\s]+).*"; package_name_convention => "$(name)"; package_add_command => "/usr/bin/zypper --non-interactive install"; package_delete_command => "/usr/bin/zypper --non-interactive remove --force-resolution"; package_update_command => "/usr/bin/zypper --non-interactive update"; package_patch_command => "/usr/bin/zypper --non-interactive patch$"; # $ means no args package_verify_command => "/usr/bin/zypper --non-interactive verify$"; redhat:: package_changes => "bulk"; package_list_command => "/usr/bin/yum list installed"; package_patch_list_command => "/usr/bin/yum check-update"; package_list_name_regex => "([^.]+).*"; package_list_version_regex => "[^\s]\s+([^\s]+).*"; package_list_arch_regex => "[^.]+\.([^\s]+).*"; package_installed_regex => ".*(installed|\s+@).*"; package_name_convention => "$(name).$(arch)"; package_list_update_ifelapsed => "240"; package_patch_installed_regex => "^\s.*"; package_patch_name_regex => "([^.]+).*"; package_patch_version_regex => "[^\s]\s+([^\s]+).*"; package_patch_arch_regex => "[^.]+\.([^\s]+).*"; package_add_command => "/usr/bin/yum -y install"; package_delete_command => "/bin/rpm -e --nodeps"; package_verify_command => "/bin/rpm -V"; debian:: package_changes => "bulk"; package_list_command => "/usr/bin/dpkg -l"; package_list_name_regex => "ii\s+([^\s]+).*"; package_list_version_regex => "ii\s+[^\s]+\s+([^\s]+).*"; package_installed_regex => ".*"; # all reported are installed package_name_convention => "$(name)"; package_list_update_ifelapsed => "240"; # 4 hours debian.have_aptitude:: package_add_command => "/usr/bin/aptitude --assume-yes install"; package_list_update_command => "/usr/bin/aptitude update"; package_delete_command => "/usr/bin/aptitude --assume-yes remove"; package_update_command => "/usr/bin/aptitude --assume-yes install"; package_verify_command => "/usr/bin/aptitude show"; package_noverify_regex => "(State: not installed|E: Unable to locate package .*)"; debian.!have_aptitude:: package_add_command => "/usr/bin/apt-get --yes install"; package_list_update_command => "/usr/bin/apt-get update"; package_delete_command => "/usr/bin/apt-get --yes remove"; package_update_command => "/usr/bin/apt-get --yes install"; package_verify_command => "/usr/bin/dpkg -s"; package_noverify_returncode => "1"; freebsd:: package_changes => "individual"; package_list_command => "/usr/sbin/pkg_info"; package_list_name_regex => "([^\s]+)-.*"; package_list_version_regex => "[^\s]+-([^\s]+).*"; package_name_regex => "([^\s]+)-.*"; package_version_regex => "[^\s]+-([^\s]+).*"; package_installed_regex => ".*"; package_name_convention => "$(name)-$(version)"; package_add_command => "/usr/sbin/pkg_add -r"; package_delete_command => "/usr/sbin/pkg_delete"; } ##------------------------------------------------------- ## storage promises ##------------------------------------------------------- body volume min_free_space(free) { check_foreign => "false"; freespace => "$(free)"; sensible_size => "10000"; sensible_count => "2"; } ## body mount nfs(server,source) { mount_type => "nfs"; mount_source => "$(source)"; mount_server => "$(server)"; edit_fstab => "true"; } ## body mount nfs_p(server,source,perm) { mount_type => "nfs"; mount_source => "$(source)"; mount_server => "$(server)"; mount_options => {"$(perm)"}; edit_fstab => "true"; } ## body mount unmount { mount_type => "nfs"; edit_fstab => "true"; unmount => "true"; } ##------------------------------------------------------- ## process promises ##------------------------------------------------------- body process_select exclude_procs(x) { command => "$(x)"; process_result => "!command"; } ## body process_select days_older_than(d) { stime_range => irange(ago(0,0,"$(d)",0,0,0),now); process_result => "stime"; } ## body process_count any_count(cl) { match_range => "0,0"; out_of_range_define => { "$(cl)" }; } ## body process_count check_range(name,lower,upper) { match_range => irange("$(lower)","$(upper)"); out_of_range_define => { "$(name)_out_of_range" }; } ## ## service promises ## body service_method bootstart { service_autostart_policy => "boot_time"; service_dependence_chain => "start_parent_services"; windows:: service_type => "windows"; } ## body service_method force_deps { service_dependence_chain => "all_related"; windows:: service_type => "windows"; } #################################################### ## monitor bodyparts #################################################### body match_value scan_log(line) { select_line_matching => "$(line)"; track_growing_file => "true"; } ## body action sample_rate(x) { ifelapsed => "$(x)"; expireafter => "10"; } cfengine-3.2.4/m4/0000755000175000017500000000000011715233355010624 500000000000000cfengine-3.2.4/m4/cf3_with_library.m40000644000175000017500000000340711707771422014247 00000000000000# CF3_WITH_LIBRARY(library-name, checks) # -------------------------------------- # # This function popluates CFLAGS, CPPFLAGS and LDFLAGS from the # --with-$library=PATH and runs a second argument with those options. # # After execution flags are returned to previous state, but available in # ${LIBRARY}_{CFLAGS,LDFLAGS}. Path is available in ${LIBRARY}_PATH. # # Libraries added to LIBS are available as ${LIBRARY}_LIBS afterwards. # AC_DEFUN([CF3_WITH_LIBRARY], [ m4_define([ULN],m4_toupper($1)) # # Populate ${LIBRARY}_{PATH,CFLAGS,LDFLAGS} according to arguments # if test "x$with_[$1]" != xyes && test "x$with_[$1]" != xcheck; then ULN[]_PATH="$with_[$1]" if test "x$with_[$1]" != x/usr && test "x$with_[$1]" != x/; then ULN[]_CFLAGS="-I$with_[$1]/include" ULN[]_LDFLAGS="-L$with_[$1]/lib" fi else ULN[]_PATH="default path" fi save_CFLAGS="$CFLAGS" save_CPPFLAGS="$CPPFLAGS" save_LDFLAGS="$LDFLAGS" save_LIBS="$LIBS" CFLAGS="$CFLAGS $ULN[]_CFLAGS" CPPFLAGS="$CPPFLAGS $ULN[]_CFLAGS" LDFLAGS="$LDFLAGS $ULN[]_LDFLAGS" LIBS="" $2 # # Pick up any libraries added by tests # ULN[]_LIBS="$LIBS" # # libtool understands -R$path, but we are not using libtool in configure # snippets, so -R$path goes to $pkg_LDFLAGS only after autoconf tests # if test "x$with_[$1]" != xyes && test "x$with_[$1]" != xcheck; then if test "x$with_[$1]" != x/usr && test "x$with_[$1]" != x/; then ULN[]_LDFLAGS="$ULN[]_LDFLAGS -R$with_[$1]/lib" fi fi # # Restore pristine environment # CFLAGS="$save_CFLAGS" CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" AC_SUBST(ULN[]_PATH) AC_SUBST(ULN[]_CPPFLAGS) AC_SUBST(ULN[]_CFLAGS) AC_SUBST(ULN[]_LDFLAGS) AC_SUBST(ULN[]_LIBS) ]) cfengine-3.2.4/m4/ltsugar.m40000644000175000017500000001042411715232770012470 00000000000000# 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 ]) cfengine-3.2.4/m4/ltversion.m40000644000175000017500000000126211715232770013034 00000000000000# 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. # @configure_input@ # serial 3337 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4.2]) m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4.2' macro_revision='1.3337' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) cfengine-3.2.4/m4/libtool.m40000644000175000017500000106043411715232770012462 00000000000000# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 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, 2009, 2010, 2011 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 57 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_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl 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 _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) 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 "$cc_temp" | $SED "s%.*/%%; 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 AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl 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_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])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 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 # 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_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify 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' ]) # _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 "$][$1" | $SED "$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 "$" | $SED "$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' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$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 \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # `#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test $lt_write_fail = 0 && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_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]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false 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) 2011 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. 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) ])# 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 '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_REPLACE_SHELLFNS 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)], [Go], [_LT_LANG(GO)], [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 m4_ifndef([AC_PROG_GO], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_GO. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_GO], [AC_LANG_PUSH(Go)dnl AC_ARG_VAR([GOC], [Go compiler command])dnl AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl _AC_ARG_VAR_LDFLAGS()dnl AC_CHECK_TOOL(GOC, gccgo) if test -z "$GOC"; then if test -n "$ac_tool_prefix"; then AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) fi fi if test -z "$GOC"; then AC_CHECK_PROG(GOC, gccgo, gccgo, false) fi ])#m4_defun ])#m4_ifndef # _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([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) 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)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) 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], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _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 there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 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" ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) 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" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES([TAG]) # --------------------------------- # 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 if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _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=func_echo_all _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([TAGNAME]) # ---------------------------------- # 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. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`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 "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script which will find a shell with a builtin # printf (which we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case "$ECHO" in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [ --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified).], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([${with_sysroot}]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and in which our libraries should be installed.])]) # _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 '$LINENO' "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 ;; *-*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*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) 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_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR 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 \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _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_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _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:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $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 "$_lt_compiler_boilerplate" | $SED '/^$/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 "$_lt_linker_boilerplate" | $SED '/^$/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; ;; mint*) # On MiNT this can take a long time and run out of memory. 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 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; 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"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$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 $LINENO "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 /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 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; else puts (dlerror ()); } /* 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:$LINENO: $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:$LINENO: \$? = $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 "$_lt_compiler_boilerplate" | $SED '/^$/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 m4_require([_LT_CHECK_SHELL_FEATURES])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 case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # 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 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # 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; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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=`func_echo_all "$lib" | $SED '\''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 # correct to gnu/linux during the next big refactor 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,$cc_basename in yes,*) # gcc 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}' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; 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 dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. 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 # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # 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' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # 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 # correct to gnu/linux during the next big refactor 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 ;; 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[[23]].*) 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 # correct to gnu/linux during the next big refactor 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 ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" 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=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' 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' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor 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 AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no 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], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # 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;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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _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 m4_require([_LT_PROG_ECHO_BACKSLASH])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 # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' 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 ;; haiku*) 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])(-bit)?( [LM]SB)? 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 glibc/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_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi 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_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob 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. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi 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:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $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:$LINENO: 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_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-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 case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _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([AC_PROG_AWK])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};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /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 lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # 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 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #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. */ LT@&t@_DLSYM_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_globsym_save_LIBS=$LIBS lt_globsym_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_globsym_save_LIBS CFLAGS=$lt_globsym_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 # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' 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_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _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)= 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)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $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 ;; 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). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; 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* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _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* | sunCC*) # 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' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; 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 case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" fi ;; 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' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # 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* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _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\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # 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)='' ;; *Sun\ F* | *Sun*Fortran*) _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 ' ;; *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,' ;; *Intel*\ [[CF]]*Compiler*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; *Portland\ Group*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; 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* | sunf77* | sunf90* | sunf95*) _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_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # 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]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # 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_PATH_MANIFEST_TOOL])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' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] 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 # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". 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") || (\$ 2 == "W")) && ([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*) case $cc_basename in cl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; linux* | k*bsd*-gnu | 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 ], [ 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_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 | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = 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.19, 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 install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _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(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _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/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] 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 ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; 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=' $pic_flag' 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; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # 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; func_echo_all \"$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]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; 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; func_echo_all \"$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* | bgf* | bgxlf* | mpixlf*) # 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)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_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 $linker_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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $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 # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". 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") || (\$ 2 == "W")) && ([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([$1]) _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 func_echo_all "${wl}${allow_undefined_flag}"; 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([$1]) _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' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _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. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # 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 $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _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' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _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 `func_echo_all "$deplibs" | $SED '\''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(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; 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 ;; # 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 $pic_flag -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 $pic_flag ${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 && test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${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_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 && test "$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 $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${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' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS="$save_LDFLAGS"]) if test "$lt_cv_irix_exported_symbol" = yes; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -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" && func_echo_all "-set_version $verstring"` -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" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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" && func_echo_all "-set_version $verstring"` -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} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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" && func_echo_all "-set_version $verstring"` -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 "-set_version $verstring"` -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 $pic_flag ${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 $pic_flag ${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_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$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_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_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* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_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_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([], [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([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _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_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], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl 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 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_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(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_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_CFLAGS=$CFLAGS 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++"} CFLAGS=$CXXFLAGS 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 $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -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 -v "^Configured with:" | $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([$1]) _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 func_echo_all "${wl}${allow_undefined_flag}"; 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([$1]) _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' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _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*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # 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 _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # 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 $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _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(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _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 ;; esac ;; 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 ;; freebsd2.*) # 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*) ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; 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; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${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; func_echo_all "$list"' ;; *) 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 $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${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" && func_echo_all "-set_version $verstring"` -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 $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -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; func_echo_all "$list"' _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 | sort | $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 | sort | $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 | sort | $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 | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above 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; func_echo_all \"$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=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # 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; func_echo_all \"$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='func_echo_all' # 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=func_echo_all 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" && func_echo_all "${wl}-set_version $verstring"` -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" && func_echo_all "-set_version $verstring"` -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 "-set_version $verstring"` -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=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) 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" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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 -v "^Configured with:" | $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* | sunCC*) # 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='func_echo_all' # 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 $pic_flag -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 $pic_flag -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 -v "^Configured with:" | $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 -v "^Configured with:" | $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(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _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 CFLAGS=$lt_save_CFLAGS 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_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf 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). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _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 AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])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 ], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF package foo func foo() { } _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac 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 ${prev}${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 fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} 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 prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$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 CFLAGS=$_lt_libdeps_save_CFLAGS # 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* | sunCC*) # 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_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_LANG_PUSH(Fortran 77) if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi _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_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(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_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 lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS 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" CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _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_LANG_PUSH(Fortran) if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi _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_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(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_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 lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS 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 CFLAGS=$lt_save_CFLAGS 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_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS 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 _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_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 CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_GO_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE # Source file extension for Go test sources. ac_ext=go # Object file extension for compiled Go test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="package main; func main() { }" # Code to be used in simple link tests lt_simple_link_test_code='package main; func main() { }' # 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_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # Go 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 _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_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 CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_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_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= 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 CFLAGS=$lt_save_CFLAGS ])# _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_GO # ---------- AC_DEFUN([LT_PROG_GO], [AC_CHECK_TOOL(GOC, gccgo,) ]) # 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_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _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%"$_lt_dummy"}, \ = c,a/b,b/c, \ && 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_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) # ------------------------------------------------------ # In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and # '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. m4_defun([_LT_PROG_FUNCTION_REPLACE], [dnl { sed -e '/^$1 ()$/,/^} # $1 /c\ $1 ()\ {\ m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) } # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: ]) # _LT_PROG_REPLACE_SHELLFNS # ------------------------- # Replace existing portable implementations of several shell functions with # equivalent extended shell implementations where those features are available.. m4_defun([_LT_PROG_REPLACE_SHELLFNS], [if test x"$xsi_shell" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl # 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}"}]) _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl func_split_long_opt_name=${1%%=*} func_split_long_opt_arg=${1#*=}]) _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) fi if test x"$lt_shell_append" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl func_quote_for_eval "${2}" dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) fi ]) # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine which file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS cfengine-3.2.4/m4/lt~obsolete.m40000644000175000017500000001375611715232770013374 00000000000000# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2009 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 5 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_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])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) cfengine-3.2.4/m4/acinclude.m40000644000175000017500000001624011707771422012743 00000000000000dnl From http://ac-archive.sourceforge.net/ac-archive/acx_pthread.html AC_DEFUN([ACX_PTHREAD], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_LANG_SAVE AC_LANG_C acx_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) AC_MSG_RESULT($acx_pthread_ok) if test x"$acx_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config pthreadGC2" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: 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 # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case "${host_cpu}-${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: acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" ;; esac if test x"$acx_pthread_ok" = xno; then for flag in $acx_pthread_flags; do case $flag in none) AC_MSG_CHECKING([whether pthreads work without any flags]) ;; -*) AC_MSG_CHECKING([whether pthreads work with $flag]) PTHREAD_CFLAGS="$flag" ;; pthread-config) AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) if test x"$acx_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) AC_MSG_CHECKING([for the pthreads library -l$flag]) PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. AC_TRY_LINK([#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); ], [acx_pthread_ok=yes]) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" AC_MSG_RESULT($acx_pthread_ok) if test "x$acx_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$acx_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. AC_MSG_CHECKING([for joinable pthread attribute]) attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do AC_TRY_LINK([#include ], [int attr=$attr; return attr;], [attr_name=$attr; break]) done AC_MSG_RESULT($attr_name) if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, [Define to necessary symbol if this constant uses a non-standard name on your system.]) fi AC_MSG_CHECKING([if more special flags are required for pthreads]) flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; esac AC_MSG_RESULT(${flag}) if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: must compile with xlc_r or cc_r if test x"$GCC" != xyes; then AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) else PTHREAD_CC=$CC fi else PTHREAD_CC="$CC" fi AC_SUBST(PTHREAD_LIBS) AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_CC) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$acx_pthread_ok" = xyes; then ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) : else acx_pthread_ok=no $2 fi AC_LANG_RESTORE ])dnl ACX_PTHREAD cfengine-3.2.4/m4/ltoptions.m40000644000175000017500000003007311715232770013044 00000000000000# Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008, 2009 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 7 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], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [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@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac], [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])]) cfengine-3.2.4/examples/0000755000175000017500000000000011715233356012123 500000000000000cfengine-3.2.4/examples/unit_translatepath.cf0000644000175000017500000000046411707771422016274 00000000000000 body common control { bundlesequence => { "test" }; } ############################## bundle agent test { vars: "inputs_dir" string => translatepath("$(sys.workdir)/inputs"); reports: windows:: "The path has backslashes: $(inputs_dir)"; !windows:: "The path has slashes: $(inputs_dir)"; } cfengine-3.2.4/examples/unit_activedirectory_listusers.cf0000644000175000017500000000302211707771422020730 00000000000000# This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # List users from Active Directory through LDAP # Note: Anonymous LDAP binding must be allowed, and the Anonymous user # must have read access to CN=Users bundle agent ldap { vars: "userlist" slist => ldaplist( "ldap://cf-win2003", "CN=Users,DC=domain,DC=cf-win2003", "(objectClass=user)", "sAMAccountName", "subtree", "none"); reports: Yr2010:: "Username: \"$(userlist)\""; } cfengine-3.2.4/examples/unit_filenames.cf0000644000175000017500000000216511707771422015365 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # filenames # bundle agent test { files: "/etc/passwd" create => "true"; "C:\etc\passwd" create => "true"; "etc/passwd" create => "true"; } cfengine-3.2.4/examples/unit_change_detect.cf0000644000175000017500000000316211707771422016175 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Change detect # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/home/mark/tmp/web" -> "me" changes => detect_all_change, depth_search => recurse("inf"); } ######################################################### body changes detect_all_change { report_changes => "all"; update_hashes => "true"; } ######################################################### body depth_search recurse(d) { depth => "$(d)"; } cfengine-3.2.4/examples/unit_fileexists.cf0000644000175000017500000000240011707771422015571 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "exists" expression => fileexists("/etc/passwdx"); reports: exists:: "File exists"; !exists:: "Does not exist"; } cfengine-3.2.4/examples/unit_changedbefore.cf0000644000175000017500000000236011707771422016173 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "do_it" and => { changedbefore("/tmp/earlier","/tmp/later") }; reports: do_it:: "Earlier than later!"; } cfengine-3.2.4/examples/active_directory.cf0000644000175000017500000000536411707771422015726 00000000000000# This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################################### # active_directory.cf - Extract Data From Windows Domain Controllers # # NOTE: Since we don't supply any credentials in this policy file, # the Domain Controller must allow anonymous bind. Also, # the user "NT AUTHORITY\ANONYMOUS LOGON" must be granted access # to the resources we want to read. # ######################################################################### bundle agent active_directory { vars: # NOTE: Edit this to your domain, e.g. "corp", may also need more DC's after it "domain_name" string => "cftesting"; "user_name" string => "Guest"; # NOTE: We can also extract data from remote Domain Controllers dummy.DomainController:: "domain_controller" string => "localhost"; "userlist" slist => ldaplist( "ldap://$(domain_controller)", "CN=Users,DC=$(domain_name),DC=com", "(objectClass=user)", "sAMAccountName", "subtree", "none"); classes: dummy.DomainController:: "gotuser" expression => ldaparray( "userinfo", "ldap://$(domain_controller)", "CN=$(user_name),CN=Users,DC=$(domain_name),DC=com", "(name=*)", "subtree", "none"); reports: dummy.DomainController:: "Username is \"$(userlist)\""; dummy.gotuser:: "Got user data; $(userinfo[name]) has logged on $(userinfo[logonCount]) times"; } cfengine-3.2.4/examples/unit_returnszero.cf0000644000175000017500000000243711707771422016026 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "main" }; } bundle agent main { classes: "testclass1" expression => returnszero("/bin/true","noshell"); "testclass2" expression => returnszero("/bin/false","noshell"); reports: testclass1:: "true is defined"; testclass2:: "false is defined"; } cfengine-3.2.4/examples/unit_regarray.cf0000644000175000017500000000262611707771422015240 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "testbundle" }; } ########################################### bundle agent testbundle { vars: "myarray[0]" string => "bla1"; "myarray[1]" string => "bla2"; "myarray[3]" string => "bla"; "myarray" string => "345"; "not" string => "345"; classes: "ok" expression => regarray("myarray","b.*2"); reports: ok:: "Found in list"; !ok:: "Not found in list"; } cfengine-3.2.4/examples/unit_control_expand.cf0000644000175000017500000000350111715232734016431 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. bundle common g { classes: "softclass" expression => "any"; vars: "bundle" slist => { "bundle1", "bundle2", @(extra) }; any:: # default extra "extra" slist => { "bundle3" }, policy => "overridable"; softclass:: "extra" slist => { "bundle3", "bundle4" }, policy => "overridable"; } ############################################################## body common control { # inputs => { @(g.bundle) }; bundlesequence => { @(g.bundle) }; } ############################################################## bundle agent bundle1 { vars: "var1" string => "anything"; } bundle agent bundle2 { classes: "ok" expression => isvariable("bundle1.var1"); reports: ok:: "Success"; } bundle agent bundle3 { reports: linux:: "Success extra..."; } bundle agent bundle4 { reports: linux:: "Success extra more..."; }cfengine-3.2.4/examples/unit_classmatch.cf0000644000175000017500000000234211707771422015541 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "do_it" and => { classmatch(".*_3"), "linux" }; reports: do_it:: "Host matches pattern"; } cfengine-3.2.4/examples/unit_webserver.cf0000644000175000017500000000634711707771422015434 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Apache 2 reconfig - modelled on SuSE # ####################################################### body common control { any:: bundlesequence => { apache }; } ####################################################### bundle agent apache { files: "/home/mark/tmp/apache2" # "/etc/sysconfig/apache2" edit_line => fixapache; } ####################################################### # For the library ####################################################### bundle edit_line fixapache { # Values have the form NAME = "quoted space separated list" vars: "add_modules" slist => { "dav", "dav_fs", "ssl", "php5", "dav_svn", "xyz", "superduper" }; "del_modules" slist => { "php3", "jk", "userdir", "imagemap", "alias" }; insert_lines: "APACHE_CONF_INCLUDE_FILES=\"/site/masterfiles/local-http.conf\""; field_edits: ##################################################################### # APACHE_MODULES="authz_host actions alias auth_basic dav dav_fs imagemap ssl php5 dav_svn authz_default jk" ##################################################################### "APACHE_MODULES=.*" # Insert module "columns" between the quoted RHS # using space separators edit_field => quotedvar("$(add_modules)","append"); "APACHE_MODULES=.*" # Delte module "columns" between the quoted RHS # using space separators edit_field => quotedvar("$(del_modules)","delete"); # if this line already exists, edit it } ######################################## # Bodies ######################################## body edit_field quotedvar(newval,method) { field_separator => "\""; select_field => "2"; value_separator => " "; field_value => "$(newval)"; field_operation => "$(method)"; extend_fields => "false"; allow_blank_fields => "true"; } cfengine-3.2.4/examples/unit_compare.cf0000644000175000017500000000254111707771422015046 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Testing some variable/class definitions - note scope # # Use browser -f promise_output_agent.html to view # body common control { bundlesequence => { "test" }; } ########################################################### bundle agent test { classes: "ok" expression => isgreaterthan("1","0"); reports: ok:: "Assertion is true"; !ok:: "Assertion is false"; } cfengine-3.2.4/examples/unit_services_win.cf0000644000175000017500000000251311707771422016117 00000000000000######################################################################### # # win_services.cf - Windows Service Management # ######################################################################### bundle agent win_services { vars: # NOTE: Use "Service Name" (not "Display Name"); # Administrative Tools -> Services -> Double Click on one to see its name "bad_services" slist => { "RemoteRegistry" }; Windows_Server_2003_R2:: "autostart_services" slist => { "Alerter", "W32Time" # Windows Time }; Windows_Server_2008:: "autostart_services" slist => { "MpsSvc", # Windows Firewall "W32Time" # Windows Time }; services: "$(bad_services)" service_policy => "disable", service_method => force_deps, comment => "Disable services that create security issues"; Windows_Server_2003_R2|Windows_Server_2008:: "$(autostart_services)" service_policy => "start", service_method => bootstart, comment => "Make sure important services are running and set to start at boot time"; } cfengine-3.2.4/examples/unit_setvar.cf0000644000175000017500000000326411707771422014727 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "setvars" }; inputs => { "cfengine_stdlib.cf" }; } bundle agent setvars { vars: # want to set these values by the names of their array keys "rhs[lhs1]" string => " Mary had a little pig"; "rhs[lhs2]" string => "Whose Fleece was white as snow"; "rhs[lhs3]" string => "And everywhere that Mary went"; "rhs[net/ipv4/tcp_syncookies]" string => "1"; "rhs[net/ipv4/icmp_echo_ignore_broadcasts]" string => "1"; "rhs[net/ipv4/ip_forward]" string => "0"; # oops, now change pig -> lamb files: "/tmp/system" comment => "Create a file of variable assignments and manage this file", create => "true", edit_line => set_variable_values("setvars.rhs"); } cfengine-3.2.4/examples/unit_createdb.cf0000644000175000017500000000227311707771422015173 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "dummy" }; } body knowledge control { #sql_database => "postgres"; sql_owner => "postgres"; sql_passwd => ""; # No passwd sql_type => "postgres"; } bundle knowledge dummy { topics: }cfengine-3.2.4/examples/unit_getindices_and_values.cf0000644000175000017500000000262611707771422017743 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { any:: bundlesequence => { "testsetvar" }; } ####################################################### bundle agent testsetvar { vars: "v[index_1]" string => "value_1"; "v[index_2]" string => "value_2"; "x" slist => getindices("v"); "y" slist => getvalues("v"); reports: cfengine_3:: "All indices:"; " Found index: $(x) with value \"$(v[$(x)])\""; "All values:"; " Found value: $(y)"; } cfengine-3.2.4/examples/unit_package_solaris.cf0000644000175000017500000000323211707771422016545 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Package managment # body common control { bundlesequence => { "packages" }; inputs => { "cfengine_stdlb.cf" }; } ############################################# bundle agent packages { vars: "solaris_packages[SMCzlib]" string => "zlib-1.2.3-sol10-sparc-local"; "admin_file" string => "cfengine_admin_file"; "package_names" slist => getindices("solaris_packages"); files: "/tmp/$(admin_file)" create => "true", edit_defaults => empty_file, edit_line => create_solaris_admin_file; packages: "$(package_names)" package_policy => "add", package_method => solaris("$(package_names)", "$(solaris_packages[$(package_names)])", "$(admin_file)"); } cfengine-3.2.4/examples/unit_select_size.cf0000644000175000017500000000271011707771422015727 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "test" }; } # bundle agent test { files: # Show files in range "/home/mark/tmp" file_select => name_and_sizes(".*cf","100","300"), depth_search => recurse("1"), transformer => "/bin/ls -l $(this.promiser)"; } # body file_select name_and_sizes(n,x,y) { leaf_name => { "$(n)" }; search_size => irange("$(x)", "$(y)"); file_result => "leaf_name&size"; } body depth_search recurse(x) { depth => "$(x)"; } cfengine-3.2.4/examples/unit_process_restart_basic.cf0000644000175000017500000000235111707771422020002 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "process_restart" }; } ######################################################### bundle agent process_restart { processes: "/usr/bin/daemon" restart_class => "launch"; commands: launch:: "/usr/bin/daemon"; } cfengine-3.2.4/examples/unit_edit_sectioned_file.cf0000644000175000017500000000530411715232734017376 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test editfile # ######################################################## # # This assumes a file format like: # # [section 1] # # lines.... # # [section 2] # # lines... etc body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { vars: "v1" string => "numerical backreference"; files: "/home/mark/tmp/cf3_test" create => "true", edit_line => AppendIfNoLine("cfengine tcp 5308","second"); } ######################################################## bundle edit_line AppendIfNoLine(parameter,two) { vars: "list" slist => { "1", "2", "3" }; insert_lines: "$(parameter) and $(two)-$(list)" location => "append"; "NEW Special-insert!!!" select_region => MySection("New section"); "set variable = value" select_region => MySection("New section"); "/home/mark/tmp/insert" insert_type => "file", expand_scalars => "true", select_region => MySection("New section"); delete_lines: # "l.*"; # "NEW.*" select_region => MySection("New section"); # Delete LinesStarting in file } ######################################################## body location append { # If not line to match, applies to whole text body before_after => "after"; } ######################################################## body location after(x) { # If not line to match, applies to whole text body #select_line_matching => "$(x)"; before_after => "after"; } ######################################################## body select_region MySection(x) { select_start => "\[$(x)\]"; select_end => "\[.*\]"; } cfengine-3.2.4/examples/unit_environment.cf0000644000175000017500000000416711707771422015772 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Virtual environments # ####################################################### body common control { bundlesequence => { "my_vm_cloud" }; } ####################################################### bundle agent my_vm_cloud { vars: "vms[atlas]" slist => { "guest1", "guest2", "guest3" }; environments: scope||any:: # These should probably be in class "any" to ensure uniqueness "$(vms[$(sys.host)])" environment_resources => virt_xml("$(xmlfile[$(this.promiser)])"), environment_interface => vnet("eth0,192.168.1.100/24"), environment_type => "test", environment_host => "atlas"; # default environment_state => "create" on host, and "suspended elsewhere" } ####################################################### body environment_resources virt_xml(specfile) { env_spec_file => "$(specfile)"; } ####################################################### body environment_interface vnet(primary) { env_name => "$(this.promiser)"; env_addresses => { "$(primary)" }; host1:: env_network => "default_vnet1"; host2:: env_network => "default_vnet2"; }cfengine-3.2.4/examples/unit_deletelines.cf0000644000175000017500000000377111707771422015723 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "test" }; } bundle agent test { files: "/tmp/resolv.conf" # test on "/tmp/resolv.conf" # create => "true", edit_line => resolver, edit_defaults => def; } ####################################################### # For the library ####################################################### bundle edit_line resolver { vars: "search" slist => { "search iu.hio.no cfengine.com", "nameserver 128.39.89.10" }; delete_lines: "search.*"; insert_lines: "$(search)" location => end; } ####################################################### body edit_defaults def { empty_file_before_editing => "false"; edit_backup => "false"; max_file_size => "100000"; } ######################################################## body location start { # If not line to match, applies to whole text body before_after => "before"; } ######################################################## body location end { # If not line to match, applies to whole text body before_after => "after"; } cfengine-3.2.4/examples/unit_global_list_expansion.cf0000644000175000017500000000301511707771422017774 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Show access of external lists. # # - to pass lists globally, use a parameter to dereference them # body common control { bundlesequence => { hardening(@(va.tmpdirs)) }; } ######################################################### bundle common va { vars: "tmpdirs" slist => { "/tmp", "/var/tmp", "/usr/tmp" }; } ########################################################## bundle agent hardening(x) { classes: "ok" expression => "any"; vars: "other" slist => { "/tmp", "/var/tmp" }; reports: ok:: "Do $(x)"; "Other: $(other)"; } cfengine-3.2.4/examples/unit_package_rpm.cf0000644000175000017500000000456611707771422015702 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Package managment # body common control { bundlesequence => { "packages" }; } ############################################# bundle agent packages { vars: "exact_package" slist => { "apache2", "kernel-default" }; "version[OpenOffice_org-hyphen]" string => "1.2.3"; "version[kernel-default]" string => "2.6.27.7-9.1"; packages: "$(exact_package)" package_policy => "verify", package_method => rpm, package_select => ">=", package_architectures => { "x86_64" }, package_version => "$(version[$(exact_package)])"; } ############################################# body package_method rpm { any:: package_changes => "individual"; package_list_command => "/bin/rpm -qa --queryformat \"i | repos | %{name} | %{version}-%{release} | %{arch}\n\""; # Remember to escape special characters like | package_list_name_regex => "[^|]+\|[^|]+\|\s+([^\s|]+).*"; package_list_version_regex => "[^|]+\|[^|]+\|[^|]+\|\s+([^\s|]+).*"; package_list_arch_regex => "[^|]+\|[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_installed_regex => "i.*"; package_name_convention => "$(name).$(arch)"; package_add_command => "/bin echo /bin/rpm -i "; package_delete_command => "/bin/rpm -e --nodeps"; package_verify_command => "/bin/rpm -V"; package_noverify_regex => ".*[^\s].*"; #package_noverify_returncode => "-1"; } cfengine-3.2.4/examples/unit_hashmatch.cf0000644000175000017500000000242211707771422015356 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "matches" expression => hashmatch("/etc/passwd","md5","c5068b7c2b1707f8939b283a2758a691"); reports: matches:: "File has correct version"; } cfengine-3.2.4/examples/unit_create_filedir.cf0000644000175000017500000000311511707771422016357 00000000000000# Copyright (C) CFEngine AS # This file is part of CFEngine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of CFEngine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test create files # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/home/mark/tmp/test_plain" perms => system, create => "true"; "/home/mark/tmp/test_dir/." perms => system, create => "true"; } ######################################################### body perms system { mode => "0640"; } ######################################################### cfengine-3.2.4/examples/unit_reglist.cf0000644000175000017500000000250211707771422015066 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "testbundle" }; } ########################################### bundle agent testbundle { vars: "userlist" slist => { "xyz", "mark", "jeang", "jonhenrik", "thomas", "eben" }; classes: "ok" expression => reglist("@(userlist)","j.*"); reports: ok:: "Found in list"; !ok:: "Not found in list"; } cfengine-3.2.4/examples/unit_helloworld.cf0000644000175000017500000000215711707771422015576 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # Hard promises body common control { bundlesequence => { "hello" }; } # soft promises bundle agent hello { reports: linux:: "Hello world!"; }cfengine-3.2.4/examples/unit_accessed_before.cf0000644000175000017500000000251611707771422016516 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Show the definition of classes by comparing timestamps # body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "do_it" and => { accessedbefore("/tmp/earlier","/tmp/later") }; reports: do_it:: "The earlier file has been accessed before the later"; } cfengine-3.2.4/examples/unit_package_zypper.cf0000644000175000017500000000305011707771422016420 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Package managment # body common control { bundlesequence => { "packages" }; inputs => { "cfengine_stdlib.cf" } } ############################################# bundle agent packages { vars: # Test the simplest case -- leave everything to the zypper smart manager "match_package" slist => { "apache2", "apache2-mod_php5", "apache2-prefork", "php5" }; packages: "$(match_package)" package_policy => "add", package_method => zypper; } cfengine-3.2.4/examples/unit_multipassvars.cf0000644000175000017500000000225711707771422016341 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "test" }; } bundle agent test { vars: any:: "tempdir" string => execresult("/bin/mktemp -d", "noshell"); reports: linux:: "tempdir: ${tempdir}"; }cfengine-3.2.4/examples/unit_acl.cf0000644000175000017500000000332711707771422014162 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "acls" }; } ######################################### bundle agent acls { files: "/media/flash/acl/test_dir" depth_search => include_base, acl => template; } ######################################### body acl template { acl_method => "overwrite"; acl_type => "posix"; acl_directory_inherit => "parent"; aces => { "user:*:r(wwx),-r:allow", "group:*:+rw:allow", "mask:x:allow", "all:r"}; } ######################################### body acl win { acl_method => "overwrite"; acl_type => "ntfs"; acl_directory_inherit => "nochange"; aces => { "user:Administrator:rw", "group:Bad:rwx(Dpo):deny" }; } ######################################### body depth_search include_base { include_basedir => "true"; } cfengine-3.2.4/examples/unit_environment_simple.cf0000644000175000017500000000320711707771422017335 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Virtual environments # ####################################################### body common control { bundlesequence => { "my_vm_cloud" }; } ####################################################### bundle agent my_vm_cloud { environments: "centos5" environment_resources => virt_xml, environment_type => "xen", environment_host => "ursa-minor"; # default environment_state => "create" on host, and "suspended elsewhere" } ####################################################### body environment_resources virt_xml { env_spec_file => "/srv/xen/centos5-libvirt-create.xml"; } cfengine-3.2.4/examples/unit_parallel_exec.cf0000644000175000017500000000321011707771422016212 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple backgrounding - try this with background = true and false # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## body agent control { agentaccess => { "mark", "root" }; } ######################################################## bundle agent testbundle { commands: "/bin/sleep 10" action => background; "/bin/sleep" args => "20", action => background; } ######################################################### body action background { background => "true"; } cfengine-3.2.4/examples/unit_varexpansion.cf0000644000175000017500000000263411707771422016140 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "scalar1" string => "SCALAR 1"; "list1" slist => { "LIST1_1", "LIST1_2" } ; "array[1]" string => "ARRAY 1"; "array[2]" string => "ARRAY 2"; "i" slist => getindices("array"); reports: cfengine_3:: "Scalar $(scalar1)"; "LIst $(list1)"; "Array $(array[$(i)])"; } cfengine-3.2.4/examples/unit_userexists.cf0000644000175000017500000000245411707771422015641 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "ok" expression => userexists("root"); reports: ok:: "Root exists"; !ok:: "Root does not exist"; } ########################################################### cfengine-3.2.4/examples/unit_copy.cf0000644000175000017500000000243211707771422014371 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "copy" }; } bundle agent copy { files: "/tmp/testfile1-cop" copy_from => mycopy("/tmp/testfile1", "gudea"); "/tmp/testfile2-cop" copy_from => mycopy("/tmp/testfile2", "gudea"); } body copy_from mycopy(from,server) { source => "$(from)"; #servers => { "$(server)" }; } cfengine-3.2.4/examples/unit_reg_multiline.cf0000644000175000017500000000130211707771422016251 00000000000000############################################# # Matching multiple lines in regexp (PCRE) ############################################## body common control { bundlesequence => { "test" }; } bundle agent test { vars: "data" string => "Something boring is written up here. This is the interesting part: KWYDK (know what you don't know)"; classes: # note the (?s) at the beginning of the pattern - this ensures newlines are matched by . "matched" expression => regextract("(?s).*: (.*)", "$(data)", "interesting"); reports: matched:: "This is interesting: \"$(interesting[1])\""; !matched:: "Nothing was interesting!"; }cfengine-3.2.4/examples/win_schedule.cf0000644000175000017500000000376011707771422015036 00000000000000######################################################################### # # scheduling.cf - Command Execution Scheduling # # NOTE: Commands can be executed based on any class expression. # Examples include execution of other commands (sequencing), # time, OS, hostname or the outcome of another promise. # If a shell wrapper is not needed, removing it will increase # security and performance. # ######################################################################### bundle agent system_scheduling { vars: # Command definitions are given in cmd[index]. # The dependencies of the commands are dep_cmd[index], as boolean class expressions. # Comments are given as comment_cmd[index] "cmd[1]" string => "$(sys.cf_key)"; "dep_cmd[1]" string => "cmd2_success"; "comment_cmd[1]" string => "Check that a Cfengine key is generated if command 2 has run (dummy)"; windows:: "cmd[2]" string => "\"$(sys.winsysdir)\shutdown.exe\" /r /c \"Cfengine automatic restart\" /t 120"; "dep_cmd[2]" string => "Monday.Hr05.Min00_05"; "comment_cmd[2]" string => "Restart windows every week"; "cmd[3]" string => "$(sys.winsysdir)\cscript.exe \"$(sys.workdir)\script1.vbs\" //Nologo > \"$(sys.workdir)\script1_out.txt\""; "dep_cmd[3]" string => "Hr05.Min05_10"; "comment_cmd[3]" string => "Run a script and save its output for later reference (needs to be run in shell)"; !windows:: "cmd[2]" string => "/bin/echo Hello World!"; "dep_cmd[2]" string => "Hr12.Min00_05"; "comment_cmd[2]" string => "Print a message (dummy)"; any:: "cmd_index" slist => getindices("cmd"); commands: # Runs a command if its dependencies are satisfied "$(cmd[$(cmd_index)])" classes => if_repaired("cmd$(cmd_index)_success"), ifvarclass => "$(dep_cmd[$(cmd_index)])", contain => in_shell, comment => "$(comment_cmd[$(cmd_index)])"; } cfengine-3.2.4/examples/unit_regextract.cf0000644000175000017500000000115711707771422015572 00000000000000###################################################################### # Function regline(regex,file) ###################################################################### body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { classes: # Extract regular backreferences and put them in an array "ok" expression => regextract("xx ([^\s]+) ([^\s]+).* xx","xx one two three four xx","myarray"); reports: ok:: "ok - \"$(myarray[0])\" = xx + \"$(myarray[1])\" + \"$(myarray[2])\" + .. + xx"; } cfengine-3.2.4/examples/unit_badpromise.cf0000644000175000017500000000234211715232734015541 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { dummy: "help" -> "me"; reports: same:: "Strings are equal"; !same:: "Strings are not equal"; } cfengine-3.2.4/examples/unit_exec_in_sequence.cf0000644000175000017500000000360311707771422016722 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test execution # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { vars: "size" int => "46k"; "rand" int => randomint("33","$(size)"); commands: "/bin/echo" args => "Hello world - $(size)/$(rand)", contain => standard, classes => cdefine("followup","alert"); followup:: "/bin/ls" contain => standard; reports: alert:: "What happened?"; } ###################################################################### body contain standard { exec_owner => "mark"; useshell => "true"; } ###################################################################### body classes cdefine(class,alert) { promise_repaired => { "$(class)" }; repair_failed => { "$(alert)" }; }cfengine-3.2.4/examples/unit_join.cf0000644000175000017500000000271711707771422014364 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # join function to concat a list # ####################################################### body common control { any:: bundlesequence => { test }; } ####################################################### bundle agent test { vars: "mylist" slist => { "one", "two", "three", "four", "five" }; "scalar" string => join("<->","mylist"); reports: linux:: "Concatenated $(scalar)"; } cfengine-3.2.4/examples/unit_method_var.cf0000644000175000017500000000141511707771422015547 00000000000000# # Demonstrates the use of variables to call bundles. # We can then filter variables on classes, for example. # body common control { bundlesequence => { "test" }; } ########################################### bundle agent test { vars: "run_bundles" slist => { "test_one", "test_two" }; "run_a_bundle" string => "test_three"; methods: "any" usebundle => "$(run_bundles)"; "any" usebundle => "$(run_a_bundle)"; } ########################################### bundle agent test_one { reports: cfengine_3:: "in test_one"; } ########################################### bundle agent test_two { reports: cfengine_3:: "in test_two"; } ########################################### bundle agent test_three { reports: cfengine_3:: "in test_three"; } cfengine-3.2.4/examples/unit_rename.cf0000644000175000017500000000221611707771422014666 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => {"test"}; } bundle agent test { files: "/tmp/foo" rename => moveit; } body rename moveit { newname => "/tmp/foo_moved"; }cfengine-3.2.4/examples/unit_arrays.cf0000644000175000017500000000243011707771422014716 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "array" }; } bundle common g { vars: "array[1]" string => "one"; "array[2]" string => "two"; } bundle agent array { vars: "localarray[1]" string => "one"; "localarray[2]" string => "two"; reports: linux:: "Global $(g.array[1]) and $(localarray[2])"; } cfengine-3.2.4/examples/unit_env.cf0000644000175000017500000000026511707771422014211 00000000000000 body common control { bundlesequence => { "one" }; } body agent control { environment => { "A=123", "B=456", "PGK_PATH=/tmp"}; } bundle agent one { commands: "/usr/bin/env"; }cfengine-3.2.4/examples/unit_copy_edit.cf0000644000175000017500000000513211707771422015376 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Copy and edit convergently # ######################################################## body common control { bundlesequence => { "testbundle" }; version => "1.2.3"; } ######################################################## bundle agent testbundle { vars: "source" string => "/tmp"; "dest" string => "/tmp"; files: "/$(dest)/staging-file" comment => "Copy from source to buffer", copy_from => cp("$(source)/source-template"), classes => satisfied("copy_ok"); copy_ok:: "/$(dest)/final-file" comment => "Build a file template and expand keys", edit_line => myedits("/$(dest)/staging-file"), edit_defaults => empty; } ######################################################### body copy_from cp(from) { source => "$(from)"; compare => "mtime"; type_check => "true"; } ######################################################## bundle edit_line myedits(f) { insert_lines: "$(f)" comment => "Populate empty file", insert_type => "file"; replace_patterns: "TEMPLATE_HOST_KEY" comment => "Replace a place-marker with the name of this host", replace_with => rp("$(sys.host)"); } ######################################################## body replace_with rp(x) { replace_value => "$(x)"; occurrences => "all"; } ######################################################### body classes satisfied(x) { promise_repaired => { "$(x)" }; persist_time => "0"; } ####################################################### body edit_defaults empty { empty_file_before_editing => "true"; }cfengine-3.2.4/examples/unit_update.cf0000644000175000017500000000634511715232734014705 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. #cop update,example #cop What should a failsafe and update file contain?,example # Minimum failsafe body common control { bundlesequence => { "update" }; } bundle agent update { vars: "master_location" string => "$(sys.workdir)/masterfiles"; "policy_server" string => readfile("$(sys.workdir)/policy_server.dat",40), comment => "IP address to locate your policy host."; classes: "policy_host" or => { classmatch(canonify("ipv4_$(policy_server)")), classmatch(canonify("$(policy_server)")) }, comment => "Define the ip identity of the policy source host"; "have_ppkeys" expression => fileexists("$(sys.workdir)/ppkeys/localhost.pub"); "nofile" expression => fileexists("$(sys.workdir)/policy_server.dat"); commands: !have_ppkeys:: "/usr/local/sbin/cf-key"; files: "/var/cfengine/inputs" handle => "update_policy", perms => u_p("600"), copy_from => u_scp("$(master_location)"), depth_search => u_recurse("inf"), action => immediate; "/var/cfengine/bin" perms => u_p("700"), copy_from => u_scp("/usr/local/sbin"), depth_search => u_recurse("inf"), action => immediate; processes: any:: "cf-execd" restart_class => "start_exec"; policy_host:: "cf-serverd" restart_class => "start_server"; commands: start_exec:: "$(sys.workdir)/bin/cf-execd", action => logme("executor"); start_server:: "$(sys.workdir)/bin/cf-serverd", action => logme("server"); reports: bootstrap_mode.policy_host:: "I am the policy host - i.e. with ipv4 address $(policy_server)"; } ############################################ body action logme(x) { log_repaired => "stdout"; logstring => " -> Started the $(x) (success)"; } ############################################ body perms u_p(p) { mode => "$(p)"; } ############################################# body copy_from u_scp(from) { source => "$(from)"; compare => "digest"; trustkey => "true"; !policy_host:: servers => { "$(policy_server)" }; } ######################################################### body action immediate { ifelapsed => "1"; } ############################################ body depth_search u_recurse(d) { depth => "$(d)"; } cfengine-3.2.4/examples/unit_test_environment.cf0000644000175000017500000000533611707771422017030 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Virtual environments # ####################################################### body common control { bundlesequence => { "my_vm_cloud" }; } ####################################################### bundle agent my_vm_cloud { environments: scope||any:: # These should probably be in class "any" to ensure uniqueness "test2" environment_resources => my_environment, environment_interface => vnet("eth0,192.168.1.100/24"), environment_type => "test", environment_state => "create", environment_host => "atlas"; "test2" environment_resources => my_environment, environment_interface => vnet("eth0,192.168.1.101/24"), environment_type => "test", environment_state => "delete", environment_host => "atlas"; "test4" environment_resources => my_environment, environment_interface => vnet("eth0,192.168.1.102/24"), environment_type => "test", environment_state => "create", environment_host => "atlas"; "network1" environment_type => "test_net", environment_state => "create", environment_host => "atlas"; # default environment_state => "create" on host, and "suspended elsewhere" } ####################################################### body environment_resources my_environment { env_cpus => "2"; env_memory => "512"; # in KB env_disk => "1024"; # in MB } ####################################################### body environment_interface vnet(primary) { env_name => "$(this.promiser)"; env_addresses => { "$(primary)" }; host1:: env_network => "default_vnet1"; host2:: env_network => "default_vnet2"; }cfengine-3.2.4/examples/unit_package_yum.cf0000644000175000017500000000304211707771422015702 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Package managment # body common control { bundlesequence => { "packages" }; inputs => { "cfengine_stdlib.cf" } } ############################################# bundle agent packages { vars: # Test the simplest case -- leave everything to the yum smart manager "match_package" slist => { "apache2", "apache2-mod_php5", "apache2-prefork", "php5" }; packages: "$(match_package)" package_policy => "add", package_method => yum; } cfengine-3.2.4/examples/unit_hashcomment.cf0000644000175000017500000000351311707771422015726 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ###################################################################### # # Comment lines # ###################################################################### body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/home/mark/tmp/comment_test" create => "true", edit_line => comment_lines_matching; } ######################################################## bundle edit_line comment_lines_matching { vars: "regexes" slist => { "one.*", "two.*", "four.*" }; replace_patterns: "^($(regexes))$" replace_with => comment("# "); } ######################################## # Bodies ######################################## body replace_with comment(c) { replace_value => "$(c) $(match.1)"; occurrences => "all"; } cfengine-3.2.4/examples/unit_countlinesmatching.cf0000644000175000017500000000235611707771422017322 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "no" int => countlinesmatching("m.*","/etc/passwd"); reports: cfengine_3:: "Found $(no) lines matching"; } cfengine-3.2.4/examples/unit_bsdflags.cf0000644000175000017500000000232111707771422015201 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "test" }; } bundle agent test { files: freebsd:: "/tmp/newfile" create => "true", perms => setbsd; } body perms setbsd { bsdflags => { "+uappnd","+uchg", "+uunlnk", "-nodump" }; } cfengine-3.2.4/examples/unit_exec_args.cf0000644000175000017500000000250111707771422015354 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Test the symmetry between using / not using args => # Locks should prevent these from being run twice, all else being equal. # body common control { bundlesequence => { "main" }; } bundle agent main { vars: "testlist" slist => { "apple", "banana", "carrot" }; commands: "/bin/echo test1 $(testlist)"; "/bin/echo test1" args => "$(testlist)"; } cfengine-3.2.4/examples/unit_edit_setvar.cf0000644000175000017500000000350311707771422015730 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Edit variable = value in a text file # ####################################################### body common control { any:: bundlesequence => { "testsetvar" }; } ####################################################### bundle agent testsetvar { vars: "v[variable_1]" string => "value_1"; "v[variable_2]" string => "value_2"; files: "/tmp/test_setvar" edit_line => setvars_v1("testsetvar.v"); } ####################################################### # For the library ####################################################### bundle edit_line setvars_v1(contexted_array_name) { vars: "parameter_name" slist => getindices("$(contexted_array_name)"); delete_lines: "$(parameter_name).*"; insert_lines: "$(parameter_name) = $($(contexted_array_name)[$(parameter_name)])"; } cfengine-3.2.4/examples/Makefile.am0000644000175000017500000000025111707771422014077 00000000000000SUBDIRS = example_config DIST_SUBDIRS = example_config examplesdir = @docdir@/examples dist_examples_DATA = $(srcdir)/*.cf MAINTAINERCLEANFILES = Makefile.in mdate-sh cfengine-3.2.4/examples/unit_service_disable.cf0000644000175000017500000000244211707771422016543 00000000000000# This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "winservice" }; } ########################################################### bundle agent winservice { vars: "bad_services" slist => { "Alerter", "ClipSrv" }; services: windows:: "$(bad_services)" service_policy => "disable", comment => "Disable services that create security issues"; } cfengine-3.2.4/examples/unit_filesexist2.cf0000644000175000017500000000264311707771422015664 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "mylist" slist => { "/tmp/a", "/tmp/b", "/tmp/c" }; methods: "any" usebundle => crystal_meth(@(example.mylist)); } bundle agent crystal_meth(x) { classes: "exists" expression => filesexist("@(x)"); reports: exists:: "File does exist"; !exists:: "Does not yet exist"; } cfengine-3.2.4/examples/unit_acl_generic.cf0000644000175000017500000000264511707771422015660 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "acls" }; } ######################################### bundle agent acls { files: "/media/flash/acl/test_dir" depth_search => include_base, acl => test; } ######################################### body acl test { acl_type => "generic"; aces => {"user:bob:rwx", "group:staff:rx", "all:r"}; } ######################################### body depth_search include_base { include_basedir => "true"; } cfengine-3.2.4/examples/unit_badtype.cf0000644000175000017500000000207711715232734015051 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. bundle agent test { report: # type report is a typo.... linux:: "Goodbye cruel world..."; }cfengine-3.2.4/examples/unit_module_exec.cf0000644000175000017500000000254011707771422015710 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Test module execution as class function # body common control { any:: bundlesequence => { test }; } ################################################################### bundle agent test { classes: "done" or => { usemodule("module:getusers","") }; commands: "/bin/echo promiser text" args => "test $(user)"; } cfengine-3.2.4/examples/unit_regex_win.cf0000644000175000017500000000105711707771422015410 00000000000000###################################################################### # Using path regular expressions on Windows (always forward slash) ###################################################################### body common control { bundlesequence => { "test" }; } ######################################################## bundle agent test { files: "c:/test/.*.xml" edit_line => add_information(); } ######################################################## bundle edit_line add_information() { insert_lines: "a line", comment => "adding line"; } cfengine-3.2.4/examples/unit_dollar.cf0000644000175000017500000000244611707771422014701 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "some" expression => "any"; reports: some:: "The value of $(const.dollar)(const.dollar) is $(const.dollar)"; "But the value of \$(dollar) is \$(dollar)"; } cfengine-3.2.4/examples/unit_hashuncomment.cf0000644000175000017500000000347011707771422016273 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ###################################################################### # # Uncomment lines # ###################################################################### body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } # try this on some test data like # one # two # mark one #mark two ######################################################## bundle agent testbundle { files: "/home/mark/tmp/comment_test" create => "true", edit_line => uncomment_lines_matching("\s*mark.*","#"); } ######################################################## bundle edit_line uncomment_lines_matching(regex,comment) { replace_patterns: "#($(regex))$" replace_with => uncomment; } ######################################################## body replace_with uncomment { replace_value => "$(match.1)"; occurrences => "all"; } cfengine-3.2.4/examples/unit_registry.cf0000644000175000017500000000420111707771422015263 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "databases" }; } bundle agent databases { databases: windows:: # Regsitry has (value,data) pairs in "keys" which are directories # "HKEY_LOCAL_MACHINE\SOFTWARE\Cfengine AS" # database_operation => "create", # database_type => "ms_registry"; # "HKEY_LOCAL_MACHINE\SOFTWARE\Cfengine AS\Cfengine" # database_operation => "create", # database_rows => { "value1,REG_SZ,new value 1", "value2,REG_SZ,new val 2"} , # database_type => "ms_registry"; "HKEY_LOCAL_MACHINE\SOFTWARE\Cfengine AS\Cfengine" database_operation => "delete", database_columns => { "value1", "value2" } , database_type => "ms_registry"; # "HKEY_LOCAL_MACHINE\SOFTWARE\Cfengine AS\Cfengine" # database_operation => "cache", # cache,restore # registry_exclude => { ".*Windows.*CurrentVersion.*", ".*Touchpad.*", ".*Capabilities.FileAssociations.*", ".*Rfc1766.*" , ".*Synaptics.SynTP.*", ".*SupportedDevices.*8086", ".*Microsoft.*ErrorThresholds" }, # database_type => "ms_registry"; "HKEY_LOCAL_MACHINE\SOFTWARE\Cfengine AS" database_operation => "restore", database_type => "ms_registry"; } cfengine-3.2.4/examples/unit_hostsseen.cf0000644000175000017500000000225611707771422015436 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "test" }; } bundle agent test { vars: "myhosts" slist => { hostsseen("inf","lastseen","address") }; reports: cfengine_3:: "Found client/peer: $(myhosts)"; }cfengine-3.2.4/examples/unit_lsdir.cf0000644000175000017500000000231711707771422014536 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "ls" slist => lsdir("/etc","p.*","true"); reports: !sdfkjh:: "ls: $(ls)"; } cfengine-3.2.4/examples/unit_getgid.cf0000644000175000017500000000231411707771422014661 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "gid" int => getgid("users"); reports: Yr2008:: "Users gid is $(gid)"; } cfengine-3.2.4/examples/unit_postfix.cf0000644000175000017500000000607011707771422015115 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Postfix # ####################################################### body common control { any:: bundlesequence => { postfix }; } ####################################################### bundle agent postfix { vars: "prefix" string => "/home/mark/tmp"; "smtpserver" string => "mailx.domain.tld"; "mailrelay" string => "mailx.domain.tld"; files: "$(prefix)/main.cf" edit_line => prefix_postfix; "$(prefix)/sasl-passwd" create => "true", perms => system("0600","root"), edit_line => AppendIfNSL("$(smtpserver) _$(fqhost):chmsxrcynz4etzefabj9frejizhs22"); } ####################################################### # For the library ####################################################### bundle edit_line prefix_postfix { # # Value have the form NAME = "quoted space separated list" # vars: "ps[relayhost]" string => "[$(postfix.mailrelay)]:587"; "ps[mydomain]" string => "iu.hio.no"; "ps[smtp_sasl_auth_enable]" string => "yes"; "ps[smtp_sasl_password_maps]" string => "hash:/etc/postfix/sasl-passwd"; "ps[smtp_sasl_security_options]" string => ""; "ps[smtp_use_tls]" string => "yes"; "ps[default_privs]" string => "mailman"; "ps[inet_protocols]" string => "all"; "ps[inet_interfaces]" string => "127.0.0.1"; "parameter_name" slist => getindices("ps"); delete_lines: "$(parameter_name).*"; insert_lines: "$(parameter_name) = $(ps[$(parameter_name)])"; } ######################################################## bundle edit_line AppendIfNSL(parameter) { insert_lines: "$(parameter)"; # This is default } ######################################## # Library Bodies ######################################## body replace_with All(x) { replace_value => "$(x)"; occurrences => "all"; } ######################################################### body perms system(x,owner) { mode => "0640"; owners => { "$(owner)", "root" }; } cfengine-3.2.4/examples/unit_process_kill.cf0000644000175000017500000000214011707771422016104 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "test" }; } bundle agent test { processes: "sleep" signals => { "term", "kill" }; } cfengine-3.2.4/examples/unit_chdir.cf0000644000175000017500000000234711707771422014515 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### body contain cd(dir) { chdir => "${dir}"; useshell => "true"; } bundle agent example { commands: "/bin/pwd" contain => cd("/tmp"); } cfengine-3.2.4/examples/app_baseline.cf0000644000175000017500000000450011707771422015000 00000000000000# This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################################### # # app_baseline.cf - Verify Existence of Applications # # NOTE: Sometimes applications are not correctly installed even # though the native package manager reports them to be. # Cfengine can check for application-specific configuration # and act upon or report any anomalies. # ######################################################################### bundle agent app_baseline { methods: windows:: "any" usebundle => detect_adobereader; } ### bundle agent detect_adobereader { vars: windows:: "value1" string => registryvalue("HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\9.0\Installer", "ENU_GUID"); "value2" string => registryvalue("HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\9.0\Installer", "VersionMax"); "value3" string => registryvalue("HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\9.0\Installer", "VersionMin"); classes: windows:: "is_correct" and => { strcmp("$(value1)", "{AC76BA86-7AD7-1033-7B44-A93000000001}"), strcmp("$(value2)", "90003"), islessthan("$(value3)", "10001" ) }; reports: windows.!is_correct:: "Adobe Reader is not correctly deployed - got \"$(value1)\", \"$(value2)\", \"$(value3)\""; } cfengine-3.2.4/examples/unit_menu.cf0000644000175000017500000000411611707771422014364 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test copy from server connection to cfServer # ######################################################## # # run this as follows: # # cf-serverd -f runtest_1.cf [-d2] # cf-agent -f runtest_2.cf # # Notice that the same file configures all parts of cfengine ######################################################## body common control { bundlesequence => { "testbundle" }; version => "1.2.3"; } # cf-runagent -q bundle agent testbundle { files: } ######################################################### # Server config ######################################################### body server control { allowconnects => { "127.0.0.1" , "::1" }; allowallconnects => { "127.0.0.1" , "::1" }; trustkeysfrom => { "127.0.0.1" , "::1" }; allowusers => { "mark", "root" }; } ######################################################### bundle server access_rules() { access: "delta" resource_type => "query", admit => { "127.0.0.1" }; "full" resource_type => "query", admit => { "127.0.0.1" }; } cfengine-3.2.4/examples/unit_server_copy_purge.cf0000644000175000017500000000571611707771422017171 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test copy from server connection to cfServer # ######################################################## # # run this as follows: # # cf-serverd -f runtest_1.cf [-d2] # cf-agent -f runtest_2.cf # # Notice that the same file configures all parts of cfengine ######################################################## body common control { bundlesequence => { "testbundle" }; version => "1.2.3"; } ######################################################## bundle agent testbundle { files: "/home/mark/tmp/test_to" comment => "test copy promise", copy_from => mycopy("/home/mark/tmp/test_from","127.0.0.1"), perms => system, depth_search => recurse("inf"), classes => satisfied("copy_ok"); reports: copy_ok:: "Files were copied.."; } ######################################################### body perms system { mode => "0644"; } ######################################################### body depth_search recurse(d) { depth => "$(d)"; } ######################################################### body copy_from mycopy(from,server) { source => "$(from)"; servers => { "$(server)" }; compare => "digest"; verify => "true"; copy_backup => "true"; #/false/timestamp purge => "true"; type_check => "true"; force_ipv4 => "true"; trustkey => "true"; } ######################################################### body classes satisfied(x) { promise_repaired => { "$(x)" }; persist_time => "0"; } ######################################################### # Server config ######################################################### body server control { allowconnects => { "127.0.0.1" , "::1" }; allowallconnects => { "127.0.0.1" , "::1" }; trustkeysfrom => { "127.0.0.1" , "::1" }; } ######################################################### bundle server access_rules() { access: "/home/mark/tmp" admit => { "127.0.0.1" }; } cfengine-3.2.4/examples/unit_edit_insert_lines_silly.cf0000644000175000017500000000355711707771422020347 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Insert a number of lines # ####################################################### body common control { any:: bundlesequence => { "insert" }; } ####################################################### bundle agent insert { vars: "v" slist => { "One potato", "Two potato", "Three potatoe", "Four" }; files: "/tmp/test_insert" create => "true", edit_line => Insert("@(insert.v)"); # edit_defaults => empty; } ####################################################### # For the library ####################################################### bundle edit_line Insert(name) { insert_lines: "$(name)"; } ####################################################### body edit_defaults empty { empty_file_before_editing => "true"; }cfengine-3.2.4/examples/unit_measurements.cf0000644000175000017500000000735011707771422016133 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. #cop measurements,example ####################################################### # # Test file: # # First line # Blonk blonk bnklkygsuilnm # ####################################################### body common control { bundlesequence => { "report" }; } ####################################################### body monitor control { forgetrate => "0.7"; histograms => "true"; } ####################################################### bundle agent report { reports: cfengine_3:: " Free memory read at $(mon.av_free_memory_watch) cf_monitord read $(mon.value_monitor_self_watch) "; } ####################################################### bundle monitor watch { measurements: # Test 1 - extract string matching "/home/mark/tmp/testmeasure" handle => "blonk_watch", stream_type => "file", data_type => "string", history_type => "weekly", units => "blonks", match_value => find_blonks, action => sample_min("10"); # Test 2 - follow a special process over time # using cfengine's process cache to avoid resampling "/var/cfengine/state/cf_rootprocs" handle => "monitor_self_watch", stream_type => "file", data_type => "int", history_type => "static", units => "kB", match_value => proc_value(".*cf-monitord.*", "root\s+[0-9.]+\s+[0-9.]+\s+[0-9.]+\s+[0-9.]+\s+([0-9]+).*"); # Test 3, discover disk device information "/bin/df" handle => "free_disk_watch", stream_type => "pipe", data_type => "slist", history_type => "static", units => "device", match_value => file_system; # Update this as often as possible # Test 4 "/tmp/file" handle => "line_counter", stream_type => "file", data_type => "counter", match_value => scanlines("MYLINE.*"), history_type => "log"; } ########################################################## body match_value scanlines(x) { select_line_matching => "^$(x)$"; } ########################################################## body action sample_min(x) { ifelapsed => "$(x)"; expireafter => "$(x)"; } ########################################################## body match_value find_blonks { select_line_number => "2"; extraction_regex => "Blonk blonk ([blonk]+).*"; } ########################################################## body match_value free_memory # not willy! { select_line_matching => "MemFree:.*"; extraction_regex => "MemFree:\s+([0-9]+).*"; } ########################################################## body match_value proc_value(x,y) { select_line_matching => "$(x)"; extraction_regex => "$(y)"; } ########################################################## body match_value file_system { select_line_matching => "/.*"; extraction_regex => "(.*)"; } cfengine-3.2.4/examples/unit_getenv.cf0000644000175000017500000000045211707771422014707 00000000000000 body common control { bundlesequence => { "test" }; } bundle agent test { vars: "myvar" string => getenv("PATH","20"); classes: "isdefined" not => strcmp("$(myvar)",""); reports: isdefined:: "The path is $(myvar)"; !isdefined:: "The named variable PATH does not exist"; } cfengine-3.2.4/examples/unit_classes_global.cf0000644000175000017500000000275511707771422016404 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "g","tryclasses_1", "tryclasses_2" }; } ################################# bundle common g { classes: "one" expression => "any"; "client_network" expression => iprange("128.39.89.0/24"); } ################################# bundle agent tryclasses_1 { classes: "two" expression => "any"; } ################################# bundle agent tryclasses_2 { classes: "three" expression => "any"; reports: one.three.!two:: "Success"; } #################################cfengine-3.2.4/examples/unit_syslog.cf0000644000175000017500000000223211707771422014735 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "one" }; } bundle agent one { files: "/tmp/xyz" create => "true", action => log; } body action log { log_level => "inform"; } cfengine-3.2.4/examples/unit_grep.cf0000644000175000017500000000271011707771422014353 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # grp function to concat a list # ####################################################### body common control { any:: bundlesequence => { test }; } ####################################################### bundle agent test { vars: "mylist" slist => { "One", "Two", "Three", "Four", "Five" }; "sublist" slist => grep("T.*","mylist"); reports: linux:: "Item: $(sublist)"; } cfengine-3.2.4/examples/unit_copydir_copbl.cf0000644000175000017500000000254611707771422016255 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "my_recursive_copy" }; inputs => { "cfengine_stdlib.cf" }; } bundle agent my_recursive_copy { files: "/home/mark/tmp/test_dir" copy_from => local_cp("$(sys.workdir)/bin/."), depth_search => recurse("inf"); "/home/mark/tmp/test_dir" copy_from => secure_cp("$(sys.workdir)/bin","serverhost"), depth_search => recurse("inf"); } cfengine-3.2.4/examples/unit_execresult.cf0000644000175000017500000000235611707771422015607 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "my_result" string => execresult("/bin/ls /tmp","noshell"); reports: linux:: "Variable is $(my_result)"; } cfengine-3.2.4/examples/unit_isdir.cf0000644000175000017500000000232411707771422014531 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "isdir" expression => isdir("/etc"); reports: isdir:: "Directory exists.."; } cfengine-3.2.4/examples/unit_selectservers.cf0000644000175000017500000000361611707771422016315 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Testing some variable/class definitions - note scope # # Use browser -f promise_output_agent.html to view # body common control { bundlesequence => { "test" }; } ########################################################### bundle agent test { vars: "hosts" slist => { "slogans.iu.hio.no", "eternity.iu.hio.no", "nexus.iu.hio.no" }; # selectservers(hostlist,port,sendstr,regex_on_reply,maxbytesread_reply,array_name "up_servers" int => selectservers("@(hosts)","80","","","100","alive_servers"); classes: "someone_alive" expression => isgreaterthan("$(up_servers)","0"); "i_am_a_server" expression => regarray("up_servers","$(host)|$(fqhost)"); reports: someone_alive:: "Number of active servers $(up_servers)" action => always; "First server $(alive_servers[0]) fails over to $(alive_servers[1])"; } ############################################################# body action always { ifelapsed => "0"; }cfengine-3.2.4/examples/unit_promises.cf0000644000175000017500000000272711715232734015264 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # The starting point for every configuration # ####################################################### body common control { any:: bundlesequence => { "update", "main", "cfengine2" }; inputs => { "update.cf" }; } ####################################################### bundle agent main { # do something } ####################################################### bundle agent cfengine2 { commands: "/var/cfengine/bin/cfagent"; } cfengine-3.2.4/examples/win_services.cf0000644000175000017500000000251311715232734015055 00000000000000######################################################################### # # win_services.cf - Windows Service Management # ######################################################################### bundle agent win_services { vars: # NOTE: Use "Service Name" (not "Display Name"); # Administrative Tools -> Services -> Double Click on one to see its name "bad_services" slist => { "RemoteRegistry" }; Windows_Server_2003_R2:: "autostart_services" slist => { "Alerter", "W32Time" # Windows Time }; Windows_Server_2008:: "autostart_services" slist => { "MpsSvc", # Windows Firewall "W32Time" # Windows Time }; services: "$(bad_services)" service_policy => "disable", service_method => force_deps, comment => "Disable services that create security issues"; Windows_Server_2003_R2|Windows_Server_2008:: "$(autostart_services)" service_policy => "start", service_method => bootstart, comment => "Make sure important services are running and set to start at boot time"; } cfengine-3.2.4/examples/unit_resolveconf.cf0000644000175000017500000000535711707771422015755 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Resolve conf # ####################################################### bundle common g # globals { vars: "searchlist" slist => { "search iu.hio.no", "search cfengine.com" }; "nameservers" slist => { "128.39.89.10", "128.39.74.16", "192.168.1.103" }; classes: "am_name_server" expression => reglist("@(nameservers)","$(sys.ipv4[eth1])"); } ####################################################### body common control { any:: bundlesequence => { "g", resolver(@(g.searchlist),@(g.nameservers)) }; domain => "iu.hio.no"; } ####################################################### bundle agent resolver(s,n) { files: # When passing parameters down, we have to refer to # a source context "$(sys.resolv)" # test on "/tmp/resolv.conf" # create => "true", edit_line => doresolv("@(this.s)","@(this.n)"), edit_defaults => reconstruct; # or edit_defaults => modify } ####################################################### # For the library ####################################################### bundle edit_line doresolv(s,n) { vars: "line" slist => { @(s), @(n) }; insert_lines: "$(line)"; } ####################################################### body edit_defaults reconstruct { empty_file_before_editing => "true"; edit_backup => "false"; max_file_size => "100000"; } ####################################################### body edit_defaults modify { empty_file_before_editing => "false"; edit_backup => "false"; max_file_size => "100000"; } cfengine-3.2.4/examples/unit_epimenides.cf0000644000175000017500000000223611715232734015540 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "g" }; } bundle common g { vars: "head" string => "Swallow my ${tail}"; "tail" string => "behind my ${head}"; reports: linux:: "Go $(head)"; } cfengine-3.2.4/examples/unit_cf2_integration.cf0000644000175000017500000000303311715232734016467 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Cfagent 2 can be run as a command within cfengine 3 # so that cfagent 2 AND cfagent 3 can coexist # # It does not matter which versions of the daemons are run # but you must choose version 2 XOR version 3 # body control common { # Reads default # /var/cfengine/inputs/promises.cf # /var/cfengine/inputs/failsafe.cf bundlesequence = { "cfengine3", "cfengine2" }; } ########################################### bundle agent cfengine2 { commands: "/var/cfengine/bin/cfagent"; } ########################################### bundle agent cfengine3 { # Stuff } cfengine-3.2.4/examples/unit_edit_passwd_file.cf0000644000175000017500000000415411707771422016727 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "addpasswd" }; } bundle agent addpasswd { vars: # want to set these values by the names of their array keys "pwd[mark]" string => "mark:x:1000:100:Mark Burgess:/home/mark:/bin/bash"; "pwd[fred]" string => "fred:x:1001:100:Right Said:/home/fred:/bin/bash"; "pwd[jane]" string => "jane:x:1002:100:Jane Doe:/home/jane:/bin/bash"; files: "/tmp/passwd" create => "true", edit_line => append_users_starting("addpasswd.pwd"); } ############################################################ # Library stuff ############################################################ bundle edit_line append_users_starting(v) { vars: "index" slist => getindices("$(v)"); classes: "add_$(index)" not => userexists("$(index)"); insert_lines: "$($(v)[$(index)])", ifvarclass => "add_$(index)"; } ############################################################ bundle edit_line append_groups_starting(v) { vars: "index" slist => getindices("$(v)"); classes: "add_$(index)" not => groupexists("$(index)"); insert_lines: "$($(v)[$(index)])", ifvarclass => "add_$(index)"; } cfengine-3.2.4/examples/unit_inventory_cpu.cf0000644000175000017500000000147011707771422016324 00000000000000# Demo on how to extract the first "model name" field from /proc/cpuinfo # into a variable. # Can be used for inventory information in CFEngine Nova and above. body common control { bundlesequence => { "inventory" }; } ### bundle common inventory { vars: "cpuinfo" string => execresult("/bin/grep \"model name\" /proc/cpuinfo", "noshell"); got_model_name:: "cpu" string => "$(myarray[1])"; classes: "got_model_name" expression => regextract( "model\s+name\s+:\s+([^\n]*)\n?.*", "$(cpuinfo)", "myarray" ); reports: got_model_name:: "model name is \"$(myarray[1])\""; !got_model_name:: "Did not match CPU model name"; } cfengine-3.2.4/examples/unit_storage.cf0000644000175000017500000000263211707771422015065 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # cfengine 3 # # cf-agent -f ./cftest.cf -K # body common control { bundlesequence => { "storage" }; } # bundle agent storage { storage: "/usr" volume => mycheck("11G"); "/" volume => mycheck("60%"); } ###################################################################### body volume mycheck(free) # reusable template { check_foreign => "false"; freespace => "$(free)"; sensible_size => "10000"; sensible_count => "2"; } cfengine-3.2.4/examples/unit_server_flatcopy_localhost.cf0000644000175000017500000000627711707771422020711 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test copy from server connection to cfServer # ######################################################## # # run this as follows: # # cf-serverd -f runtest_1.cf [-d2] # cf-agent -f runtest_2.cf # # Notice that the same file configures all parts of cfengine ######################################################## body common control { bundlesequence => { "testbundle" }; version => "1.2.3"; } ######################################################## bundle agent testbundle { files: "/home/mark/tmp/testflatcopy" comment => "test copy promise", copy_from => mycopy("/home/mark/LapTop/words","127.0.0.1"), perms => system, depth_search => recurse("inf"), classes => satisfied("copy_ok"); "/home/mark/tmp/testcopy/single_file" comment => "test copy promise", copy_from => mycopy("/home/mark/LapTop/Cfengine3/trunk/README","127.0.0.1"), perms => system; reports: copy_ok:: "Files were copied.."; } ######################################################### body perms system { mode => "0644"; } ######################################################### body depth_search recurse(d) { depth => "$(d)"; } ######################################################### body copy_from mycopy(from,server) { source => "$(from)"; servers => { "$(server)" }; compare => "digest"; verify => "true"; copy_backup => "true"; #/false/timestamp purge => "false"; type_check => "true"; force_ipv4 => "true"; trustkey => "true"; collapse_destination_dir => "true"; } ######################################################### body classes satisfied(x) { promise_repaired => { "$(x)" }; persist_time => "0"; } ######################################################### # Server config ######################################################### body server control { allowconnects => { "127.0.0.1" , "::1" }; allowallconnects => { "127.0.0.1" , "::1" }; trustkeysfrom => { "127.0.0.1" , "::1" }; } ######################################################### bundle server access_rules() { access: "/home/mark/LapTop" admit => { "127.0.0.1" }; } cfengine-3.2.4/examples/unit_select_class.cf0000644000175000017500000000237611707771422016072 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "g" }; } ################################# bundle common g { classes: "selection" select_class => { "one", "two" }; reports: one:: "One was selected"; two:: "Two was selected"; selection:: "A selection was made"; } cfengine-3.2.4/examples/unit_user_edit_method.cf0000644000175000017500000000357511707771422016753 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # body common control { bundlesequence => { "users" }; } body agent control { abortbundleclasses => { "ldap_fail" }; } #################################################################################### bundle agent users { vars: "users" slist => { "mark", "nakarin", "three" }; methods: "all" usebundle => fix_user("$(users)"); } ################################################################################### bundle agent fix_user(x) { classes: "ldap_fail" not => ldaparray("dat","ldap://eternity.iu.hio.no","dc=cfengine,dc=com","(uid=$(x))","subtree","none"); files: "/tmp/passwd" create => "true", edit_line => fix_passwd("$(x)"); reports: !ldap_fail:: "Editing user $(x)"; } #################################################################################### bundle edit_line fix_passwd(x) { insert_lines: "Hello $(x),$(fix_user.dat[uid]),$(fix_user.dat[gecos])"; }cfengine-3.2.4/examples/unit_varnet.cf0000644000175000017500000000051611707771422014717 00000000000000 body common control { bundlesequence => { "test" }; } bundle agent test { classes: "all" expression => "any"; reports: all:: "My default interface and ip4 address is $(sys.interface) and $(sys.ipv4)"; "Can also extract $(sys.ipv4[Local_Area_Connection_3]), $(sys.ipv4_2[Wireless_Network_Connection])"; }cfengine-3.2.4/examples/unit_package_freebsd.cf0000644000175000017500000000423511707771422016507 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Package managment # body common control { bundlesequence => { "packages" }; } ############################################# body agent control { environment => { "PACKAGESITE=ftp://freebsd-src.es.net/pub/FreeBSD/ports/i386/packages-7.2-release/All/" }; } ############################################# bundle agent packages { vars: # Test the simplest case -- leave everything to the yum smart manager "match_package" slist => { "wget-1.11.4" }; packages: "$(match_package)" package_policy => "add", package_method => freebsd; } ############################################# body package_method freebsd { any:: package_changes => "individual"; # Could use rpm for this package_list_command => "/usr/sbin/pkg_info"; # Remember to escape special characters like | package_list_name_regex => "([^-]+).*"; package_list_version_regex => "[^-]+-([^\s]+).*"; package_name_regex => "([^-]+).*"; package_version_regex => "[^-]+-([^\s]+).*"; package_installed_regex => ".*"; package_name_convention => "$(name)-$(version)"; package_add_command => "/usr/sbin/pkg_add -r"; package_delete_command => "/usr/sbin/pkg_delete"; } cfengine-3.2.4/examples/example_config/0000755000175000017500000000000011715233356015103 500000000000000cfengine-3.2.4/examples/example_config/promises.cf0000644000175000017500000000551211707771422017203 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # promises.cf # ####################################################### body common control { bundlesequence => { "update", "garbage_collection", "main", "cfengine" }; inputs => { "update.cf", "site.cf", "cfengine_stdlib.cf" }; } ####################################################### body agent control { # if default runtime is 5 mins we need this for long jobs ifelapsed => "15"; } ####################################################### body monitor control { forgetrate => "0.7"; histograms => "true"; } ####################################################### body executor control { splaytime => "1"; mailto => "cfengine_mail@example.org"; smtpserver => "localhost"; mailmaxlines => "30"; # Instead of a separate update script, now do this exec_command => "$(sys.workdir)/bin/cf-agent -f failsafe.cf && $(sys.workdir)/bin/cf-agent"; } ####################################################### body reporter control { reports => { "performance", "last_seen", "monitor_history" }; build_directory => "$(sys.workdir)/reports"; report_output => "html"; } ####################################################### body runagent control { hosts => { "127.0.0.1" # , "myhost.example.com:5308", ... }; } ####################################################### body server control { allowconnects => { "127.0.0.1" , "::1" }; allowallconnects => { "127.0.0.1" , "::1" }; trustkeysfrom => { "127.0.0.1" , "::1" }; # Make updates and runs happen in one cfruncommand => "$(sys.workdir)/bin/cf-agent -f failsafe.cf && $(sys.workdir)/bin/cf-agent"; allowusers => { "root" }; } cfengine-3.2.4/examples/example_config/Makefile.am0000644000175000017500000000120111715232734017050 00000000000000exampleconfigdir = @docdir@/example_config dist_exampleconfig_DATA = $(srcdir)/failsafe.cf $(srcdir)/cfengine_stdlib.cf $(srcdir)/promises.cf $(srcdir)/site.cf $(srcdir)/update.cf # # Some basic clean ups # MOSTLYCLEANFILES = *~ # # Get everything removed down to where rebuilding requires: # "make; make install" # CLEANFILES = # # Get everything removed down to where rebuilding requires: # "configure; make; make install" # DISTCLEANFILES = # # Get everything removed down to where rebuilding requires: # "aclocal; autoconf; autoheader; automake --add-missing" # "configure; make; make install" # MAINTAINERCLEANFILES = Makefile.in cfengine-3.2.4/examples/example_config/failsafe.cf0000644000175000017500000000210211707771422017104 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Failsafe file # body common control { bundlesequence => { "update" }; inputs => { "update.cf" }; } cfengine-3.2.4/examples/example_config/Makefile.in0000644000175000017500000003514611715232775017105 00000000000000# Makefile.in generated by automake 1.11.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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@ target_triplet = @target@ subdir = examples/example_config DIST_COMMON = $(dist_exampleconfig_DATA) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \ $(top_srcdir)/m4/cf3_with_library.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)/src/conf.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 = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(exampleconfigdir)" DATA = $(dist_exampleconfig_DATA) 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@ BERKELEYDB_CFLAGS = @BERKELEYDB_CFLAGS@ BERKELEYDB_LDFLAGS = @BERKELEYDB_LDFLAGS@ BERKELEYDB_LIBS = @BERKELEYDB_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EIGHTBIT = @EIGHTBIT@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GCC_CFLAG = @GCC_CFLAG@ GETCONF = @GETCONF@ GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ GREP = @GREP@ HOSTNAME = @HOSTNAME@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ KMEM_GROUP = @KMEM_GROUP@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_SELINUX = @LIB_SELINUX@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MYSQL_CFLAGS = @MYSQL_CFLAGS@ MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@ MYSQL_LDFLAGS = @MYSQL_LDFLAGS@ MYSQL_LIBS = @MYSQL_LIBS@ MYSQL_PATH = @MYSQL_PATH@ NEED_SETGID = @NEED_SETGID@ NM = @NM@ NMEDIT = @NMEDIT@ NOWRAP = @NOWRAP@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_CPPFLAGS = @OPENSSL_CPPFLAGS@ OPENSSL_LDFLAGS = @OPENSSL_LDFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OPENSSL_PATH = @OPENSSL_PATH@ 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@ PCRE_CFLAGS = @PCRE_CFLAGS@ PCRE_CPPFLAGS = @PCRE_CPPFLAGS@ PCRE_LDFLAGS = @PCRE_LDFLAGS@ PCRE_LIBS = @PCRE_LIBS@ PCRE_PATH = @PCRE_PATH@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_CPPFLAGS = @POSTGRESQL_CPPFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_LIBS = @POSTGRESQL_LIBS@ POSTGRESQL_PATH = @POSTGRESQL_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ TOKYOCABINET_CFLAGS = @TOKYOCABINET_CFLAGS@ TOKYOCABINET_CPPFLAGS = @TOKYOCABINET_CPPFLAGS@ TOKYOCABINET_LDFLAGS = @TOKYOCABINET_LDFLAGS@ TOKYOCABINET_LIBS = @TOKYOCABINET_LIBS@ TOKYOCABINET_PATH = @TOKYOCABINET_PATH@ 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_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ workdir = @workdir@ exampleconfigdir = @docdir@/example_config dist_exampleconfig_DATA = $(srcdir)/failsafe.cf $(srcdir)/cfengine_stdlib.cf $(srcdir)/promises.cf $(srcdir)/site.cf $(srcdir)/update.cf # # Some basic clean ups # MOSTLYCLEANFILES = *~ # # Get everything removed down to where rebuilding requires: # "make; make install" # CLEANFILES = # # Get everything removed down to where rebuilding requires: # "configure; make; make install" # DISTCLEANFILES = # # Get everything removed down to where rebuilding requires: # "aclocal; autoconf; autoheader; automake --add-missing" # "configure; make; make install" # MAINTAINERCLEANFILES = Makefile.in all: all-am .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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) --gnu examples/example_config/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu examples/example_config/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(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 install-dist_exampleconfigDATA: $(dist_exampleconfig_DATA) @$(NORMAL_INSTALL) test -z "$(exampleconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(exampleconfigdir)" @list='$(dist_exampleconfig_DATA)'; test -n "$(exampleconfigdir)" || 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)$(exampleconfigdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(exampleconfigdir)" || exit $$?; \ done uninstall-dist_exampleconfigDATA: @$(NORMAL_UNINSTALL) @list='$(dist_exampleconfig_DATA)'; test -n "$(exampleconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(exampleconfigdir)'; $(am__uninstall_files_from_dir) 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 $(DATA) installdirs: for dir in "$(DESTDIR)$(exampleconfigdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) 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) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) 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 "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) 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-dist_exampleconfigDATA 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: uninstall-dist_exampleconfigDATA .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-dist_exampleconfigDATA \ 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 \ uninstall-dist_exampleconfigDATA # 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: cfengine-3.2.4/examples/example_config/cfengine_stdlib.cf0000644000175000017500000006513611715232734020466 00000000000000########################################################################### # Copyright (C) Cfengine AS # # 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; version 3. # # 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. # # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ########################################################################### # # Cfengine Community Open Promise-Body Library # # This initiative started by Cfengine promotes a # standardized set of names and promise specifications # for template functionality within Cfengine 3. # # The aim is to promote an industry standard for # naming of configuration patterns, leading to a # de facto middleware of standardized syntax. # # Names should be intuitive and parameters should be # minimal to assist readability and comprehensibility. # Contributions to this file are voluntarily given to # the cfengine community, and are moderated by Cfengine. # No liability or warranty for misuse is implied. # # If you add to this file, please try to make the # contributions "self-documenting". Comments made # after the bundle/body statement are retained in # the online docs # # Subversion : $Rev: 61 $ # For Cfengine Core: 3.1.0 ################################################### # If you find Cfengine useful, please consider # # purchasing a commercial version of the software.# ################################################### ################################################### # edit_line bundles ################################################### bundle edit_line insert_lines(lines) { insert_lines: "$(lines)" comment => "Append lines if they don't exist"; } ## bundle edit_line comment_lines_matching(regex,comment) # Comment lines of a file matching a regex { replace_patterns: "^($(regex))$" replace_with => comment("$(comment)"), comment => "Search and replace string"; } ## bundle edit_line uncomment_lines_matching(regex,comment) # Uncomment lines of a file where the regex matches # the text after the comment string { replace_patterns: "^$(comment)\s?($(regex))$" replace_with => uncomment, comment => "Uncomment lines matching a regular expression"; } ## bundle edit_line comment_lines_containing(regex,comment) # Comment lines of a file containing a regex { replace_patterns: "^(.*$(regex).*)$" replace_with => comment("$(comment)"), comment => "Comment out lines in a file"; } ## bundle edit_line uncomment_lines_containing(regex,comment) # Uncomment lines of a file where the regex matches # the text after the comment string { replace_patterns: "^$(comment)\s?(.*$(regex).*)$" replace_with => uncomment, comment => "Uncomment a line containing a fragment"; } ## bundle edit_line delete_lines_matching(regex) { delete_lines: "$(regex)" comment => "Delete lines matching regular expressions"; } ## bundle edit_line warn_lines_matching(regex) { delete_lines: "$(regex)" comment => "Warn about lines in a file", action => warn_only; } ## bundle edit_line append_if_no_line(str) { insert_lines: "$(str)" comment => "Append a line to the file if it doesn't already exist"; } ## bundle edit_line append_if_no_lines(list) { insert_lines: "$(list)" comment => "Append lines to the file if they don't already exist"; } ## bundle edit_line resolvconf(search,list) # search is the search domains with space # list is an slist of nameserver addresses { delete_lines: "search.*" comment => "Reset search lines from resolver"; "nameserver.*" comment => "Reset nameservers in resolver"; insert_lines: "search $(search)" comment => "Add search domains to resolver"; "nameserver $(list)" comment => "Add name servers to resolver"; } ## bundle edit_line set_variable_values(v) # Sets the RHS of variables in the file of the form # LHS = RHS # Adds a new line if no LHS exists, repairs RHS values if one does exist # # To use: # 1) Define an array, where the keys are the LHS and the values are the RHS # "stuff[lhs-1]" string => "rhs1"; # "stuff[lhs-2]" string => "rhs2"; # 2) The parameter passed to the edit_line promise is the fully qualified # name of the array (i.e., "bundlename.stuff") WITHOUT any "$" or "@" { vars: "index" slist => getindices("$(v)"); # Be careful if the index string contains funny chars "cindex[$(index)]" string => canonify("$(index)"); field_edits: # match a line starting like the key = something "\s*$(index)\s*=.*" edit_field => col("=","2","$($(v)[$(index)])","set"), classes => if_ok("$(cindex[$(index)])_in_file"), comment => "Match a line starting like key = something"; insert_lines: "$(index)=$($(v)[$(index)])", comment => "Insert a variable definition", ifvarclass => "!$(cindex[$(index)])_in_file"; } ## bundle edit_line append_users_starting(v) # For adding to /etc/passwd or etc/shadow, needs # an array v[username] string => "line..." { vars: "index" slist => getindices("$(v)"); classes: "add_$(index)" not => userexists("$(index)"); insert_lines: "$($(v)[$(index)])", comment => "Append users into a password file format", ifvarclass => "add_$(index)"; } ## bundle edit_line append_groups_starting(v) # For adding groups to /etc/group, needs # an array v[groupname] string => "line..." { vars: "index" slist => getindices("$(v)"); classes: "add_$(index)" not => groupexists("$(index)"); insert_lines: "$($(v)[$(index)])", comment => "Append users into a group file format", ifvarclass => "add_$(index)"; } ## bundle edit_line set_user_field(user,field,val) # Set the value of field number "field" in # a :-field formatted file like /etc/passwd { field_edits: "$(user):.*" comment => "Edit a user attribute in the password file", edit_field => col(":","$(field)","$(val)","set"); } ## bundle edit_line append_user_field(group,field,allusers) # For adding users to to a file like /etc/group # at field position "field", comma separated subfields { vars: "val" slist => { @(allusers) }; field_edits: "$(group):.*" comment => "Append users into a password file format", edit_field => col(":","$(field)","$(val)","alphanum"); } ## bundle edit_line expand_template(templatefile) # Read in the named text file and expand $(var) # inside the file { insert_lines: "$(templatefile)" insert_type => "file", comment => "Expand variables in the template file", expand_scalars => "true"; } ## ## editing bodies ## body edit_field quoted_var(newval,method) { field_separator => "\""; select_field => "2"; value_separator => " "; field_value => "$(newval)"; field_operation => "$(method)"; extend_fields => "false"; allow_blank_fields => "true"; } ## body edit_field col(split,col,newval,method) { field_separator => "$(split)"; select_field => "$(col)"; value_separator => ","; field_value => "$(newval)"; field_operation => "$(method)"; extend_fields => "true"; allow_blank_fields => "true"; } ## body replace_with value(x) { replace_value => "$(x)"; occurrences => "all"; } ## body select_region INI_section(x) { select_start => "\[$(x)\]\s*"; select_end => "\[.*\]\s*"; } ## ## edit_defaults ## body edit_defaults std_defs { empty_file_before_editing => "false"; edit_backup => "false"; max_file_size => "300000"; } ## body edit_defaults empty { empty_file_before_editing => "true"; edit_backup => "false"; max_file_size => "300000"; } ## ## location ## body location start { before_after => "before"; } ## body location after(str) { before_after => "after"; select_line_matching => "$(str)"; } ## ## replace_with ## ## body replace_with comment(c) { replace_value => "$(c) $(match.1)"; occurrences => "all"; } ## body replace_with uncomment { replace_value => "$(match.1)"; occurrences => "all"; } #################################################### ## agent bodyparts #################################################### ## ## action ## body action if_elapsed(x) { ifelapsed => "$(x)"; expireafter => "$(x)"; } ## body action measure_performance(x) { measurement_class => "Detect changes in $(this.promiser)"; ifelapsed => "$(x)"; expireafter => "$(x)"; } ## body action warn_only { action_policy => "warn"; ifelapsed => "60"; } ## body action bg(elapsed,expire) { ifelapsed => "$(elapsed)"; # run only every 8 hours expireafter => "$(expire)"; background => "true"; } ## body action ifwin_bg { windows:: background => "true"; } ## body action immediate { ifelapsed => "0"; } ## body action policy(p) { action_policy => "$(p)"; } ## # Log a message to log=[/file|stdout] body action log_repaired(log,message) { log_string => "$(sys.date), $(message)"; log_repaired => "$(log)"; } ## ## contain ## body contain silent { no_output => "true"; } ## body contain in_dir(s) { chdir => "$(s)"; } ## body contain silent_in_dir(s) { chdir => "$(s)"; no_output => "true"; } ## body contain in_shell { useshell => "true"; } ## body contain setuid(x) { exec_owner => "$(x)"; useshell => "false"; } ## body contain setuid_sh(x) { exec_owner => "$(x)"; useshell => "true"; } ## body contain setuidgid_sh(owner,group) { exec_owner => "$(owner)"; exec_group => "$(group)"; useshell => "true"; } ## body contain jail(owner,root,dir) { exec_owner => "$(owner)"; useshell => "true"; chdir => "$(dir)"; chroot => "$(root)"; } ## ## classes ## body classes if_repaired(x) { promise_repaired => { "$(x)" }; } ## body classes if_else(yes,no) { promise_kept => { "$(yes)" }; promise_repaired => { "$(yes)" }; repair_failed => { "$(no)" }; repair_denied => { "$(no)" }; repair_timeout => { "$(no)" }; } ## body classes cf2_if_else(yes,no) # meant to match cf2 semantics { promise_repaired => { "$(yes)" }; repair_failed => { "$(no)" }; repair_denied => { "$(no)" }; repair_timeout => { "$(no)" }; } ## body classes if_notkept(x) { repair_failed => { "$(x)" }; repair_denied => { "$(x)" }; repair_timeout => { "$(x)" }; } ## body classes if_ok(x) { promise_repaired => { "$(x)" }; promise_kept => { "$(x)" }; } ## ## Persistent classes ## body classes state_repaired(x) { promise_repaired => { "$(x)" }; persist_time => "10"; } ## body classes enumerate(x) # # This is used by commercial editions to count # instances of jobs in a cluster # { promise_repaired => { "mXC_$(x)" }; promise_kept => { "mXC_$(x)" }; persist_time => "15"; } ################################################### # agent bundles ################################################### ##.................................................. ## files promises ##.................................................. ## ## copy_from ## body copy_from secure_cp(from,server) { source => "$(from)"; servers => { "$(server)" }; compare => "digest"; encrypt => "true"; verify => "true"; } ## body copy_from remote_cp(from,server) { servers => { "$(server)" }; source => "$(from)"; compare => "mtime"; } ## body copy_from local_cp(from) { source => "$(from)"; } ## body copy_from perms_cp(from) { source => "$(from)"; preserve => "true"; } ## # Copy only if the file does not already exist, i.e. seed the placement body copy_from seed_cp(from) { source => "$(from)"; compare => "exists"; } ## body copy_from sync_cp(from,server) { servers => { "$(server)" }; source => "$(from)"; purge => "true"; preserve => "true"; } ## body copy_from no_backup_cp(from) { source => "$(from)"; copy_backup => "false"; } ## body copy_from no_backup_rcp(from,server) { servers => { "$(server)" }; source => "$(from)"; compare => "mtime"; copy_backup => "false"; } ## ## link_from ## body link_from ln_s(x) { link_type => "symlink"; source => "$(x)"; when_no_source => "force"; } ## body link_from linkchildren(tofile) { source => "$(tofile)"; link_type => "symlink"; when_no_source => "force"; link_children => "true"; when_linking_children => "if_no_such_file"; # "override_file"; } ## ## perms ## body perms m(mode) { mode => "$(mode)"; } ## body perms mo(mode,user) { owners => { "$(user)" }; mode => "$(mode)"; } ## body perms mog(mode,user,group) { owners => { "$(user)" }; groups => { "$(group)" }; mode => "$(mode)"; } ## body perms og(u,g) { owners => { "$(u)" }; groups => { "$(g)" }; } ## body perms owner(user) { owners => { "$(user)" }; } ## ## ACLS (extended Unix perms) ## body acl access_generic(acl) # default/inherited ACLs are left unchanged, # applicable for both files and directory on all platforms { acl_method => "overwrite"; aces => { "@(acl)" }; } ## body acl strict # NOTE: May need to take ownership of file/dir # to be sure no-one else is allowed access { acl_method => "overwrite"; windows:: aces => { "user:Administrator:rwx" }; !windows:: aces => { "user:root:rwx" }; } ## ## depth_search ## body depth_search recurse(d) { depth => "$(d)"; xdev => "true"; } ## body depth_search recurse_ignore(d,list) { depth => "$(d)"; exclude_dirs => { @(list) }; } ## ## delete ## body delete tidy { dirlinks => "delete"; rmdirs => "true"; } ## ## rename ## body rename disable { disable => "true"; } ## body rename rotate(level) { rotate => "$(level)"; } ## body rename to(file) { newname => "$(file)"; } ## ## file_select ## body file_select name_age(name,days) { leaf_name => { "$(name)" }; mtime => irange(0,ago(0,0,"$(days)",0,0,0)); file_result => "mtime.leaf_name"; } ## body file_select days_old(days) { mtime => irange(0,ago(0,0,"$(days)",0,0,0)); file_result => "mtime"; } ## body file_select size_range(from,to) { search_size => irange("$(from)","$(to)"); file_result => "size"; } ## body file_select exclude(name) { leaf_name => { "$(name)"}; file_result => "!leaf_name"; } ## body file_select plain { file_types => { "plain" }; file_result => "file_types"; } body file_select dirs { file_types => { "dir" }; file_result => "file_types"; } ## body file_select by_name(names) { leaf_name => { @(names)}; file_result => "leaf_name"; } ## body file_select ex_list(names) { leaf_name => { @(names)}; file_result => "!leaf_name"; } ## ## changes ## body changes detect_all_change # This is fierce, and will cost disk cycles { hash => "best"; report_changes => "all"; update_hashes => "yes"; } ## body changes detect_content # This is a cheaper alternative { hash => "md5"; report_changes => "content"; update_hashes => "yes"; } ## body changes noupdate # Use on (small) files that should never change { hash => "sha256"; report_changes => "content"; update_hashes => "no"; } ## body changes diff # Generates diff report (Nova and above) { hash => "sha256"; report_changes => "content"; report_diffs => "true"; update_hashes => "yes"; } ##-------------------------------------------------------------- ## Packages promises ##-------------------------------------------------------------- body package_method zypper { package_changes => "bulk"; package_list_command => "/usr/bin/zypper packages"; package_patch_list_command => "/usr/bin/zypper patches"; package_installed_regex => "i.*"; package_list_name_regex => "[^|]+\|[^|]+\|\s+([^\s]+).*"; package_list_version_regex => "[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_list_arch_regex => "[^|]+\|[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_patch_installed_regex => ".*Installed.*|.*Not Applicable.*"; package_patch_name_regex => "[^|]+\|\s+([^\s]+).*"; package_patch_version_regex => "[^|]+\|[^|]+\|\s+([^\s]+).*"; package_name_convention => "$(name)"; package_add_command => "/usr/bin/zypper -non-interactive install"; package_delete_command => "/usr/bin/zypper -non-interactive remove --force-resolution"; package_update_command => "/usr/bin/zypper -non-interactive update"; package_patch_command => "/usr/bin/zypper -non-interactive patch$"; # $ means no args package_verify_command => "/usr/bin/zypper -non-interactive verify$"; } ## body package_method apt { package_changes => "bulk"; package_list_command => "/usr/bin/dpkg -l"; package_list_name_regex => "ii\s+([^\s]+).*"; package_list_version_regex => "ii\s+[^\s]+\s+([^\s]+).*"; package_installed_regex => ".*"; # all reported are installed package_name_convention => "$(name)"; package_list_update_ifelapsed => "240"; # 4 hours have_aptitude:: package_add_command => "/usr/bin/aptitude --assume-yes install"; package_list_update_command => "/usr/bin/aptitude update"; package_delete_command => "/usr/bin/aptitude --assume-yes remove"; package_update_command => "/usr/bin/aptitude --assume-yes install"; !have_aptitude:: package_add_command => "/usr/bin/apt-get --yes install"; package_list_update_command => "/usr/bin/apt-get update"; package_delete_command => "/usr/bin/apt-get --yes remove"; package_update_command => "/usr/bin/apt-get --yes install"; } ## body package_method rpm_version(repo) { package_changes => "individual"; package_list_command => "/bin/rpm -qa --queryformat \"i | repos | %{name} | %{version} | %{arch}\n\""; package_list_name_regex => "[^|]+\|[^|]+\|\s+([^\s|]+).*"; package_list_version_regex => "[^|]+\|[^|]+\|[^|]+\|\s+([^\s|]+).*"; package_list_arch_regex => "[^|]+\|[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_installed_regex => "i.*"; package_file_repositories => { "$(repo)" }; package_name_convention => "$(name)-$(version)-$(arch).rpm"; package_add_command => "/bin/rpm -ivh "; package_delete_command => "/bin/rpm -e --nodeps"; package_verify_command => "/bin/rpm -V"; package_update_command => "/bin/rpm -Uvh "; package_noverify_regex => ".*[^\s].*"; } ## body package_method msi_implicit(repo) # Use whole file name as promiser, e.g. "7-Zip-4.50-x86_64.msi", # the name, version and arch is then deduced from the promiser { package_changes => "individual"; package_file_repositories => { "$(repo)" }; package_installed_regex => ".*"; package_name_convention => "$(name)-$(version)-$(arch).msi"; package_delete_convention => "$(firstrepo)$(name)-$(version)-$(arch).msi"; package_name_regex => "^(\S+)-(\d+\.?)+"; package_version_regex => "^\S+-((\d+\.?)+)"; package_arch_regex => "^\S+-[\d\.]+-(.*).msi"; package_add_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_update_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_delete_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /x"; } ## body package_method msi_explicit(repo) # use software name as promiser, e.g. "7-Zip", and explicitly # specify any package_version and package_arch { package_changes => "individual"; package_file_repositories => { "$(repo)" }; package_installed_regex => ".*"; package_name_convention => "$(name)-$(version)-$(arch).msi"; package_delete_convention => "$(firstrepo)$(name)-$(version)-$(arch).msi"; package_add_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_update_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_delete_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /x"; } ## body package_method yum { package_changes => "bulk"; package_list_command => "/usr/bin/yum list installed"; # Remember to escape special characters like | package_list_name_regex => "([^.]+).*"; package_list_version_regex => "[^\s]\s+([^\s]+).*"; package_list_arch_regex => "[^.]+\.([^\s]+).*"; package_installed_regex => ".*installed.*"; package_name_convention => "$(name).$(arch)"; package_add_command => "/usr/bin/yum -y install"; package_delete_command => "/bin/rpm -e"; package_verify_command => "/bin/rpm -V"; } ## body package_method yum_rpm # Contributed by Trond Hasle Amundsen # More efficient package method for RedHat - uses rpm to list instead of yum # Notes: # - using $(name).$(arch) instead of $(name) for package_name_convention # causes uninstallation to fail. # - using allmatches to remove for all architectures # { package_changes => "bulk"; package_list_command => "/bin/rpm -qa --qf '%{name} %{version}-%{release} %{arch}\n'"; package_list_name_regex => "^(\S+?)\s\S+?\s\S+$"; package_list_version_regex => "^\S+?\s(\S+?)\s\S+$"; package_list_arch_regex => "^\S+?\s\S+?\s(\S+)$"; package_installed_regex => ".*"; package_name_convention => "$(name)"; package_add_command => "/usr/bin/yum -y install"; package_update_command => "/usr/bin/yum -y update"; package_delete_command => "/bin/rpm -e --allmatches"; package_verify_command => "/bin/rpm -V"; } ## # The solaris package system is poorly designed, with too many different # names to track. See the example in tests/units/unit_package_solaris.cf # to see how to use this body package_method solaris (pkgname, spoolfile, adminfile) { package_changes => "individual"; package_list_command => "/usr/bin/pkginfo -l"; package_multiline_start => "\s*PKGINST:\s+[^\s]+"; package_list_name_regex => "\s*PKGINST:\s+([^\s]+)"; package_list_version_regex => "\s*VERSION:\s+([^\s]+)"; package_list_arch_regex => "\s*ARCH:\s+([^\s]+)"; package_installed_regex => "\s*STATUS:\s*(completely|partially)\s+installed.*"; package_name_convention => "$(name)"; package_add_command => "/usr/sbin/pkgadd -n -a /tmp/$(adminfile) -d /tmp/$(spoolfile)"; package_delete_command => "/usr/sbin/pkgrm -n -a /tmp/$(adminfile)"; } ## body package_method freebsd { package_changes => "individual"; # Could use rpm for this package_list_command => "/usr/sbin/pkg_info"; # Remember to escape special characters like | package_list_name_regex => "([^-]+).*"; package_list_version_regex => "[^-]+-([^\s]+).*"; package_name_regex => "([^-]+).*"; package_version_regex => "[^-]+-([^\s]+).*"; package_installed_regex => ".*"; package_name_convention => "$(name)-$(version)"; package_add_command => "/usr/sbin/pkg_add -r"; package_delete_command => "/usr/sbin/pkg_delete"; } ## # Single bundle for all the similar managers simplifies promises body package_method generic { SuSE:: package_changes => "bulk"; package_list_command => "/usr/bin/zypper packages"; package_patch_list_command => "/usr/bin/zypper patches"; package_installed_regex => "i.*"; package_list_name_regex => "[^|]+\|[^|]+\|\s+([^\s]+).*"; package_list_version_regex => "[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_list_arch_regex => "[^|]+\|[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_patch_installed_regex => ".*Installed.*|.*Not Applicable.*"; package_patch_name_regex => "[^|]+\|\s+([^\s]+).*"; package_patch_version_regex => "[^|]+\|[^|]+\|\s+([^\s]+).*"; package_name_convention => "$(name)"; package_add_command => "/usr/bin/zypper -non-interactive install"; package_delete_command => "/usr/bin/zypper -non-interactive remove --force-resolution"; package_update_command => "/usr/bin/zypper -non-interactive update"; package_patch_command => "/usr/bin/zypper -non-interactive patch$"; # $ means no args package_verify_command => "/usr/bin/zypper -non-interactive verify$"; redhat:: package_changes => "bulk"; package_list_command => "/usr/bin/yum list installed"; package_list_name_regex => "([^.]+).*"; package_list_version_regex => "[^\s]\s+([^\s]+).*"; package_list_arch_regex => "[^.]+\.([^\s]+).*"; package_installed_regex => ".*installed.*"; package_name_convention => "$(name).$(arch)"; package_add_command => "/usr/bin/yum -y install"; package_delete_command => "/bin/rpm -e"; package_verify_command => "/bin/rpm -V"; debian:: package_changes => "bulk"; package_list_command => "/usr/bin/dpkg -l"; package_list_name_regex => "ii\s+([^\s]+).*"; package_list_version_regex => "ii\s+[^\s]+\s+([^\s]+).*"; package_installed_regex => ".*"; # all reported are installed package_name_convention => "$(name)"; package_list_update_ifelapsed => "240"; # 4 hours debian.have_aptitude:: package_add_command => "/usr/bin/aptitude --assume-yes install"; package_list_update_command => "/usr/bin/aptitude update"; package_delete_command => "/usr/bin/aptitude --assume-yes remove"; package_update_command => "/usr/bin/aptitude --assume-yes install"; debian.!have_aptitude:: package_add_command => "/usr/bin/apt-get --yes install"; package_list_update_command => "/usr/bin/apt-get update"; package_delete_command => "/usr/bin/apt-get --yes remove"; package_update_command => "/usr/bin/apt-get --yes install"; freebsd:: package_changes => "individual"; package_list_command => "/usr/sbin/pkg_info"; package_list_name_regex => "([^-]+).*"; package_list_version_regex => "[^-]+-([^\s]+).*"; package_name_regex => "([^-]+).*"; package_version_regex => "[^-]+-([^\s]+).*"; package_installed_regex => ".*"; package_name_convention => "$(name)-$(version)"; package_add_command => "/usr/sbin/pkg_add -r"; package_delete_command => "/usr/sbin/pkg_delete"; } ##------------------------------------------------------- ## storage promises ##------------------------------------------------------- body volume min_free_space(free) { check_foreign => "false"; freespace => "$(free)"; sensible_size => "10000"; sensible_count => "2"; } ## body mount nfs(server,source) { mount_type => "nfs"; mount_source => "$(source)"; mount_server => "$(server)"; edit_fstab => "true"; } ## body mount nfs_p(server,source,perm) { mount_type => "nfs"; mount_source => "$(source)"; mount_server => "$(server)"; mount_options => {"$(perm)"}; edit_fstab => "true"; } ## body mount unmount { mount_type => "nfs"; edit_fstab => "true"; unmount => "true"; } ##------------------------------------------------------- ## process promises ##------------------------------------------------------- body process_select exclude_procs(x) { command => "$(x)"; process_result => "!command"; } ## body process_count check_range(name,lower,upper) { match_range => irange("$(lower)","$(upper)"); out_of_range_define => { "$(name)_out_of_range" }; } ## ## service promises ## body service_method bootstart { service_autostart_policy => "boot_time"; service_dependence_chain => "start_parent_services"; windows:: service_type => "windows"; } ## body service_method force_deps { service_dependence_chain => "all_related"; windows:: service_type => "windows"; } #################################################### ## monitor bodyparts #################################################### body match_value scan_log(line) { select_line_matching => "$(line)"; track_growing_file => "true"; } ## body action sample_rate(x) { ifelapsed => "$(x)"; expireafter => "10"; } cfengine-3.2.4/examples/example_config/update.cf0000644000175000017500000000405211707771422016622 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################### bundle agent update { vars: "master_location" string => "/var/cfengine/masterfiles"; files: "/var/cfengine/inputs" perms => u_p("600"), copy_from => mycopy("$(master_location)","localhost"), depth_search => urecurse("inf"), action => uimmediate; "/var/cfengine/bin" perms => u_p("700"), copy_from => mycopy("/usr/local/sbin","localhost"), file_select => cf3_files, depth_search => urecurse("inf"), action => uimmediate; } ############################################ body perms u_p(p) { mode => "$(p)"; } ############################################ body file_select cf3_files { leaf_name => { "cf-.*" }; file_result => "leaf_name"; } ######################################################### body copy_from mycopy(from,server) { source => "$(from)"; compare => "digest"; } ######################################################### body action uimmediate { ifelapsed => "1"; } ############################################ body depth_search urecurse(d) { depth => "$(d)"; } cfengine-3.2.4/examples/example_config/site.cf0000644000175000017500000001704311707771422016310 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Site specific promises # ####################################################### bundle common g { vars: SuSE:: "crontab" string => "/var/spool/cron/tabs/root"; redhat:: "crontab" string => "/var/spool/cron/root"; (!SuSE).(!redhat):: "crontab" string => "/var/spool/cron/crontabs/root"; } ####################################################### # Start with cfengine itself ####################################################### bundle agent cfengine { classes: "integrate_cfengine2" and => { fileexists("$(sys.workdir)/inputs/cfagent.conf"), fileexists("$(sys.workdir)/bin/cfagent") }; vars: "cf2bits" slist => { "cfenvd", "cfservd", "cfexecd" }; commands: integrate_cfengine2:: "$(sys.workdir)/bin/cfagent" action => if_elapsed("240"); files: # Warn about rules relating to cfengine 2 in inputs - could conflict "$(sys.workdir)/inputs/.*" comment => "Check if there are still promises about cfengine 2 that need removing", edit_line => delete_lines_matching(".*$(cf2bits).*"), file_select => OldCf2Files, action => warn_only; # Check cf-execd and schedule is in crontab "$(g.crontab)" comment => "Add cfengine as a cron job, or check for cfengine 2 jobs to replace", create => "true", edit_line => upgrade_cfexecd; processes: exec_fix:: "cron" signals => { "hup" }; } ####################################################### # General site issues can be in bundles like this one ####################################################### bundle agent main { vars: "component" slist => { "cf-monitord", "cf-serverd" }; # - - - - - - - - - - - - - - - - - - - - - - - - files: "$(sys.resolv)" # test on "/tmp/resolv.conf" # comment => "Edit the resolver file", create => "true", edit_line => resolver, edit_defaults => def; # Uncomment this to perform a change-detection scan # "/usr" # changes => lay_trip_wire, # depth_search => recurse("inf"), # action => measure; processes: "cfenvd" signals => { "term" }; # Uncomment this if/when you are ready to upgrade a cf2 server # # "cfservd" signals => { "term" }; # # Now make sure the new parts are running, cf-serverd will fail if # the old server is still running "$(component)" restart_class => canonify("start_$(component)"); # - - - - - - - - - - - - - - - - - - - - - - - - commands: "$(sys.workdir)/bin/$(component)" ifvarclass => canonify("start_$(component)"); } ####################################################### # Garbage collection issues ####################################################### bundle agent garbage_collection { files: "$(sys.workdir)/outputs" delete => tidy, file_select => days_old("3"), depth_search => recurse("inf"); } ####################################################### bundle edit_line resolver { vars: "search" slist => { "search cfengine.com" }; delete_lines: "search.*"; insert_lines: "$(search)" location => start; } ########################################################### body file_select OldCf2Files { leaf_name => { "promises.cf", "site.cf", "library.cf", "failsafe.cf", ".*.txt", ".*.html", ".*~", "#.*" }; file_result => "!leaf_name"; } ########################################################### body action measure { measurement_class => "Detect Changes in /usr"; ifelapsed => "240"; expireafter => "240"; } ####################################################### # Anomaly monitoring ####################################################### bundle agent anomalies { reports: rootprocs_high_dev2:: "RootProc anomaly high 2 dev on $(mon.host) at $(mon.env_time) measured value $(mon.value_rootprocs) av $(mon.av_rootprocs) pm $(mon.dev_rootprocs)" showstate => { "rootprocs" }; entropy_www_in_high&anomaly_hosts.www_in_high_anomaly:: "HIGH ENTROPY Incoming www anomaly high anomaly dev!! on $(mon.host) at $(mon.env_time) - measured value $(mon.value_www_in) av $(mon.av_www_in) pm $(mon.dev_www_in)" showstate => { "incoming.www" }; entropy_www_in_low.anomaly_hosts.www_in_high_anomaly:: "LOW ENTROPY Incoming www anomaly high anomaly dev!! on $(mon.host) at $(mon.env_time) - measured value $(svalue_www_in) av $(av_www_in) pm $(dev_www_in)" showstate => { "incoming.www" }; entropy_tcpsyn_in_low.anomaly_hosts.tcpsyn_in_high_dev2:: "Anomalous number of new TCP connections on $(mon.host) at $(mon.env_time) - measured value $(mon.value_tcpsyn_in) av $(mon.av_tcpsyn_in) pm $(mon.dev_tcpsyn_in)" showstate => { "incoming.tcpsyn" }; entropy_dns_in_low.anomaly_hosts.dns_in_high_anomaly:: "Anomalous (3dev) incoming DNS packets on $(mon.host) at $(mon.env_time) - measured value $(mon.value_dns_in) av $(av_dns_in) pm $(mon.dev_dns_in)" showstate => { "incoming.dns" }; entropy_dns_in_low.anomaly_hosts.udp_in_high_dev2:: "Anomalous (2dev) incoming (non-DNS) UDP traffic on $(mon.host) at $(mon.env_time) - measured value $(mon.value_udp_in) av $(mon.av_udp_in) pm $(mon.dev_udp_in)" showstate => { "incoming.udp" }; anomaly_hosts.icmp_in_high_anomaly.!entropy_icmp_in_high:: "Anomalous low entropy (3dev) incoming ICMP traffic on $(mon.host) at $(mon.env_time) - measured value $(mon.value_icmp_in) av $(mon.av_icmp_in) pm $(mon.dev_icmp_in)" showstate => { "incoming.icmp" }; } ####################################################### # Server configuration ####################################################### bundle server access_rules() { access: "/home/mark/LapTop" admit => { "127.0.0.1" }; "/home/mark/.cfagent/bin/cf-agent" admit => { "127.0.0.1" }; roles: ".*" authorize => { "mark" }; } ######################################################## bundle edit_line upgrade_cfexecd { classes: "exec_fix" not => regline(".*cf-execd.*","$(edit.filename)"); insert_lines: exec_fix:: "0,5,10,15,20,25,30,35,40,45,50,55 * * * * /var/cfengine/bin/cf-execd -F"; replace_patterns: "cfexecd" replace_with => value("cf-execd"); reports: exec_fix:: "Added a 5 minute schedule to crontabs"; } ####################################################### body edit_defaults def { empty_file_before_editing => "false"; edit_backup => "false"; max_file_size => "100000"; } cfengine-3.2.4/examples/unit_report_custom.cf0000644000175000017500000000324311707771422016325 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "test" }; } bundle agent test { vars: "software" slist => { "gpg", "zip", "rsync" }; classes: "noreport" expression => fileexists("/tmp/report.html"); "have_$(software)" expression => fileexists("/usr/bin/$(software)"); reports: no_report:: " Name of this host is: $(sys.host)
Type of this host is: $(sys.os)
" report_to_file => "/tmp/report.html"; # " Host has software $(software)
" ifvarclass => "have_$(software)", report_to_file => "/tmp/report.html"; # " " report_to_file => "/tmp/report.html"; } cfengine-3.2.4/examples/unit_neighbourhood_watch.cf0000644000175000017500000000465511715232734017447 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Change detect # ######################################################## body common control { bundlesequence => { "neighbourhood_watch" }; } ######################################################## bundle agent neighbourhood_watch { vars: "neighbours" slist => peers("/var/cfengine/inputs/hostlist","#.*",4); files: # Redundant cross monitoring ....................................... "$(sys.workdir)/nw/$(neighbours)_checksum_digests.db" comment => "Watch our peers remote hash tables and keep a local copy", copyfrom => rcp("$(sys.workdir)/checksum_digests.db",$(neighbours)), depends_on => { "grant_hash_tables" }; # Define the actual children to watch over ......................... "/usr/bin" comment => "Watch over the system binaries - changes are mostly updates", changes => lay_trip_wire, depth_search => recurse("inf"), action => measure; } ######################################################### body changes lay_trip_wire { hash => "best"; report_changes => "content"; update_hashes => "yes"; } ######################################################### body copy_from rcp(from,server) { servers => { "$(server)" }; source => "$(from)"; compare => "digest"; encrypt => "false"; } ########################################################## body depth_search recurse(d) { depth => "$(d)"; } cfengine-3.2.4/examples/unit_regline.cf0000644000175000017500000000307011707771422015043 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ###################################################################### # Function regline(regex,file) ###################################################################### body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/tmp/testfile" edit_line => test; } ######################################################## bundle edit_line test { classes: "ok" expression => regline(".*mark.*","$(edit.filename)"); reports: ok:: "File matched $(edit.filename)"; } cfengine-3.2.4/examples/unit_ldap.cf0000644000175000017500000000473311707771422014345 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # body common control { bundlesequence => { "ldap" , "followup"}; } ################################################################################################### # NOTE!! relying on LDAP or other network data without validation is EXTREMELY dangerous. # You could destroy a system by assuming that the service will respond with a # sensible result. Cfengine does not recommend reliance on network services in configuration. ################################################################################################### bundle agent ldap { vars: # Get the first matching value for "uid" "value" string => ldapvalue("ldap://eternity.iu.hio.no","dc=cfengine,dc=com","(sn=User)","uid","subtree","none"); # Geta all matching values for "uid" - should be a single record match "list" slist => ldaplist("ldap://eternity.iu.hio.no","dc=cfengine,dc=com","(sn=User)","uid","subtree","none"); classes: "gotdata" expression => ldaparray("myarray","ldap://eternity.iu.hio.no","dc=cfengine,dc=com","(uid=mark)","subtree","none"); "found" expression => regldap("ldap://eternity.iu.hio.no","dc=cfengine,dc=com","(sn=User)","uid","subtree","jon.*","none"); reports: linux:: "LDAP VALUE $(value) found"; "LDAP LIST VALUE $(list)"; gotdata:: "Found specific entry data ...$(ldap.myarray[uid]),$(ldap.myarray[gecos]), etc"; found:: "Matched regex"; } bundle agent followup { reports: linux:: "Different bundle ...$(ldap.myarray[uid]),$(ldap.myarray[gecos]), etc"; }cfengine-3.2.4/examples/unit_groupexists.cf0000644000175000017500000000245511707771422016020 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "gname" expression => groupexists("users"); "gid" expression => groupexists("100"); reports: gname:: "Group exists by name"; gid:: "Group exists by id"; } cfengine-3.2.4/examples/unit_peers.cf0000644000175000017500000000252611707771422014541 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "peers" }; } # bundle agent peers { vars: "mygroup" slist => peers("/tmp/hostlist","#.*",4); "myleader" string => peerleader("/tmp/hostlist","#.*",4); "all_leaders" slist => peerleaders("/tmp/hostlist","#.*",4); reports: linux:: "mypeer *$(mygroup)*"; "myleader *$(myleader)*"; "another leader *$(all_leaders)*"; }cfengine-3.2.4/examples/Makefile.in0000644000175000017500000005160411715232775014122 00000000000000# Makefile.in generated by automake 1.11.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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@ target_triplet = @target@ subdir = examples DIST_COMMON = $(dist_examples_DATA) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \ $(top_srcdir)/m4/cf3_with_library.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)/src/conf.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' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(examplesdir)" DATA = $(dist_examples_DATA) 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 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@ BERKELEYDB_CFLAGS = @BERKELEYDB_CFLAGS@ BERKELEYDB_LDFLAGS = @BERKELEYDB_LDFLAGS@ BERKELEYDB_LIBS = @BERKELEYDB_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EIGHTBIT = @EIGHTBIT@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GCC_CFLAG = @GCC_CFLAG@ GETCONF = @GETCONF@ GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ GREP = @GREP@ HOSTNAME = @HOSTNAME@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ KMEM_GROUP = @KMEM_GROUP@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_SELINUX = @LIB_SELINUX@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MYSQL_CFLAGS = @MYSQL_CFLAGS@ MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@ MYSQL_LDFLAGS = @MYSQL_LDFLAGS@ MYSQL_LIBS = @MYSQL_LIBS@ MYSQL_PATH = @MYSQL_PATH@ NEED_SETGID = @NEED_SETGID@ NM = @NM@ NMEDIT = @NMEDIT@ NOWRAP = @NOWRAP@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_CPPFLAGS = @OPENSSL_CPPFLAGS@ OPENSSL_LDFLAGS = @OPENSSL_LDFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OPENSSL_PATH = @OPENSSL_PATH@ 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@ PCRE_CFLAGS = @PCRE_CFLAGS@ PCRE_CPPFLAGS = @PCRE_CPPFLAGS@ PCRE_LDFLAGS = @PCRE_LDFLAGS@ PCRE_LIBS = @PCRE_LIBS@ PCRE_PATH = @PCRE_PATH@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_CPPFLAGS = @POSTGRESQL_CPPFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_LIBS = @POSTGRESQL_LIBS@ POSTGRESQL_PATH = @POSTGRESQL_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ TOKYOCABINET_CFLAGS = @TOKYOCABINET_CFLAGS@ TOKYOCABINET_CPPFLAGS = @TOKYOCABINET_CPPFLAGS@ TOKYOCABINET_LDFLAGS = @TOKYOCABINET_LDFLAGS@ TOKYOCABINET_LIBS = @TOKYOCABINET_LIBS@ TOKYOCABINET_PATH = @TOKYOCABINET_PATH@ 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_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ workdir = @workdir@ SUBDIRS = example_config DIST_SUBDIRS = example_config examplesdir = @docdir@/examples dist_examples_DATA = $(srcdir)/*.cf MAINTAINERCLEANFILES = Makefile.in mdate-sh all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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) --gnu examples/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu examples/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(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 install-dist_examplesDATA: $(dist_examples_DATA) @$(NORMAL_INSTALL) test -z "$(examplesdir)" || $(MKDIR_P) "$(DESTDIR)$(examplesdir)" @list='$(dist_examples_DATA)'; test -n "$(examplesdir)" || 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)$(examplesdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(examplesdir)" || exit $$?; \ done uninstall-dist_examplesDATA: @$(NORMAL_UNINSTALL) @list='$(dist_examples_DATA)'; test -n "$(examplesdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(examplesdir)'; $(am__uninstall_files_from_dir) # 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 $(DATA) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(examplesdir)"; 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) 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-dist_examplesDATA 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: uninstall-dist_examplesDATA .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-dist_examplesDATA 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 \ uninstall-dist_examplesDATA # 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: cfengine-3.2.4/examples/unit_template.cf0000644000175000017500000000322511707771422015233 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test editfile - template expansion # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/home/mark/tmp/file_based_on_template" create => "true", edit_line => ExpandMeFrom("/tmp/source_template"); } ######################################################## bundle edit_line ExpandMeFrom(template) { vars: "myvar" string => "[sub string]"; insert_lines: "$(template)" insert_type => "file", expand_scalars => "true"; } cfengine-3.2.4/examples/unit_reporting.cf0000644000175000017500000000275611715232734015436 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "none" }; } body reporter control { reports => { # "audit", # "performance", # "all_locks", # "active_locks", # "hashes", # "classes", # "last_seen", #"monitor_now", #"monitor_history" #"monitor_summary" "compliance", "file_changes", "setuid" }; build_directory => "/home/mark/tmp/reports"; # html,xml,csv,text report_output => "html"; } cfengine-3.2.4/examples/unit_id.cf0000644000175000017500000000474211707771422014021 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test of promise references # ######################################################## body common control { bundlesequence => { "testbundle" }; version => "1.2.3"; } ######################################################## bundle agent testbundle { vars: classes: files: "/home/mark/tmp/testcopy" handle => "update_rule", copy_from => mycopy("/home/mark/LapTop/words","127.0.0.1"), perms => system, depth_search => recurse("inf"); } ######################################################### body perms system { mode => "0644"; } ######################################################### body depth_search recurse(d) { depth => "$(d)"; } ######################################################### body copy_from mycopy(from,server) { source => "$(from)"; servers => { "$(server)" }; copy_backup => "true"; #/false/timestamp purge => "false"; type_check => "true"; force_ipv4 => "true"; } ######################################################### # Server config ######################################################### body server control { allowconnects => { "127.0.0.1" , "::1" }; allowallconnects => { "127.0.0.1" , "::1" }; trustkeysfrom => { "127.0.0.1" , "::1" }; } ######################################################### bundle server access_rules() { access: "/home/mark/LapTop" handle => "update_rule", admit => { "127.0.0.1" }; } cfengine-3.2.4/examples/unit_package_apt.cf0000644000175000017500000000506711707771422015665 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # to see list of packages type "apt-cache pkgnames" # to see list of installed packages type "dpkg --get-selections" # # Package managment # body common control { bundlesequence => { "packages" }; } body agent control { environment => { "DEBIAN_FRONTEND=noninteractive" }; } ############################################# bundle agent packages { vars: # Test the simplest case -- leave everything to the yum smart manager "match_package" slist => { "apache2" # "apache2-mod_php5", # "apache2-prefork", # "php5" }; packages: "$(match_package)" package_policy => "add", package_method => apt; } ############################################# body package_method apt { any:: # ii acpi 0.09-3ubuntu1 package_changes => "bulk"; package_list_command => "/usr/bin/dpkg -l"; package_list_name_regex => "ii\s+([^\s]+).*"; package_list_version_regex => "ii\s+[^\s]+\s+([^\s]+).*"; # package_list_arch_regex => "none"; package_installed_regex => ".*"; # all reported are installed #package_name_convention => "$(name)_$(version)_$(arch)"; package_name_convention => "$(name)"; # Use these only if not using a separate version/arch string # package_version_regex => ""; # package_name_regex => ""; # package_arch_regex => ""; package_add_command => "/usr/bin/apt-get --yes install"; package_delete_command => "/usr/bin/apt-get --yes remove"; package_update_command => "/usr/bin/apt-get --yes dist-upgrade"; #package_verify_command => "/bin/rpm -V"; } cfengine-3.2.4/examples/unit_disable.cf0000644000175000017500000000233111707771422015020 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "my_disable" }; inputs => { "cfengine_stdlib.cf" }; } bundle agent my_disable { files: "/home/mark/tmp/test_create" rename => disable; "/home/mark/tmp/rotate_my_log" rename => rotate("4"); } cfengine-3.2.4/examples/unit_getregistry.cf0000755000175000017500000000230411707771422015770 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "reg" }; } bundle agent reg { vars: "value" string => registryvalue("HKEY_LOCAL_MACHINE\SOFTWARE\Cfengine AS\Cfengine","value3"); reports: windows:: "Value extracted: $(value)"; } cfengine-3.2.4/examples/unit_vars.cf0000644000175000017500000000224311707771422014372 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => {"yes"}; } bundle agent yes { vars: "var" string => "/one/two/last1", comment => "This is a comment"; reports: Yr2009:: "Test = $(var)"; }cfengine-3.2.4/examples/unit_customize_by_named_list.cf0000644000175000017500000000477211715232734020340 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test - copy from a single directory of spec files # generating multiple directories and special # edits. # ######################################################## body common control { bundlesequence => { "virtualhosts" }; version => "1.2.3"; } ######################################################## bundle agent virtualhosts { vars: "vmbase" string => "/home/mark/tmp/vm"; "source_files" string => "/home/mark/tmp/src"; # list of hosts to create "hostlist" slist => { "host1", "host2", "host3", "host4", "host5", "host6", "host7", "host8", "host9" }; ################### or just a new file to the dir ################ # # "hostlist" slist => { SelectFilesIn("$(source_files)",".*") } # ################################################################## files: "$(vmbase)/$(hostlist)/config_for_$(hostlist).vm" copy_from => buildvm("$(source_files)/template_$(hostlist)"); # # Now edit config .e.g. edit in $(ipadr[$(hostlist)]) for each # } ######################################################### # library template ######################################################### body copyfrom buildvm(from) { source => "$(from)"; copy_backup => "true"; #/false/timestamp } cfengine-3.2.4/examples/unit_server_copy_localhost.cf0000644000175000017500000000632011707771422020027 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test copy from server connection to cfServer # ######################################################## # # run this as follows: # # cf-serverd -f runtest_1.cf [-v] # cf-agent -f runtest_2.cf # # Notice that the same file configures all parts of cfengine ######################################################## body common control { bundlesequence => { "testbundle" }; version => "1.2.3"; #fips_mode => "true"; } ######################################################## bundle agent testbundle { files: "/home/mark/tmp/testcopy" comment => "test copy promise", copy_from => mycopy("/home/mark/LapTop/words","127.0.0.1"), perms => system, depth_search => recurse("inf"), classes => satisfied("copy_ok"); "/home/mark/tmp/testcopy/single_file" comment => "test copy promise", copy_from => mycopy("/home/mark/LapTop/Cfengine3/trunk/README","127.0.0.1"), perms => system; reports: copy_ok:: "Files were copied.."; } ######################################################### body perms system { mode => "0644"; } ######################################################### body depth_search recurse(d) { depth => "$(d)"; } ######################################################### body copy_from mycopy(from,server) { source => "$(from)"; servers => { "$(server)" }; compare => "digest"; encrypt => "true"; verify => "true"; copy_backup => "true"; #/false/timestamp purge => "false"; type_check => "true"; force_ipv4 => "true"; trustkey => "true"; } ######################################################### body classes satisfied(x) { promise_repaired => { "$(x)" }; persist_time => "0"; } ######################################################### # Server config ######################################################### body server control { allowconnects => { "127.0.0.1" , "::1" }; allowallconnects => { "127.0.0.1" , "::1" }; trustkeysfrom => { "127.0.0.1" , "::1" }; # allowusers } ######################################################### bundle server access_rules() { access: "/home/mark/LapTop" admit => { "127.0.0.1" }; } cfengine-3.2.4/examples/unit_copylinks.cf0000644000175000017500000000375211707771422015440 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test copy with link/copy exceptions # ######################################################## ######################################################## body common control { bundlesequence => { "testbundle" }; version => "1.2.3"; } ######################################################## bundle agent testbundle { files: "/home/mark/tmp/test_to" copy_from => mycopy("/home/mark/tmp/test_from"), perms => system, move_obstructions => "true", depth_search => recurse("inf"); } ######################################################### body perms system { mode => "0644"; } ######################################################### body depth_search recurse(d) { depth => "$(d)"; } ######################################################### body copy_from mycopy(from) { source => "$(from)"; #copylink_patterns => { ".*" }; # copy all links linkcopy_patterns => { ".*" }; # copy all links #copy_backup => "timestamp"; } cfengine-3.2.4/examples/unit_pattern_and_edit.cf0000644000175000017500000000274111715232734016723 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => {"test"}; } ######################################################## bundle agent test { files: "/home/(.*)/testfile" create => "true", edit_line => AppendIfNoLine("key_$(match.1)"); } ######################################################## bundle edit_line AppendIfNoLine(x) { insert_lines: "Line $(x)" location => "append"; } ######################################################## body location append { before_after => "before"; } cfengine-3.2.4/examples/unit_readtcp.cf0000644000175000017500000000273511707771422015047 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "my80" string => readtcp("research.iu.hio.no","80","GET /index.php HTTP/1.1$(const.r)$(const.n)Host: research.iu.hio.no$(const.r)$(const.n)$(const.r)$(const.n)",20); classes: "server_ok" expression => regcmp(".*200 OK.*\n.*","$(my80)"); reports: server_ok:: "Server is alive"; !server_ok:: "Server is not responding - got $(my80)"; } cfengine-3.2.4/examples/cfengine_stdlib.cf0000644000175000017500000010370511715232734015501 00000000000000########################################################################### # Copyright (C) Cfengine AS # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License LGPL as published by the # Free Software Foundation; version 3. # # 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. # # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ########################################################################### # # Cfengine Community Open Promise-Body Library # # This initiative started by Cfengine promotes a # standardized set of names and promise specifications # for template functionality within Cfengine 3. # # The aim is to promote an industry standard for # naming of configuration patterns, leading to a # de facto middleware of standardized syntax. # # Names should be intuitive and parameters should be # minimal to assist readability and comprehensibility. # Contributions to this file are voluntarily given to # the cfengine community, and are moderated by Cfengine. # No liability or warranty for misuse is implied. # # If you add to this file, please try to make the # contributions "self-documenting". Comments made # after the bundle/body statement are retained in # the online docs # # Subversion : $Rev: 95 $ # For Cfengine Core: 3.1.0 ################################################### # If you find Cfengine useful, please consider # # purchasing a commercial version of the software.# ################################################### ################################################### # edit_line bundles ################################################### bundle edit_line insert_lines(lines) { insert_lines: "$(lines)" comment => "Append lines if they don't exist"; } ## bundle edit_line insert_file(templatefile) { insert_lines: "$(templatefile)" comment => "Insert the template file into the file being edited", insert_type => "file"; } ## bundle edit_line comment_lines_matching(regex,comment) # Comment lines of a file matching a regex { replace_patterns: "^($(regex))$" replace_with => comment("$(comment)"), comment => "Search and replace string"; } ## bundle edit_line uncomment_lines_matching(regex,comment) # Uncomment lines of a file where the regex matches # the text after the comment string { replace_patterns: "^$(comment)\s?($(regex))$" replace_with => uncomment, comment => "Uncomment lines matching a regular expression"; } ## bundle edit_line comment_lines_containing(regex,comment) # Comment lines of a file containing a regex { replace_patterns: "^(.*$(regex).*)$" replace_with => comment("$(comment)"), comment => "Comment out lines in a file"; } ## bundle edit_line uncomment_lines_containing(regex,comment) # Uncomment lines of a file where the regex matches # the text after the comment string { replace_patterns: "^$(comment)\s?(.*$(regex).*)$" replace_with => uncomment, comment => "Uncomment a line containing a fragment"; } ## bundle edit_line delete_lines_matching(regex) { delete_lines: "$(regex)" comment => "Delete lines matching regular expressions"; } ## bundle edit_line warn_lines_matching(regex) { delete_lines: "$(regex)" comment => "Warn about lines in a file", action => warn_only; } ## bundle edit_line append_if_no_line(str) { insert_lines: "$(str)" comment => "Append a line to the file if it doesn't already exist"; } ## bundle edit_line append_if_no_lines(list) { insert_lines: "$(list)" comment => "Append lines to the file if they don't already exist"; } ## bundle edit_line replace_line_end(start,end) # # Lines starting with "$(start)" will get the ending given in "$(end)", # whitespaces will be left unmodified. # For example, replace_line_end("ftp", "2121/tcp") would replace # "ftp 21/tcp" # with # "ftp 2121/tcp" { field_edits: "\s*$(start)\s.*" edit_field => line("(^|\s)$(start)\s*", "2", "$(end)","set"); } ## bundle edit_line append_to_line_end(start,end) # # Lines starting with "$(start)" and not ending with "$(end)" # will get appended with "$(end)", whitespaces will be left unmodified. # For example, append_to_line_end("kernel", "vga=791") would replace # "kernel /boot/vmlinuz root=/dev/sda7" # with # "kernel /boot/vmlinuz root=/dev/sda7 resume=/dev/sda9 vga=791" # # WARNING: Be careful not to have multiple promises matching the same line, # which would result in the line growing indefinetively. { field_edits: "\s*$(start)\s.*" edit_field => line("(^|\s)$(start)\s*", "2", "$(end)","append"); } ## bundle edit_line resolvconf(search,list) # search is the search domains with space # list is an slist of nameserver addresses { delete_lines: "search.*" comment => "Reset search lines from resolver"; "nameserver.*" comment => "Reset nameservers in resolver"; insert_lines: "search $(search)" comment => "Add search domains to resolver"; "nameserver $(list)" comment => "Add name servers to resolver"; } ## bundle edit_line set_variable_values(v) # Sets the RHS of variables in the file of the form # LHS = RHS # Adds a new line if no LHS exists, repairs RHS values if one does exist # # To use: # 1) Define an array, where the keys are the LHS and the values are the RHS # "stuff[lhs-1]" string => "rhs1"; # "stuff[lhs-2]" string => "rhs2"; # 2) The parameter passed to the edit_line promise is the fully qualified # name of the array (i.e., "bundlename.stuff") WITHOUT any "$" or "@" { vars: "index" slist => getindices("$(v)"); # Be careful if the index string contains funny chars "cindex[$(index)]" string => canonify("$(index)"); field_edits: # match a line starting like the key = something "\s*$(index)\s*=.*" edit_field => col("=","2","$($(v)[$(index)])","set"), classes => if_ok("$(cindex[$(index)])_in_file"), comment => "Match a line starting like key = something"; insert_lines: "$(index)=$($(v)[$(index)])", comment => "Insert a variable definition", ifvarclass => "!$(cindex[$(index)])_in_file"; } ## bundle edit_line set_variable_values2(file,v) # # Another implementation of set_variable_values. # The input and output should be exactly the same (except the file name), # but in some Cfengine versions there are bugs, # so this bundle can be used as a workaround. # { vars: "index" slist => getindices("$(v)"); # Be careful if the index string contains funny chars "cindex[$(index)]" string => canonify("$(index)"); "fieldc_$(cindex[$(index)])" int => getfields("$(index).*","$(file)","=","FIELD_$(cindex[$(index)])"); classes: "$(cindex[$(index)])_in_file" expression => strcmp("$(index)=$($(v)[$(index)])", "$(FIELD_$(index)[1])=$(FIELD_$(index)[2])"); delete_lines: # delete any lhs when no match "$(index)=.*", ifvarclass => "!$(cindex[$(index)])_in_file"; insert_lines: "$(index)=$($(v)[$(index)])", comment => "Insert a variable definition", ifvarclass => "!$(cindex[$(index)])_in_file"; } ## bundle edit_line append_users_starting(v) # For adding to /etc/passwd or etc/shadow, needs # an array v[username] string => "line..." { vars: "index" slist => getindices("$(v)"); classes: "add_$(index)" not => userexists("$(index)"); insert_lines: "$($(v)[$(index)])", comment => "Append users into a password file format", ifvarclass => "add_$(index)"; } ## bundle edit_line append_groups_starting(v) # For adding groups to /etc/group, needs # an array v[groupname] string => "line..." { vars: "index" slist => getindices("$(v)"); classes: "add_$(index)" not => groupexists("$(index)"); insert_lines: "$($(v)[$(index)])", comment => "Append users into a group file format", ifvarclass => "add_$(index)"; } ## bundle edit_line set_user_field(user,field,val) # Set the value of field number "field" in # a :-field formatted file like /etc/passwd { field_edits: "$(user):.*" comment => "Edit a user attribute in the password file", edit_field => col(":","$(field)","$(val)","set"); } ## bundle edit_line append_user_field(group,field,allusers) # For adding users to to a file like /etc/group # at field position "field", comma separated subfields { vars: "val" slist => { @(allusers) }; field_edits: "$(group):.*" comment => "Append users into a password file format", edit_field => col(":","$(field)","$(val)","alphanum"); } ## bundle edit_line expand_template(templatefile) # Read in the named text file and expand $(var) # inside the file { insert_lines: "$(templatefile)" insert_type => "file", comment => "Expand variables in the template file", expand_scalars => "true"; } ## bundle agent cronjob(commands,user,hours,mins) # For adding lines to crontab for a user # methods: # "cron" usebundle => cronjob("/bin/ls","mark","*","5,10"); { vars: SuSE:: "crontab" string => "/var/spool/cron/tabs"; redhat|fedora:: "crontab" string => "/var/spool/cron"; !(SuSE|redhat|fedora):: "crontab" string => "/var/spool/cron/crontabs"; files: !windows:: "$(crontab)/$(user)" comment => "A user's regular batch jobs are added to this file", create => "true", edit_line => append_if_no_line("$(mins) $(hours) * * * $(commands)"), perms => mo("644","$(user)"), classes => if_repaired("changed_crontab"); processes: changed_crontab:: "cron" comment => "Most crons need to be huped after file changes", signals => { "hup" }; } ## ## editing bodies ## body edit_field quoted_var(newval,method) { field_separator => "\""; select_field => "2"; value_separator => " "; field_value => "$(newval)"; field_operation => "$(method)"; extend_fields => "false"; allow_blank_fields => "true"; } ## body edit_field col(split,col,newval,method) { field_separator => "$(split)"; select_field => "$(col)"; value_separator => ","; field_value => "$(newval)"; field_operation => "$(method)"; extend_fields => "true"; allow_blank_fields => "true"; } ## body edit_field line(split,col,newval,method) { field_separator => "$(split)"; select_field => "$(col)"; value_separator => " "; field_value => "$(newval)"; field_operation => "$(method)"; extend_fields => "true"; allow_blank_fields => "true"; } ## body replace_with value(x) { replace_value => "$(x)"; occurrences => "all"; } ## body select_region INI_section(x) { select_start => "\[$(x)\]\s*"; select_end => "\[.*\]\s*"; } ## ## edit_defaults ## body edit_defaults std_defs { empty_file_before_editing => "false"; edit_backup => "false"; max_file_size => "300000"; } ## body edit_defaults empty { empty_file_before_editing => "true"; edit_backup => "false"; max_file_size => "300000"; } ## body edit_defaults no_backup { edit_backup => "false"; } ## ## location ## body location start { before_after => "before"; } ## body location after(str) { before_after => "after"; select_line_matching => "$(str)"; } ## ## replace_with ## ## body replace_with comment(c) { replace_value => "$(c) $(match.1)"; occurrences => "all"; } ## body replace_with uncomment { replace_value => "$(match.1)"; occurrences => "all"; } #################################################### ## agent bodyparts #################################################### ## ## action ## body action if_elapsed(x) { ifelapsed => "$(x)"; expireafter => "$(x)"; } ## body action measure_performance(x) { measurement_class => "Detect changes in $(this.promiser)"; ifelapsed => "$(x)"; expireafter => "$(x)"; } ## body action warn_only { action_policy => "warn"; ifelapsed => "60"; } ## body action bg(elapsed,expire) { ifelapsed => "$(elapsed)"; expireafter => "$(expire)"; background => "true"; } ## body action ifwin_bg { windows:: background => "true"; } ## body action immediate { ifelapsed => "0"; } ## body action policy(p) { action_policy => "$(p)"; } ## # Log a message to log=[/file|stdout] body action log_repaired(log,message) { log_string => "$(sys.date), $(message)"; log_repaired => "$(log)"; } ## ## contain ## body contain silent { no_output => "true"; } ## body contain in_dir(s) { chdir => "$(s)"; } ## body contain in_dir_shell(s) { chdir => "$(s)"; useshell => "true"; } ## body contain silent_in_dir(s) { chdir => "$(s)"; no_output => "true"; } ## body contain in_shell { useshell => "true"; } ## body contain in_shell_and_silent { useshell => "true"; no_output => "true"; } ## body contain setuid(x) { exec_owner => "$(x)"; useshell => "false"; } ## body contain setuid_sh(x) { exec_owner => "$(x)"; useshell => "true"; } ## body contain setuidgid_sh(owner,group) { exec_owner => "$(owner)"; exec_group => "$(group)"; useshell => "true"; } ## body contain jail(owner,root,dir) { exec_owner => "$(owner)"; useshell => "true"; chdir => "$(dir)"; chroot => "$(root)"; } ## ## classes ## body classes if_repaired(x) { promise_repaired => { "$(x)" }; } ## body classes if_else(yes,no) { promise_kept => { "$(yes)" }; promise_repaired => { "$(yes)" }; repair_failed => { "$(no)" }; repair_denied => { "$(no)" }; repair_timeout => { "$(no)" }; } ## body classes cf2_if_else(yes,no) # meant to match cf2 semantics { promise_repaired => { "$(yes)" }; repair_failed => { "$(no)" }; repair_denied => { "$(no)" }; repair_timeout => { "$(no)" }; } ## body classes if_notkept(x) { repair_failed => { "$(x)" }; repair_denied => { "$(x)" }; repair_timeout => { "$(x)" }; } ## body classes if_ok(x) { promise_repaired => { "$(x)" }; promise_kept => { "$(x)" }; } ## body classes cmd_repair(code,cl) { repaired_returncodes => { "$(code)" }; promise_repaired => { "$(cl)" }; } ## ## Persistent classes ## body classes state_repaired(x) { promise_repaired => { "$(x)" }; persist_time => "10"; } ## body classes enumerate(x) # # This is used by commercial editions to count # instances of jobs in a cluster # { promise_repaired => { "mXC_$(x)" }; promise_kept => { "mXC_$(x)" }; persist_time => "15"; } ################################################### # agent bundles ################################################### ##.................................................. ## files promises ##.................................................. ## ## copy_from ## body copy_from secure_cp(from,server) { source => "$(from)"; servers => { "$(server)" }; compare => "digest"; encrypt => "true"; verify => "true"; } ## body copy_from remote_cp(from,server) { servers => { "$(server)" }; source => "$(from)"; compare => "mtime"; } ## body copy_from remote_dcp(from,server) { servers => { "$(server)" }; source => "$(from)"; compare => "digest"; } ## body copy_from local_cp(from) { source => "$(from)"; } ## body copy_from local_dcp(from) { source => "$(from)"; compare => "digest"; } ## body copy_from perms_cp(from) { source => "$(from)"; preserve => "true"; } ## # Copy only if the file does not already exist, i.e. seed the placement body copy_from seed_cp(from) { source => "$(from)"; compare => "exists"; } ## body copy_from sync_cp(from,server) { servers => { "$(server)" }; source => "$(from)"; purge => "true"; preserve => "true"; type_check => "false"; } ## body copy_from no_backup_cp(from) { source => "$(from)"; copy_backup => "false"; } ## body copy_from no_backup_dcp(from) { source => "$(from)"; copy_backup => "false"; compare => "digest"; } ## body copy_from no_backup_rcp(from,server) { servers => { "$(server)" }; source => "$(from)"; compare => "mtime"; copy_backup => "false"; } ## ## link_from ## body link_from ln_s(x) { link_type => "symlink"; source => "$(x)"; when_no_source => "force"; } ## body link_from linkchildren(tofile) { source => "$(tofile)"; link_type => "symlink"; when_no_source => "force"; link_children => "true"; when_linking_children => "if_no_such_file"; # "override_file"; } ## ## perms ## body perms m(mode) { mode => "$(mode)"; } ## body perms mo(mode,user) { owners => { "$(user)" }; mode => "$(mode)"; } ## body perms mog(mode,user,group) { owners => { "$(user)" }; groups => { "$(group)" }; mode => "$(mode)"; } ## body perms og(u,g) { owners => { "$(u)" }; groups => { "$(g)" }; } ## body perms owner(user) { owners => { "$(user)" }; } ## ## ACLS (extended Unix perms) ## body acl access_generic(acl) # default/inherited ACLs are left unchanged, # applicable for both files and directory on all platforms { acl_method => "overwrite"; aces => { "@(acl)" }; } ## body acl ntfs(acl) { acl_type => "ntfs"; acl_method => "overwrite"; aces => { "@(acl)" }; } ## body acl strict # NOTE: May need to take ownership of file/dir # to be sure no-one else is allowed access { acl_method => "overwrite"; windows:: aces => { "user:Administrator:rwx" }; !windows:: aces => { "user:root:rwx" }; } ## ## depth_search ## body depth_search recurse(d) { depth => "$(d)"; xdev => "true"; } ## body depth_search recurse_ignore(d,list) { depth => "$(d)"; exclude_dirs => { @(list) }; } ## body depth_search include_base { include_basedir => "true"; } ## ## delete ## body delete tidy { dirlinks => "delete"; rmdirs => "true"; } ## ## rename ## body rename disable { disable => "true"; } ## body rename rotate(level) { rotate => "$(level)"; } ## body rename to(file) { newname => "$(file)"; } ## ## file_select ## body file_select name_age(name,days) { leaf_name => { "$(name)" }; mtime => irange(0,ago(0,0,"$(days)",0,0,0)); file_result => "mtime.leaf_name"; } ## body file_select days_old(days) { mtime => irange(0,ago(0,0,"$(days)",0,0,0)); file_result => "mtime"; } ## body file_select size_range(from,to) { search_size => irange("$(from)","$(to)"); file_result => "size"; } ## body file_select exclude(name) { leaf_name => { "$(name)"}; file_result => "!leaf_name"; } ## body file_select plain { file_types => { "plain" }; file_result => "file_types"; } body file_select dirs { file_types => { "dir" }; file_result => "file_types"; } ## body file_select by_name(names) { leaf_name => { @(names)}; file_result => "leaf_name"; } ## body file_select ex_list(names) { leaf_name => { @(names)}; file_result => "!leaf_name"; } ## ## changes ## body changes detect_all_change # This is fierce, and will cost disk cycles { hash => "best"; report_changes => "all"; update_hashes => "yes"; } ## body changes detect_content # This is a cheaper alternative { hash => "md5"; report_changes => "content"; update_hashes => "yes"; } ## body changes noupdate # Use on (small) files that should never change { hash => "sha256"; report_changes => "content"; update_hashes => "no"; } ## body changes diff # Generates diff report (Nova and above) { hash => "sha256"; report_changes => "content"; report_diffs => "true"; update_hashes => "yes"; } ## body changes diff_noupdate { hash => "sha256"; report_changes => "content"; report_diffs => "true"; update_hashes => "no"; } ##-------------------------------------------------------------- ## Packages promises ##-------------------------------------------------------------- body package_method zypper { package_changes => "bulk"; package_list_command => "/bin/rpm -qa --queryformat \"i | repos | %{name} | %{version}-%{release} | %{arch}\n\""; # set it to "0" to avoid caching of list during upgrade package_list_update_ifelapsed => "240"; package_patch_list_command => "/usr/bin/zypper patches"; package_installed_regex => "i.*"; package_list_name_regex => "[^|]+\|[^|]+\|\s+([^\s]+).*"; package_list_version_regex => "[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_list_arch_regex => "[^|]+\|[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_patch_installed_regex => ".*Installed.*|.*Not Applicable.*"; package_patch_name_regex => "[^|]+\|\s+([^\s]+).*"; package_patch_version_regex => "[^|]+\|[^|]+\|\s+([^\s]+).*"; package_name_convention => "$(name)"; package_add_command => "/usr/bin/zypper --non-interactive install"; package_delete_command => "/usr/bin/zypper --non-interactive remove --force-resolution"; package_update_command => "/usr/bin/zypper --non-interactive update"; package_patch_command => "/usr/bin/zypper --non-interactive patch$"; # $ means no args package_verify_command => "/usr/bin/zypper --non-interactive verify$"; } ## body package_method apt { package_changes => "bulk"; package_list_command => "/usr/bin/dpkg -l"; package_list_name_regex => "ii\s+([^\s]+).*"; package_list_version_regex => "ii\s+[^\s]+\s+([^\s]+).*"; package_installed_regex => ".*"; # all reported are installed package_name_convention => "$(name)"; # set it to "0" to avoid caching of list during upgrade package_list_update_ifelapsed => "240"; have_aptitude:: package_add_command => "/usr/bin/aptitude --assume-yes install"; package_list_update_command => "/usr/bin/aptitude update"; package_delete_command => "/usr/bin/aptitude --assume-yes remove"; package_update_command => "/usr/bin/aptitude --assume-yes install"; package_verify_command => "/usr/bin/aptitude show"; package_noverify_regex => "(State: not installed|E: Unable to locate package .*)"; !have_aptitude:: package_add_command => "/usr/bin/apt-get --yes install"; package_list_update_command => "/usr/bin/apt-get update"; package_delete_command => "/usr/bin/apt-get --yes remove"; package_update_command => "/usr/bin/apt-get --yes install"; package_verify_command => "/usr/bin/dpkg -s"; package_noverify_returncode => "1"; } ## body package_method dpkg_version(repo) { package_changes => "individual"; package_list_command => "/usr/bin/dpkg -l"; # set it to "0" to avoid caching of list during upgrade package_list_update_ifelapsed => "240"; package_list_name_regex => "ii\s+([^\s]+).*"; package_list_version_regex => "ii\s+[^\s]+\s+([^\s]+).*"; package_installed_regex => ".*"; # all reported are installed package_file_repositories => { "$(repo)" }; debian.x86_64:: package_name_convention => "$(name)_$(version)_amd64.deb"; debian.i686:: package_name_convention => "$(name)_$(version)_i386.deb"; debian:: package_add_command => "/usr/bin/dpkg --install"; package_delete_command => "/usr/bin/dpkg --purge"; package_update_command => "/usr/bin/dpkg --install"; } ## body package_method rpm_version(repo) { package_changes => "individual"; package_list_command => "/bin/rpm -qa --queryformat \"i | repos | %{name} | %{version}-%{release} | %{arch}\n\""; # set it to "0" to avoid caching of list during upgrade package_list_update_ifelapsed => "240"; package_list_name_regex => "[^|]+\|[^|]+\|\s+([^\s|]+).*"; package_list_version_regex => "[^|]+\|[^|]+\|[^|]+\|\s+([^\s|]+).*"; package_list_arch_regex => "[^|]+\|[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_installed_regex => "i.*"; package_file_repositories => { "$(repo)" }; package_name_convention => "$(name)-$(version).$(arch).rpm"; package_add_command => "/bin/rpm -ivh "; package_update_command => "/bin/rpm -Uvh "; package_delete_command => "/bin/rpm -e --nodeps"; package_noverify_regex => ".*[^\s].*"; } ## body package_method msi_implicit(repo) # Use whole file name as promiser, e.g. "7-Zip-4.50-x86_64.msi", # the name, version and arch is then deduced from the promiser { package_changes => "individual"; package_file_repositories => { "$(repo)" }; package_installed_regex => ".*"; package_name_convention => "$(name)-$(version)-$(arch).msi"; package_delete_convention => "$(firstrepo)$(name)-$(version)-$(arch).msi"; package_name_regex => "^(\S+)-(\d+\.?)+"; package_version_regex => "^\S+-((\d+\.?)+)"; package_arch_regex => "^\S+-[\d\.]+-(.*).msi"; package_add_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_update_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_delete_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /x"; } ## body package_method msi_explicit(repo) # use software name as promiser, e.g. "7-Zip", and explicitly # specify any package_version and package_arch { package_changes => "individual"; package_file_repositories => { "$(repo)" }; package_installed_regex => ".*"; package_name_convention => "$(name)-$(version)-$(arch).msi"; package_delete_convention => "$(firstrepo)$(name)-$(version)-$(arch).msi"; package_add_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_update_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_delete_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /x"; } ## body package_method yum { package_changes => "bulk"; package_list_command => "/usr/bin/yum list installed"; package_patch_list_command => "/usr/bin/yum check-update"; # Remember to escape special characters like | package_list_name_regex => "([^.]+).*"; package_list_version_regex => "[^\s]\s+([^\s]+).*"; package_list_arch_regex => "[^.]+\.([^\s]+).*"; package_installed_regex => ".*(installed|\s+@).*"; package_name_convention => "$(name).$(arch)"; # set it to "0" to avoid caching of list during upgrade package_list_update_ifelapsed => "240"; package_patch_installed_regex => "^\s.*"; package_patch_name_regex => "([^.]+).*"; package_patch_version_regex => "[^\s]\s+([^\s]+).*"; package_patch_arch_regex => "[^.]+\.([^\s]+).*"; package_add_command => "/usr/bin/yum -y install"; package_update_command => "/usr/bin/yum -y update"; package_delete_command => "/bin/rpm -e --nodeps"; package_verify_command => "/bin/rpm -V"; } ## body package_method yum_rpm # Contributed by Trond Hasle Amundsen # More efficient package method for RedHat - uses rpm to list instead of yum # Notes: # - using $(name).$(arch) instead of $(name) for package_name_convention # causes uninstallation to fail. # - using allmatches to remove for all architectures # { package_changes => "bulk"; package_list_command => "/bin/rpm -qa --qf '%{name} %{version}-%{release} %{arch}\n'"; package_patch_list_command => "/usr/bin/yum check-update"; package_list_name_regex => "^(\S+?)\s\S+?\s\S+$"; package_list_version_regex => "^\S+?\s(\S+?)\s\S+$"; package_list_arch_regex => "^\S+?\s\S+?\s(\S+)$"; package_installed_regex => ".*"; package_name_convention => "$(name)"; package_patch_installed_regex => "^\s.*"; package_patch_name_regex => "([^.]+).*"; package_patch_version_regex => "[^\s]\s+([^\s]+).*"; package_patch_arch_regex => "[^.]+\.([^\s]+).*"; package_add_command => "/usr/bin/yum -y install"; package_update_command => "/usr/bin/yum -y update"; package_delete_command => "/bin/rpm -e --nodeps --allmatches"; package_verify_command => "/bin/rpm -V"; } ## # The solaris package system is poorly designed, with too many different # names to track. See the example in tests/units/unit_package_solaris.cf # to see how to use this body package_method solaris (pkgname, spoolfile, adminfile) { package_changes => "individual"; package_list_command => "/usr/bin/pkginfo -l"; package_multiline_start => "\s*PKGINST:\s+[^\s]+"; package_list_name_regex => "\s*PKGINST:\s+([^\s]+)"; package_list_version_regex => "\s*VERSION:\s+([^\s]+)"; package_list_arch_regex => "\s*ARCH:\s+([^\s]+)"; package_installed_regex => "\s*STATUS:\s*(completely|partially)\s+installed.*"; package_name_convention => "$(name)"; package_add_command => "/usr/sbin/pkgadd -n -a /tmp/$(adminfile) -d /tmp/$(spoolfile)"; package_delete_command => "/usr/sbin/pkgrm -n -a /tmp/$(adminfile)"; } ## # # The following bundle is part of a package setup for solaris, see unit examples # bundle edit_line create_solaris_admin_file { insert_lines: "mail= instance=unique partial=nocheck runlevel=nocheck idepend=nocheck rdepend=nocheck space=nocheck setuid=nocheck conflict=nocheck action=nocheck networktimeout=60 networkretries=3 authentication=quit keystore=/var/sadm/security proxy= basedir=default"; } ## body package_method freebsd { package_changes => "individual"; # Could use rpm for this package_list_command => "/usr/sbin/pkg_info"; # Remember to escape special characters like | package_list_name_regex => "([^\s]+)-.*"; package_list_version_regex => "[^\s]+-([^\s]+).*"; package_name_regex => "([^\s]+)-.*"; package_version_regex => "[^\s]+-([^\s]+).*"; package_installed_regex => ".*"; package_name_convention => "$(name)-$(version)"; package_add_command => "/usr/sbin/pkg_add -r"; package_delete_command => "/usr/sbin/pkg_delete"; } ## # Single bundle for all the similar managers simplifies promises body package_method generic { SuSE:: package_changes => "bulk"; package_list_command => "/usr/bin/zypper packages"; package_patch_list_command => "/usr/bin/zypper patches"; package_installed_regex => "i.*"; package_list_name_regex => "[^|]+\|[^|]+\|\s+([^\s]+).*"; package_list_version_regex => "[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_list_arch_regex => "[^|]+\|[^|]+\|[^|]+\|[^|]+\|\s+([^\s]+).*"; package_patch_installed_regex => ".*Installed.*|.*Not Applicable.*"; package_patch_name_regex => "[^|]+\|\s+([^\s]+).*"; package_patch_version_regex => "[^|]+\|[^|]+\|\s+([^\s]+).*"; package_name_convention => "$(name)"; package_add_command => "/usr/bin/zypper --non-interactive install"; package_delete_command => "/usr/bin/zypper --non-interactive remove --force-resolution"; package_update_command => "/usr/bin/zypper --non-interactive update"; package_patch_command => "/usr/bin/zypper --non-interactive patch$"; # $ means no args package_verify_command => "/usr/bin/zypper --non-interactive verify$"; redhat:: package_changes => "bulk"; package_list_command => "/usr/bin/yum list installed"; package_patch_list_command => "/usr/bin/yum check-update"; package_list_name_regex => "([^.]+).*"; package_list_version_regex => "[^\s]\s+([^\s]+).*"; package_list_arch_regex => "[^.]+\.([^\s]+).*"; package_installed_regex => ".*(installed|\s+@).*"; package_name_convention => "$(name).$(arch)"; package_list_update_ifelapsed => "240"; package_patch_installed_regex => "^\s.*"; package_patch_name_regex => "([^.]+).*"; package_patch_version_regex => "[^\s]\s+([^\s]+).*"; package_patch_arch_regex => "[^.]+\.([^\s]+).*"; package_add_command => "/usr/bin/yum -y install"; package_delete_command => "/bin/rpm -e --nodeps"; package_verify_command => "/bin/rpm -V"; debian:: package_changes => "bulk"; package_list_command => "/usr/bin/dpkg -l"; package_list_name_regex => "ii\s+([^\s]+).*"; package_list_version_regex => "ii\s+[^\s]+\s+([^\s]+).*"; package_installed_regex => ".*"; # all reported are installed package_name_convention => "$(name)"; package_list_update_ifelapsed => "240"; # 4 hours debian.have_aptitude:: package_add_command => "/usr/bin/aptitude --assume-yes install"; package_list_update_command => "/usr/bin/aptitude update"; package_delete_command => "/usr/bin/aptitude --assume-yes remove"; package_update_command => "/usr/bin/aptitude --assume-yes install"; package_verify_command => "/usr/bin/aptitude show"; package_noverify_regex => "(State: not installed|E: Unable to locate package .*)"; debian.!have_aptitude:: package_add_command => "/usr/bin/apt-get --yes install"; package_list_update_command => "/usr/bin/apt-get update"; package_delete_command => "/usr/bin/apt-get --yes remove"; package_update_command => "/usr/bin/apt-get --yes install"; package_verify_command => "/usr/bin/dpkg -s"; package_noverify_returncode => "1"; freebsd:: package_changes => "individual"; package_list_command => "/usr/sbin/pkg_info"; package_list_name_regex => "([^\s]+)-.*"; package_list_version_regex => "[^\s]+-([^\s]+).*"; package_name_regex => "([^\s]+)-.*"; package_version_regex => "[^\s]+-([^\s]+).*"; package_installed_regex => ".*"; package_name_convention => "$(name)-$(version)"; package_add_command => "/usr/sbin/pkg_add -r"; package_delete_command => "/usr/sbin/pkg_delete"; } ##------------------------------------------------------- ## storage promises ##------------------------------------------------------- body volume min_free_space(free) { check_foreign => "false"; freespace => "$(free)"; sensible_size => "10000"; sensible_count => "2"; } ## body mount nfs(server,source) { mount_type => "nfs"; mount_source => "$(source)"; mount_server => "$(server)"; edit_fstab => "true"; } ## body mount nfs_p(server,source,perm) { mount_type => "nfs"; mount_source => "$(source)"; mount_server => "$(server)"; mount_options => {"$(perm)"}; edit_fstab => "true"; } ## body mount unmount { mount_type => "nfs"; edit_fstab => "true"; unmount => "true"; } ##------------------------------------------------------- ## process promises ##------------------------------------------------------- body process_select exclude_procs(x) { command => "$(x)"; process_result => "!command"; } ## body process_select days_older_than(d) { stime_range => irange(ago(0,0,"$(d)",0,0,0),now); process_result => "stime"; } ## body process_count any_count(cl) { match_range => "0,0"; out_of_range_define => { "$(cl)" }; } ## body process_count check_range(name,lower,upper) { match_range => irange("$(lower)","$(upper)"); out_of_range_define => { "$(name)_out_of_range" }; } ## ## service promises ## body service_method bootstart { service_autostart_policy => "boot_time"; service_dependence_chain => "start_parent_services"; windows:: service_type => "windows"; } ## body service_method force_deps { service_dependence_chain => "all_related"; windows:: service_type => "windows"; } #################################################### ## monitor bodyparts #################################################### body match_value scan_log(line) { select_line_matching => "$(line)"; track_growing_file => "true"; } ## body match_value scan_changing_file(line) { select_line_matching => "$(line)"; track_growing_file => "false"; } ## body action sample_rate(x) { ifelapsed => "$(x)"; expireafter => "10"; } cfengine-3.2.4/examples/unit_filesize.cf0000644000175000017500000000244311707771422015233 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "exists" int => filesize("/etc/passwd"); "nexists" int => filesize("/etc/passwdx"); reports: !xyz:: "File size $(exists)"; "Does not exist $(nexists)"; } cfengine-3.2.4/examples/unit_edit_column_files.cf0000644000175000017500000000511311707771422017102 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ###################################################################### # # File editing # # Normal ordering: # - delete # - replace | colum_edit # - insert # ###################################################################### body common control { version => "1.2.3"; bundlesequence => { "bun" }; } ######################################################## bundle agent bun { vars: "userset" slist => { "one", "two", "three" }; files: # Make a copy of the password file "/home/mark/tmp/passwd" create => "true", edit_line => set_user_field("mark","6","/home/dir"); "/home/mark/tmp/group" create => "true", edit_line => append_user_field("wheel","4","@(bun.userset)"); } ######################################################## bundle edit_line set_user_field(user,field,val) { field_edits: "$(user).*" # Set field of the file to parameter edit_field => col(":","$(field)","$(val)","set"); } ######################################################## bundle edit_line append_user_field(user,field,allusers) { vars: "val" slist => { @(allusers) }; field_edits: "$(user).*" # Set field of the file to parameter edit_field => col(":","$(field)","$(val)","alphanum"); } ######################################## # Bodies ######################################## body edit_field col(split,col,newval,method) { field_separator => "$(split)"; select_field => "$(col)"; value_separator => ","; field_value => "$(newval)"; field_operation => "$(method)"; extend_fields => "true"; allow_blank_fields => "true"; } cfengine-3.2.4/examples/unit_escape.cf0000644000175000017500000000265111707771422014662 00000000000000 # Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # escape function for literal -> regular expressions # ####################################################### body common control { any:: bundlesequence => { test }; } ####################################################### bundle agent test { vars: "literal" string => escape("192.168.1.100"); reports: cfengine_3:: "Escaped $(literal)"; } cfengine-3.2.4/examples/unit_getmacaddress.cf0000644000175000017500000000265511707771422016234 00000000000000 body common control { bundlesequence => { "get_mac_adr" }; } ############################################################## bundle agent get_mac_adr { vars: linux:: "interface" string => execresult("/sbin/ifconfig eth0","noshell"); solaris:: "interface" string => execresult("/usr/sbin/ifconfig bge0","noshell"); freebsd:: "interface" string => execresult("/sbin/ifconfig le0","noshell"); darwin:: "interface" string => execresult("/sbin/ifconfig en0","noshell"); classes: linux:: "ok" expression => regextract( ".*HWaddr ([^\s]+).*(\n.*)*", "$(interface)", "mac" ); solaris:: "ok" expression => regextract( ".*ether ([^\s]+).*(\n.*)*", "$(interface)", "mac" ); freebsd:: "ok" expression => regextract( ".*ether ([^\s]+).*(\n.*)*", "$(interface)", "mac" ); darwin:: "ok" expression => regextract( "(?s).*ether ([^\s]+).*(\n.*)*", "$(interface)", "mac" ); reports: ok:: "MAC address is $(mac[1])"; } cfengine-3.2.4/examples/unit_strcmp.cf0000644000175000017500000000240111707771422014723 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "same" expression => strcmp("test","test"); reports: same:: "Strings are equal"; !same:: "Strings are not equal"; } cfengine-3.2.4/examples/unit_edit_replace_string.cf0000644000175000017500000000406311707771422017427 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ###################################################################### # # File editing # # Normal ordering: # - delete # - replace | colum_edit # - insert # ###################################################################### body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/tmp/replacestring" create => "true", edit_line => myedit("second"); } ######################################################## bundle edit_line myedit(parameter) { vars: "edit_variable" string => "private edit variable is $(parameter)"; replace_patterns: # replace shell comments with C comments "puppet" replace_with => With("cfengine 3"); } ######################################## # Bodies ######################################## body replace_with With(x) { replace_value => "$(x)"; occurrences => "first"; } ######################################## body select_region MySection(x) { select_start => "\[$(x)\]"; select_end => "\[.*\]"; } cfengine-3.2.4/examples/unit_splitstring.cf0000644000175000017500000000275711707771422016013 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Split a string into a list # ####################################################### body common control { any:: bundlesequence => { test }; } ####################################################### bundle agent test { vars: "split1" slist => splitstring("one:two:three",":","10"); "split2" slist => splitstring("alpha:xyz:beta","xyz","10"); reports: linux:: "Found key $(split1)"; "Found key $(split2)"; } cfengine-3.2.4/examples/unit_irange.cf0000644000175000017500000000173011715232734014661 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. cfengine-3.2.4/examples/unit_method_validate.cf0000644000175000017500000000317211707771422016552 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "testbundle" }; version => "1.2.3"; } ########################################### body agent control { abortbundleclasses => { "invalid" }; } ########################################### bundle agent testbundle { vars: "userlist" slist => { "xyz", "mark", "jeang", "jonhenrik", "thomas", "eben" }; methods: "any" usebundle => subtest("$(userlist)"); } ########################################### bundle agent subtest(user) { classes: "invalid" not => regcmp("[a-z][a-z][a-z][a-z]","$(user)"); reports: !invalid:: "User name $(user) is valid at 4 letters"; invalid:: "User name $(user) is invalid"; } cfengine-3.2.4/examples/unit_insert_users.cf0000644000175000017500000000567611707771422016161 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Insert users into the passwd file of a system by # extracting named users from a master file - repeat # for /etc/shadow # ######################################################## body common control { bundlesequence => { "updateusers" }; } ######################################################## bundle agent updateusers { vars: # Set $(testing) to "" for production "testing" string => "/home/mark/tmp"; "tmp" string => "$(testing)/etc/passwd_tmp"; "extract_users" slist => { "mark", "root", "at", "www-run" }; files: # # Take the passwed entries from source and add them to real_passwd # "$(tmp)" create => "true", edit_line => SelectUsers("$(testing)/masterfiles/passwd","@(this.extract_users)"); # # Intermediate file - should be secure - not in /tmp # "$(testing)/etc/passwd" edit_line => ReplaceUsers("$(tmp)","@(this.extract_users)"); # "$(testing)/home/$(extract_users)/." create => "true", perms => userdir("$(extract_users)"); } ######################################################## # Library stuff ######################################################## body perms userdir(u) { mode => "755"; owners => { "$(u)" }; groups => { "users" }; } ######################################################## bundle edit_line SelectUsers(f,l) { insert_lines: "$(f)" insert_type => "file", insert_select => keep("@(l)"); } ######################################################## bundle edit_line ReplaceUsers(f,l) { delete_lines: "$(f)" delete_select => discard("@(l)"); insert_lines: "$(f)" insert_type => "file"; } ######################################################## body insert_select keep(s) { insert_if_startwith_from_list => { @(s) }; } ######################################################## body delete_select discard(s) { delete_if_not_startwith_from_list => { @(s) }; }cfengine-3.2.4/examples/unit_syslog2.cf0000644000175000017500000000075711707771422015031 00000000000000# # With Nova, log directly to a central server -- careful of scalability (UDP) # body common control { bundlesequence => { "test" }; syslog_host => "loghost.example.org"; host_licenses_paid => "1"; } # bundle agent test { vars: "software" slist => { "/root/xyz", "/tmp/xyz" }; files: "$(software)" create => "true", action => logme("$(software)"); } # body action logme(x) { log_repaired => "udp_syslog"; log_string => "cfengine repaired promise $(this.handle) - $(x)"; }cfengine-3.2.4/examples/unit_iprange.cf0000644000175000017500000000253011707771422015043 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "adhoc_group_1" expression => iprange("192.168.1.50-140"); "adhoc_group_2" expression => iprange("192.168.1.0/24"); reports: adhoc_group_1:: "Some numerology"; adhoc_group_2:: "The masked warriors"; } cfengine-3.2.4/examples/unit_lastnode.cf0000644000175000017500000000250011707771422015224 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => {"yes"}; } bundle agent yes { vars: "path1" string => "/one/two/last1"; "path2" string => "one:two:last2"; "last1" string => lastnode("$(path1)","/"); "last2" string => lastnode("$(path2)",":"); "last3" string => lastnode("$(path2)","/"); reports: Yr2009:: "Last = $(last1),$(last2),$(last3)"; }cfengine-3.2.4/examples/unit_process_restart.cf0000644000175000017500000000273511707771422016647 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "process_restart" }; } ######################################################### bundle agent process_restart { vars: "component" slist => { "cf-monitord", "cf-serverd", "cf-execd" }; processes: "$(component)" restart_class => canonify("start_$(component)"); commands: "/var/cfengine/bin/$(component)" ifvarclass => canonify("start_$(component)"); } cfengine-3.2.4/examples/unit_edit_deletenotmatch.cf0000644000175000017500000000313611707771422017426 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test editfile # ######################################################## # # This assumes a file format like: # # [section 1] # # lines.... # # [section 2] # # lines... etc body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/tmp/passwd_excerpt" create => "true", edit_line => MarkNRoot; } ######################################################## bundle edit_line MarkNRoot { delete_lines: "mark.*|root.*" not_matching => "true"; } cfengine-3.2.4/examples/unit_expand.cf0000644000175000017500000000257711707771422014710 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "component" slist => { "cf-monitord", "cf-serverd", "cf-execd" }; processes: "$(component)" restart_class => canonify("start_$(component)"); commands: "/bin/echo /var/cfengine/bin/$(component)" ifvarclass => canonify("start_$(component)"); } cfengine-3.2.4/examples/unit_execd.cf0000644000175000017500000000227711715232734014513 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body executor control { mailto => "MARK@iu.hio.no"; mailfrom => "cfengine@domain.tld"; smtpserver => "MAIL-out.hio.no"; mailmaxlines => "50"; schedule => { "Min00_05", "Min30_35" }; execcommand => "/var/cfengine/bin/cfAgent"; }cfengine-3.2.4/examples/unit_pathtype.cf0000644000175000017500000000342511707771422015260 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple backgrounding # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/home/mark/tmp" -> "me" changes => tripwire, pathtype => "literal", depth_search => recurse("inf"); } ######################################################### body changes tripwire { hash => "md5"; report_changes => "all"; update_hashes => "true"; } ######################################################### body action background { background => "true"; } ######################################################### body depth_search recurse(d) { depth => "$(d)"; } cfengine-3.2.4/examples/unit_accumulated_time.cf0000644000175000017500000000336011707771422016725 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test processes # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { processes: ".*" process_count => anyprocs, process_select => proc_finder; reports: any_procs:: "Found processes in range"; } ######################################################## body process_select proc_finder { ttime_range => irange(accumulated(0,0,0,0,2,0),accumulated(0,0,0,0,20,0)); process_result => "ttime"; } ######################################################## body process_count anyprocs { match_range => "0,0"; out_of_range_define => { "any_procs" }; } cfengine-3.2.4/examples/unit_zenoss.cf0000644000175000017500000000410711715232734014736 00000000000000 ###################################################################### # # Zenoss integration template example # ###################################################################### body common control { bundlesequence => { "zenoss_host", "zenoss_client" }; syslog_host => "zenoss_syslog.example.org"; syslog_port => "514"; } ######################################################## bundle agent zenoss_host { vars: "cf_server_hosts" string => "cfengine_policy.example.org"; "cf_doc_root" string => "/srv/www/html"; "zCfengineComplianceFile" string => "/home/zenoss/compliance.zen"; files: # Assume Cfengine is running on the zenoss server to collect data zenoss_syslog_example_org:: "$(zCfengineComplianceFile)" comment => "Collect data from the Cfengine policy server", perms => mo("644","zenoss"), copy_from => secure_cp("$(cf_doc_root)/reports/summary.z","$(cf_server_host)"); } ######################################################## bundle agent zenoss_client { processes: # On clients, we just pass any messages to the zenoss server # for logging... "bad_process" comment => "Make sure that process X is not running, tell zenoss if it was", signals => { "term", "kill" }, action => tell_zenoss_repaired("bad_process was killed"); files: "/etc/passwd" comment => "Check passwd security, tell zenoss if permissions were wrong", mode => mog("644","root","root"), action => tell_zenoss_repaired("passwd file had incorrect permissions"); commands: "/my/important/script -xyz" comment => "Run my mission critical batch process", action => tell_zenoss_failed("myscript failed to execute or returned error"); } # # Library stuff # body action tell_zenoss_repaired(x) { log_repaired => "udp_syslog"; log_string => "zenoss_cfengine_integration $(x) promise repaired"; ifelapsed => "10"; # Every 10 mins } body action tell_zenoss_failed(x) { log_notkept => "udp_syslog"; log_string => "zenoss_cfengine_integration $(x) persistent problem"; ifelapsed => "10"; # Every 10 mins } cfengine-3.2.4/examples/unit_countclassesmatching.cf0000644000175000017500000000265011707771422017642 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Count classes matching a regex # ####################################################### body common control { any:: bundlesequence => { test }; } ####################################################### bundle agent test { vars: "number" int => countclassesmatching("cf.*"); reports: cfengine_3:: "Found $(number) classes matching cf.*"; } cfengine-3.2.4/examples/unit_tidy_all_files.cf0000644000175000017500000000404711707771422016406 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Deleting files, like cf2 tidy age=0 r=inf # ####################################################### body common control { any:: bundlesequence => { "testbundle" }; } ############################################ bundle agent testbundle { files: "/home/mark/tmp/test_to" delete => tidyfiles, file_select => zero_age, depth_search => recurse("inf"); # Now delete the parent. "/home/mark/tmp/testcopy" delete => tidyfiles; } ######################################################### body depth_search recurse(d) { #include_basedir => "true"; depth => "$(d)"; } ######################################################### body delete tidyfiles { dirlinks => "delete"; rmdirs => "true"; } ######################################################### body file_select zero_age # # we can build old "include", "exclude", and "ignore" # from these as standard patterns - these bodies can # form a library of standard patterns # { mtime => irange(ago(1,0,0,0,0,0),now); file_result => "mtime"; } cfengine-3.2.4/examples/unit_linking.cf0000644000175000017500000000413111707771422015050 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ###################################################################### # # File editing # # Normal ordering: # - delete # - replace | colum_edit # - insert # ###################################################################### body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: # Make a copy of the password file "/home/mark/tmp/passwd" link_from => linkdetails("/etc/passwd"), move_obstructions => "true"; "/home/mark/tmp/linktest" link_from => linkchildren("/usr/local/sbin"); #child links } ######################################################### body link_from linkdetails(tofile) { source => "$(tofile)"; link_type => "symlink"; when_no_source => "force"; # kill } ######################################################### body link_from linkchildren(tofile) { source => "$(tofile)"; link_type => "symlink"; when_no_source => "force"; # kill link_children => "true"; when_linking_children => "if_no_such_file"; # "override_file"; } cfengine-3.2.4/examples/unit_registry_cache.cf0000644000175000017500000000324711707771422016417 00000000000000# This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { # "registry_cache" # "registry_restore" }; } ######################################### bundle agent registry_cache { databases: windows:: "HKEY_LOCAL_MACHINE\SOFTWARE\Adobe" database_operation => "cache", database_type => "ms_registry", comment => "Save correct registry settings for Adobe products"; } ######################################### bundle agent registry_restore { databases: windows:: "HKEY_LOCAL_MACHINE\SOFTWARE\Adobe" database_operation => "restore", database_type => "ms_registry", comment => "Make sure Adobe products have correct registry settings"; } cfengine-3.2.4/examples/unit_package_msi_file.cf0000644000175000017500000000402111707771422016655 00000000000000# This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # MSI package managment using file name # body common control { bundlesequence => { "packages" }; } ############################################# bundle agent packages { vars: "match_package" slist => { "7zip-4.65-x86_64.msi" }; packages: "$(match_package)" package_policy => "add", package_method => msi_fmatch; } ############################################# body package_method msi_fmatch { package_changes => "individual"; package_file_repositories => { "$(sys.workdir)\software_updates\windows", "s:\su" }; package_installed_regex => ".*"; package_name_regex => "^(\S+)-(\d+\.?)+"; package_version_regex => "^\S+-((\d+\.?)+)"; package_arch_regex => "^\S+-(\d+\.?)+(^.+)"; package_name_convention => "$(name)-$(version)-$(arch).msi"; package_add_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_update_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_delete_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /x"; } cfengine-3.2.4/examples/unit_service_start.cf0000644000175000017500000000105611707771422016275 00000000000000body common control { bundlesequence => { "example" }; } ############################################# bundle agent example { services: "Themes" service_policy => "start", service_dependencies => { "Alerter" }, service_method => exmethod; } ############################################# body service_method exmethod { service_type => "windows"; service_args => "-f \"the file with spaces.cf\" --some-args"; service_autostart_policy => "boot_time"; service_dependence_chain => "start_parent_services"; } cfengine-3.2.4/examples/unit_remoteclasses.cf0000644000175000017500000000560711707771422016277 00000000000000######################################################## # # Remote classes from server connection to cfServer # ######################################################## # # run this as follows: # # cf-serverd -f runtest_1.cf [-d2] # cf-agent -f runtest_2.cf # # Notice that the same file configures all parts of cfengine ######################################################## body common control { bundlesequence => { job_chain("Hr16|Hr17") }; version => "1.2.3"; } ######################################################## bundle common g { vars: # Signals are in scope of promiser and promisee "signal" string => "pack_a_name"; } ######################################################## bundle agent job_chain(time) { vars: "client" string => "localhost"; "server" string => "localhost"; "margin" string => "5"; # mins deadtime classes: "client_primed" expression => classmatch(canonify("$(client)")), ifvarclass => "$(time)"; "server_primed" expression => classmatch(canonify("$(server)")), ifvarclass => "$(time)"; client_primed:: "succeeded" expression => remoteclassesmatching("$(g.signal)","$(server)","yes","myprefix"); # # Now the job itself # methods: client_primed:: "downstream" usebundle => do_job("Starting local follow-up job"), action => if_elapsed("$(margin)"), ifvarclass => "myprefix_$(g.signal)"; server_primed:: "upstream" usebundle => do_job("Starting remote job"), action => if_elapsed("$(margin)"), classes => signal_repaired("$(g.signal)"); reports: !succeeded:: "Server communication failed", ifvarclass => "$(time)"; "Job completed on the server...", ifvarclass => "$(g.signal)"; } ######################################################### bundle agent do_job(job) { commands: # do whatever... "/bin/echo $(job)"; } ######################################################### # Server config ######################################################### body server control { allowconnects => { "127.0.0.1" , "::1" }; allowallconnects => { "127.0.0.1" , "::1" }; trustkeysfrom => { "127.0.0.1" , "::1" }; allowusers => { "mark" }; } ######################################################### bundle server access_rules() { vars: "localvar" string => "literal string"; access: "$(g.signal)" handle => "test_class_signal", resource_type => "context", admit => { "127.0.0.1" }; } ######################################################### # Standard library ######################################################### body action if_elapsed(x) { ifelapsed => "$(x)"; } ######################################################### body classes signal_repaired(x) { promise_repaired => { "$(x)" }; persist_time => "10"; } cfengine-3.2.4/examples/unit_activedirectory_showuser.cf0000644000175000017500000000316411707771422020561 00000000000000# This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # List users from Active Directory through LDAP # Note: Anonymous LDAP binding must be allowed, and the Anonymous user # must have read access to CN=Users and CN=theusername # Run the agent in verbose mode to see the data bundle agent ldap { classes: "gotdata" expression => ldaparray( "myarray", "ldap://cf-win2003", "CN=Test Pilot,CN=Users,DC=domain,DC=cf-win2003", "(name=*)", "subtree", "none"); reports: gotdata:: "Got user data"; !gotdata:: "Did not get user data"; } cfengine-3.2.4/examples/unit_package_hash.cf0000644000175000017500000000173011715232734016012 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. cfengine-3.2.4/examples/unit_isplain.cf0000644000175000017500000000233411707771422015057 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "isplain" expression => isplain("/etc/passwd"); reports: isplain:: "File exists.."; } cfengine-3.2.4/examples/unit_commands.cf0000644000175000017500000000234111707771422015217 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "my_commands" }; inputs => { "cfengine_stdlib.cf" }; } bundle agent my_commands { commands: Sunday.Hr04.Min05_10.myhost:: "/usr/bin/update_db"; any:: "/etc/mysql/start" contain => setuid("mysql"); } cfengine-3.2.4/examples/unit_product.cf0000644000175000017500000000236011707771422015077 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "test" }; } bundle agent test { vars: "series" rlist => { "1.1", "2.2", "3.3", "5.5", "7.7" }; "prod" real => product("series"); "sum" real => sum("series"); reports: cfengine_3:: "Product result: $(prod) > $(sum)"; }cfengine-3.2.4/examples/unit_log_private.cf0000644000175000017500000000260011707771422015727 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "test" }; } bundle agent test { vars: "software" slist => { "/root/xyz", "/tmp/xyz" }; files: "$(software)" create => "true", action => logme("$(software)"); } # body action logme(x) { log_kept => "/tmp/private_keptlog.log"; log_failed => "/tmp/private_faillog.log"; log_repaired => "/tmp/private_replog.log"; log_string => "$(sys.date) $(x) promise status"; }cfengine-3.2.4/examples/unit_select_mode.cf0000644000175000017500000000334011707771422015701 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Searching for permissions # ####################################################### body common control { any:: bundlesequence => { "testbundle" }; version => "1.2.3"; } ############################################ bundle agent testbundle { files: "/home/mark/tmp/test_from" file_select => by_modes, transformer => "/bin/echo DETECTED $(this.promiser)", depth_search => recurse("inf"); } ############################################ body file_select by_modes { search_mode => { "711" , "666" }; file_result => "mode"; } ############################################ body depth_search recurse(d) { depth => "$(d)"; } cfengine-3.2.4/examples/unit_getuid.cf0000644000175000017500000000231311707771422014676 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "uid" int => getuid("mark"); reports: Yr2008:: "Users gid is $(uid)"; } cfengine-3.2.4/examples/unit_edit_insert_fuzzylines.cf0000644000175000017500000000346211707771422020236 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Insert a number of lines with vague whitespace # ####################################################### body common control { any:: bundlesequence => { "insert" }; } ####################################################### bundle agent insert { vars: "v" string => " One potato"; files: "/tmp/test_insert" create => "true", edit_line => Insert("$(insert.v)"); } ####################################################### # For the library ####################################################### bundle edit_line Insert(name) { insert_lines: " $(name)" whitespace_policy => { "ignore_leading", "ignore_embedded" }; } ####################################################### body edit_defaults empty { empty_file_before_editing => "true"; }cfengine-3.2.4/examples/unit_edit_insert_lines.cf0000644000175000017500000000357611707771422017134 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Insert a number of lines # ####################################################### body common control { any:: bundlesequence => { "insert" }; } ####################################################### bundle agent insert { vars: "v" string => " One potato Two potato Three potatoe Four "; files: "/tmp/test_insert" create => "true", edit_line => Insert("$(insert.v)"), edit_defaults => empty; } ####################################################### # For the library ####################################################### bundle edit_line Insert(name) { insert_lines: "Begin$(const.n)$(name)$(const.n)End"; } ####################################################### body edit_defaults empty { empty_file_before_editing => "false"; }cfengine-3.2.4/examples/unit_knowledge_txt.cf0000644000175000017500000000440311707771422016275 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "tm" }; } body knowledge control { query_output => "text"; query_engine => "none"; sql_database => "test_map"; sql_owner => "mark"; sql_type => "mysql"; sql_passwd => ""; # No passwd for localhost } ################################################### bundle knowledge tm { topics: any:: # We have to start somewhere "Processes" comment => "Programs running on a computer"; "Computers" comment => "Generic boxes", association => a("run","Services","are run on"); Computers:: "server" comment => "Common name for a computer in a datacentre without separate screen and keyboard"; "desktop" comment => "Common name for a computer for end users"; Programs:: "httpd" comment => "A web service process"; "named" comment => "A name service process"; Services:: "WWW" comment => "World Wide Web service", association => a("is implemented by","httpd","implements"); "WWW" association => a("looks up addresses with","named","serves addresses to"); # occurrences: httpd:: "http://www.apache.org" represents => { "website" }; } ################################################### body association a(f,name,b) { forward_relationship => "$(f)"; backward_relationship => "$(b)"; associates => { $(name) }; } cfengine-3.2.4/examples/unit_iteration.cf0000644000175000017500000000236011707771422015415 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Nested iteration # body common control { bundlesequence => {"x"}; } bundle agent x { vars: "list1" slist => { "a", "b", "c" }; "list2" slist => { "1", "2", "3", "4" }; "list3" slist => { "x", "y", "z" }; reports: linux:: "Hello $(list1) $(list2) $(list3)"; } cfengine-3.2.4/examples/unit_report_diffs.cf0000644000175000017500000000335111707771422016106 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Change detect with diff reporting # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/tmp/testfile" -> "me" changes => report; } ######################################################### body changes report { report_changes => "all"; report_diffs => "true"; update_hashes => "true"; } ######################################################### body reporter control { reports => { "file_changes", }; build_directory => "$(sys.workdir)/reports"; report_output => "html"; style_sheet => "cf_enterprise.css"; }cfengine-3.2.4/examples/unit_backreferences_files.cf0000644000175000017500000000351411707771422017545 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ###################################################################### # # File editing - back reference # ###################################################################### body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: # The back reference in a path only applies to the last link # of the pathname, so the (tmp) gets ignored "/tmp/(cf3)_(.*)" edit_line => myedit("second $(match.2)"); # but ... # "/tmp/cf3_test" # create => "true", # edit_line => myedit("second $(match.1)"); } ######################################################## bundle edit_line myedit(parameter) { vars: "edit_variable" string => "private edit variable is $(parameter)"; insert_lines: "$(edit_variable)"; } cfengine-3.2.4/examples/unit_disable_and_rotate_files.cf0000644000175000017500000000330611707771422020405 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Disabling / rotating files # ####################################################### body common control { any:: bundlesequence => { "testbundle" }; } ############################################ bundle agent testbundle { files: "/home/mark/tmp/test_create" comment => "this rule does something", rename => disable; "/home/mark/tmp/rotateme" rename => rotate("4"); } ############################################ body rename disable { disable => "true"; disable_suffix => "_blownaway"; } ############################################ body rename rotate(level) { rotate => "$(level)"; } cfengine-3.2.4/examples/unit_getindices.cf0000644000175000017500000000365011707771422015540 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # GetIndices from an array into a list # ####################################################### body common control { any:: bundlesequence => { test }; } ####################################################### bundle agent test { vars: "ps[relayhost]" string => "[$(mailrelay)]:587"; "ps[mydomain]" string => "iu.hio.no"; "ps[smtp_sasl_auth_enable]" string => "yes"; "ps[smtp_sasl_password_maps]" string => "hash:/etc/postfix/sasl-passwd"; "ps[smtp_sasl_security_options]" string => ""; "ps[smtp_use_tls]" string => "yes"; "ps[default_privs]" string => "mailman"; "ps[inet_protocols]" string => "all"; "ps[inet_interfaces]" string => "127.0.0.1"; "parameter_name" slist => getindices("ps"); reports: linux:: "Found key $(parameter_name)"; } cfengine-3.2.4/examples/unit_measure_log.cf0000644000175000017500000000133711707771422015724 00000000000000#cop measurements,example ####################################################### # # Test file: log scanner # ####################################################### # # Look for a file in /var/cfengine/state/line_counter_measure.log # bundle monitor watch { measurements: "/home/mark/tmp/file" handle => "line_counter", stream_type => "file", data_type => "counter", match_value => scan_log("MYLINE.*"), history_type => "log", action => sample_rate("0"); } ########################################################## body match_value scan_log(x) { select_line_matching => "^$(x)$"; track_growing_file => "true"; } body action sample_rate(x) { ifelapsed => "$(x)"; expireafter => "10"; }cfengine-3.2.4/examples/unit_file_owner_list_template.cf0000644000175000017500000000304011707771422020472 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # List substitution in bodies # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { vars: "usernames" slist => { "one", "two", "three" }; files: "/home/mark/tmp/test_plain" perms => users("@(usernames)"), create => "true"; } ######################################################### body perms users(x) { mode => "0640"; owners => { @(x) }; } cfengine-3.2.4/examples/unit_remove_deadlinks.cf0000644000175000017500000000336611707771422016741 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Test dead link removal # ####################################################### body common control { any:: bundlesequence => { "testbundle" }; } ############################################ bundle agent testbundle { files: "/home/mark/tmp/test_to" -> "someone" depth_search => recurse("inf"), perms => modestuff, action => tell_me; } ############################################ body depth_search recurse(d) { rmdeadlinks => "true"; depth => "$(d)"; } ############################################ body perms modestuff { mode => "o-w"; } ############################################ body action tell_me { report_level => "inform"; }cfengine-3.2.4/examples/unit_template2.cf0000644000175000017500000000204411707771422015313 00000000000000 body common control { bundlesequence => { "test" }; inputs => { "cfengine_stdlib.cf" }; } bundle agent test { methods: "any" usebundle => get_template("/tmp/sudoers","400"); "any" usebundle => get_template("/tmp/hosts","644"); } ############################################################# bundle agent get_template(final_destination,mode) { vars: # This needs to ne preconfigured to your site "masterfiles" string => "/home/mark/tmp"; "this_template" string => lastnode("$(final_destination)","/"); files: "$(final_destination).staging" comment => "Get template and expand variables for this host", perms => mo("400","root"), copy_from => remote_cp("$(masterfiles)/templates/$(this_template)","$(policy_server)"), action => if_elapsed("60"); "$(final_destination)" comment => "Expand the template", create => "true", edit_line => expand_template("$(final_destination).staging"), edit_defaults => empty, perms => mo("$(mode)","root"), action => if_elapsed("60"); } cfengine-3.2.4/examples/unit_locate_files_and_compress.cf0000644000175000017500000000333511707771422020610 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Compressing files # ####################################################### body common control { any:: bundlesequence => { "testbundle" }; version => "1.2.3"; } ############################################ bundle agent testbundle { files: "/home/mark/tmp/testcopy" file_select => pdf_files, transformer => "/usr/bin/gzip $(this.promiser)", depth_search => recurse("inf"); } ############################################ body file_select pdf_files { leaf_name => { ".*.pdf" , ".*.fdf" }; file_result => "leaf_name"; } ############################################ body depth_search recurse(d) { depth => "$(d)"; } cfengine-3.2.4/examples/unit_hub.cf0000644000175000017500000000431111707771422014173 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Remote value from hub # ######################################################## # # run this as follows: # # cf-serverd -f runtest_1.cf [-d2] # cf-agent -f runtest_2.cf # # Notice that the same file configures all parts of cfengine ######################################################## body common control { bundlesequence => { "testbundle" }; version => "1.2.3"; host_licenses_paid => "10"; } ######################################################## bundle agent testbundle { vars: "remote_value" string => hubknowledge("monitoring"); reports: cfengine_3:: "Global knowledge: $(remote_value)"; } ######################################################### # Server config ######################################################### body server control { allowconnects => { "127.0.0.1" , "::1" }; allowallconnects => { "127.0.0.1" , "::1" }; trustkeysfrom => { "127.0.0.1" , "::1" }; allowusers => { "mark" }; } ######################################################### bundle server access_rules() { access: "discovered value" handle => "monitoring", resource_type => "literal", admit => { "127.0.0.1" }; } cfengine-3.2.4/examples/unit_failsafe.cf0000644000175000017500000000234011715232734015164 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Failsafe file # body control common { # Reads default # /var/cfengine/inputs/promises.cf # /var/cfengine/inputs/failsafe.cf bundlesequence = { "update" }; inputs => { "update.cf" # a simple recovery file too? }; } cfengine-3.2.4/examples/unit_varclass.cf0000644000175000017500000000237711707771422015245 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { commands: "/bin/echo This is linux" ifvarclass => "linux"; "/bin/echo This is solaris" ifvarclass => "solaris"; } cfengine-3.2.4/examples/unit_knowledge_driver.cf0000644000175000017500000000255511707771422016757 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "tm" }; } body knowledge control { query_output => "text"; query_engine => "none"; sql_database => "test_map"; sql_owner => "mark"; sql_type => "mysql"; sql_passwd => ""; # No passwd for localhost } ################################################### bundle knowledge tm { topics: any:: "Nothing needed here -- we get everything from the db cache"; } cfengine-3.2.4/examples/unit_isvariable.cf0000644000175000017500000000241011707771422015534 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "bla" string => "xyz.."; classes: "exists" expression => isvariable("bla"); reports: exists:: "Variable exists: \"$(bla)\".."; } cfengine-3.2.4/examples/unit_process_matching3.cf0000644000175000017500000000332511707771422017034 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test processes # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { processes: ".*" process_select => proc_finder("a.*"), process_count => up("cfservd"); } ######################################################## body process_count up(s) { match_range => "1,10"; # or irange("1","10"); out_of_range_define => { "$(s)_out_of_control" }; } ######################################################## body process_select proc_finder(p) { stime_range => irange(ago("0","0","0","2","0","0"),now); process_result => "stime"; } cfengine-3.2.4/examples/unit_server_copy_remote.cf0000644000175000017500000000673711707771422017346 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test copy from server connection to cfServer # ######################################################## # # run this as follows: # # cf-serverd -f runtest_1.cf [-v] (on remote-host.example.org) # cf-agent -f runtest_2.cf (on host 1.2.3.4) # # Notice that the same file configures all parts of cfengine # even though different parts are read by different hosts and agents ######################################################## body common control { bundlesequence => { "testbundle" }; version => "1.2.3"; #fips_mode => "true"; } ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/tmp/testcopy" perms => system, copy_from => mycopy("/src/document","remote-host.example.org"), depth_search => recurse("inf"); } ######################################################## body perms system { mode => "0444"; } ######################################################### body depth_search recurse(d) { depth => "$(d)"; } ######################################################### body copy_from mycopy(from,server) { source => "$(from)"; #portnumber => "6789"; servers => { "$(server)" , "failover1" }; copy_backup => "true"; #/false/timestamp stealth => "true"; #/on/false/off preserve => "true"; linkcopy_patterns => { ".*fish.*" }; copylink_patterns => { "non-local.*"}; xdev => "true"; # /on/false/off compare => "mtime"; # ctime/mtime/checksum/sum/byte/binary/any link_type => "absolute"; # /symbolic/relative/hard etc type_check => "true"; force_update => "false"; force_ipv4 => "false"; copy_size => irange("0","50000"); trustkey => "true"; encrypt => "true"; verify => "true"; purge => "false"; findertype => "MacOSX"; } ######################################################### # Server config ######################################################### body server control { allowconnects => { "1.2.3.4" , "::1" }; allowallconnects => { "1.2.3.4" , "::1" }; trustkeysfrom => { "1.2.3.4" , "::1" }; # allowusers } ######################################################### bundle server access_rules() { access: # Grant access to the remote client to access the source docs "/src" admit => { "1.2.3.4" }; } cfengine-3.2.4/examples/unit_fix_names.cf0000644000175000017500000000346111707771422015373 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ###################################################################### # # File editing # # Normal ordering: # - delete # - replace | colum_edit # - insert # ###################################################################### body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/home/mark/LapTop/Cfengine3/trunk/src/.*\.[ch]" edit_line => change_name; } ######################################################## bundle edit_line change_name { replace_patterns: "Verbose\(" replace_with => With("CfOut(cf_verbose,\"\","); } ######################################## # Bodies ######################################## body replace_with With(x) { replace_value => "$(x)"; occurrences => "all"; } cfengine-3.2.4/examples/unit_failedcommand.cf0000644000175000017500000000072111707771422016201 00000000000000body common control { bundlesequence => { "cmdtest" }; } bundle agent cmdtest { files: "/tmp/test" copy_from => copy("/etc/passwd"); "/tmp/test" classes => example, transformer => "/bin/grep -q lkajfo999999 $(this.promiser)"; reports: wasfailed:: "The files-promise failed!"; } body classes example { failed_returncodes => { "1" }; repair_failed => { "wasfailed" }; } body copy_from copy(file) { source => "$(file)"; } cfengine-3.2.4/examples/unit_controlclasses.cf0000644000175000017500000000363611715232734016461 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { myclass1:: bundlesequence => { @(categories.common), "extra1" }; inputs => { @(categories.in1), @(categories.in_any) }; myclass2:: bundlesequence => { @(categories.common), "extra2" }; inputs => { @(categories.in1), @(categories.in_any) }; } bundle common categories { classes: "myclass1" expression => "xxany"; "myclass2" expression => "xxany"; vars: "common" slist => { "update.cf", } "extra1" slist => { "reasons to be cheerful, part 1", }; "extra2" slist => { "reasons to be cheerful, part 2", }; "in_any" slist => { "update.cf", }; "in1" slist => { "in1/in1.cf", }; "in1" slist => { "in2/in1.cf", }; } cfengine-3.2.4/examples/unit_acl_secret.cf0000644000175000017500000000267011707771422015527 00000000000000# This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "acls" }; } ######################################### bundle agent acls { files: windows:: "c:\Secret" acl => win, depth_search => include_base, comment => "Secure the secret directory from unauthorized access"; } ######################################### body acl win { acl_method => "overwrite"; aces => { "user:Administrator:rwx" }; } ######################################### body depth_search include_base { include_basedir => "true"; } cfengine-3.2.4/examples/unit_global_list_expansion_2.cf0000644000175000017500000000274111707771422020222 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Show access of external lists. # body common control { bundlesequence => { hardening }; } ######################################################### bundle common va { vars: "tmpdirs" slist => { "/tmp", "/var/tmp", "/usr/tmp" }; } ########################################################## bundle agent hardening { classes: "ok" expression => "any"; vars: "other" slist => { "/tmp", "/var/tmp" }; "x" slist => { @(va.tmpdirs) }; reports: ok:: "Do $(x)"; "Other: $(other)"; } cfengine-3.2.4/examples/unit_file_change_detection.cf0000644000175000017500000000377611707771422017715 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple backgrounding # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## body agent control { agentaccess => { "mark", "root" }; } ######################################################## bundle agent testbundle { files: "/home/mark/tmp" -> "me" changes => tripwire, depth_search => recurse("inf"), action => background; "/home/mark/LapTop/words" -> "you" changes => tripwire, depth_search => recurse("inf"); } ######################################################### body changes tripwire { hash => "md5"; report_changes => "content"; update_hashes => "true"; } ######################################################### body action background { background => "true"; } ######################################################### body depth_search recurse(d) { depth => "$(d)"; } cfengine-3.2.4/examples/unit_copy_classes.cf0000644000175000017500000000435711707771422016116 00000000000000body common control { bundlesequence => { "copy_file"}; inputs => {"cfengine_stdlib.cf"}; } ###################################################### bundle agent copy_file() { files: "/tmp/non_existent" copy_from => local_cp_compare("/non_existent"), # perms => m("777"), action => warn_only, classes => check_promises("NE_NE"); "/tmp/non_existent" copy_from => local_cp_compare("/tmp/existent_file"), # perms => m("777"), action => warn_only, classes => check_promises("NE_E"); "/tmp/existent_file" copy_from => local_cp_compare("/tmp/existent_file"), # perms => m("777"), action => warn_only, classes => check_promises("E_E"); "/tmp/existent_file" copy_from => local_cp_compare("/tmp/different_file"), # perms => m("777"), action => warn_only, classes => check_promises("D_E"); "/tmp/existent_file" copy_from => local_cp_compare("/non_existent"), # perms => m("777"), action => warn_only, classes => check_promises("E_NE"); reports: NE_NE_kept:: "NE_NE_kept"; NE_NE_repaired:: "NE_NE_repaired"; NE_NE_failed:: "NE_NE_failed"; NE_NE_denied:: "NE_NE_denied"; NE_NE_timeout:: "NE_NE_timeout"; NE_E_kept:: "NE_E_kept"; NE_E_repaired:: "NE_E_repaired"; NE_E_failed:: "NE_E_failed"; NE_E_denied:: "NE_E_denied"; NE_E_timeout:: "NE_E_timeout"; E_E_kept:: "E_E_kept"; E_E_repaired:: "E_E_repaired"; E_E_failed:: "E_E_failed"; E_E_denied:: "E_E_denied"; E_E_timeout:: "E_E_timeout"; D_E_kept:: "D_E_kept"; D_E_repaired:: "D_E_repaired"; D_E_failed:: "D_E_failed"; D_E_denied:: "D_E_denied"; D_E_timeout:: "D_E_timeout"; E_NE_kept:: "E_NE_kept"; E_NE_repaired:: "E_NE_repaired"; E_NE_failed:: "E_NE_failed"; E_NE_denied:: "E_NE_denied"; E_NE_timeout:: "E_NE_timeout"; } ###################################################### body classes check_promises(prom) { promise_kept => { "$(prom)_kept" }; promise_repaired => { "$(prom)_repaired" }; repair_failed => { "$(prom)_failed" }; repair_denied => { "$(prom)_denied" }; repair_timeout => { "$(prom)_timeout" }; } ###################################################### body copy_from local_cp_compare(from) { source => "$(from)"; verify => "true"; compare => "hash"; } cfengine-3.2.4/examples/unit_repairedcommand.cf0000644000175000017500000000050411707771422016547 00000000000000body common control { bundlesequence => { "cmdtest" }; } bundle agent cmdtest { commands: "/bin/false" classes => example; reports: wasrepaired:: "The command-promise got repaired!"; } body classes example { repaired_returncodes => { "0", "1" }; promise_repaired => { "wasrepaired" }; } cfengine-3.2.4/examples/unit_select_region.cf0000644000175000017500000000356711707771422016253 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/tmp/testfile" create => "true", edit_line => myedit("second"); } ######################################################## bundle edit_line myedit(parameter) { vars: "edit_variable" string => "private edit variable is $(parameter)"; replace_patterns: # comment out lines after start "([^#].*)" replace_with => comment, select_region => ToEnd("Start.*"); } ######################################## # Bodies ######################################## body replace_with comment { replace_value => "# $(match.1)"; # backreference 0 occurrences => "all"; # first, last all } ######################################################## body select_region ToEnd(x) { select_start => "$(x)"; } cfengine-3.2.4/examples/unit_host2ip.cf0000644000175000017500000000260211707771422015006 00000000000000 # Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # host2ip function # ####################################################### body common control { any:: bundlesequence => { test }; } ####################################################### bundle agent test { vars: "ip" string => host2ip("www.google.com"); reports: cfengine_3:: "IP address $(ip)"; } cfengine-3.2.4/examples/win_emergency.cf0000644000175000017500000000353011707771422015213 00000000000000######################################################################### # # win_emergency.cf - Emergency Policy To Close Potential Security Holes # # NOTE: The class "emergency" may be set automatically by Cfengine # based on some criteria, or it may be explicitly set by a remote # execution of cf-agent through cf-runagent (if this is allowed # by the server control policy). # ######################################################################### bundle agent win_emergency { vars: "disable_services" slist => { "RemoteRegistry" # Windows Remote Management }; "secure_files" slist => { "C:\Secret", "$(sys.workdir)\secret.txt" }; "close_ports" slist => { "6510", "9300" }; commands: emergency:: "\"$(sys.winsysdir)\netsh.exe\"" args => "firewall add portopening ALL $(close_ports) \"Port $(close_ports)\" DISABLE", comment => "Close firewall ports on emergency"; databases: emergency:: "HKEY_LOCAL_MACHINE\SOFTWARE\Cfengine AS\Cfengine" database_operation => "create", database_rows => { "emergency,REG_SZ,This is an emergency!" } , database_type => "ms_registry", comment => "Create emergency policy registry settings"; files: emergency:: "$(secure_files)" acl => strict, comment => "Secure important file access on emergency"; services: emergency:: "$(disable_services)" service_policy => "disable", comment => "Disable security-relevant services on emergency"; } cfengine-3.2.4/examples/unit_isnewerthan.cf0000644000175000017500000000240311707771422015744 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "do_it" and => { isnewerthan("/tmp/later","/tmp/earlier"), "linux" }; reports: do_it:: "The derived file needs updating"; } cfengine-3.2.4/examples/unit_islink.cf0000644000175000017500000000234211707771422014710 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "islnk" expression => islink("/tmp/link"); reports: islnk:: "link exists..and is a link"; } cfengine-3.2.4/examples/unit_stringarray.cf0000644000175000017500000000262111707771422015764 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "dim_array" int => readstringarray("array_name","/etc/passwd","#[^\n]*",":",10,4000); "idx" slist => getindices("array_name"); reports: cfengine_3:: "Index $(idx): [1]=$(array_name[$(idx)][1]),[2]=$(array_name[$(idx)][2])...[7]=$(array_name[$(idx)][6])"; } cfengine-3.2.4/examples/unit_occurrences.cf0000644000175000017500000000254111707771422015733 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "test" }; } body knowledge control { query_engine => "123"; } bundle knowledge test { topics: "test topic"; occurrences: test_topic:: "(.*)/help.html" represents => { "host $(match.1)" }, representation => "file", path_root => "/home/mark/tmp", web_root => "http://www.cfengine.com"; }cfengine-3.2.4/examples/unit_module_exec_2.cf0000644000175000017500000000336311707771422016135 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Test module execution as class function # body common control { any:: bundlesequence => { def, modtest }; } ################################################################### bundle agent def { commands: "$(sys.workdir)/modules/module_name" module => "true"; reports: # # Each module forms a private context with its name as id # module_class:: "Module set variable $(module_name.myscalar)"; } ################################################################### bundle agent modtest { vars: "mylist" slist => { @(module_name.mylist) }; reports: # # Each module forms a private context with its name as id # module_class:: "Module set variable $(mylist)"; } cfengine-3.2.4/examples/unit_root_passwd.cf0000644000175000017500000000626511707771422015773 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ###################################################################### # # Root password distribution # ###################################################################### body common control { version => "1.2.3"; bundlesequence => { "SetRootPassword" }; } ######################################################## bundle common g { vars: "secret_keys_dir" string => "/tmp"; } ######################################################## bundle agent SetRootPassword { files: "/var/cfengine/ppkeys/rootpw.txt" copy_from => scp("$(fqhost)-root.txt","master_host.example.org"); # or $(pw_class)-root.txt # Test this on a copy "/tmp/shadow" edit_line => SetPasswd("root"); } ######################################################## bundle edit_line SetPasswd(user) { vars: # Assume this file contains a single string of the form :passwdhash: # with : delimiters to avoid end of line/file problems "gotpw" int => readstringarray("pw","$(sys.workdir)/ppkeys/root-pw.txt","#[^\n]*",":","3","200"); field_edits: "$(user).*" # Set field of the file to parameter # File has format root:HASH: or user:HASH: edit_field => col(":","2","$(pw[root][1])","set"); } ######################################################## bundle server passwords { vars: # Read a file of format # # classname: host1,host2,host4,IP-address,regex.*,etc # "pw_classes" int => readstringarray("acl","$(g.secret_keys_dir)/classes.txt","#[^\n]*",":","100","4000"); "each_pw_class" slist => getindices("acl"); access: "/secret/keys/$(each_pw_class)-root.txt" admit => splitstring("$(acl[$(each_pw_class)][1])" , ":" , "100"), ifencrypted => "true"; } ######################################## # Bodies ######################################## body edit_field col(split,col,newval,method) { field_separator => "$(split)"; select_field => "$(col)"; value_separator => ","; field_value => "$(newval)"; field_operation => "$(method)"; extend_fields => "true"; allow_blank_fields => "true"; } ######################################## body copy_from scp(from,server) { source => "$(from)"; compare => "digest"; encrypt => "true"; verify => "true"; } cfengine-3.2.4/examples/unit_intarray.cf0000644000175000017500000000233211707771422015247 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "dim_array" int => readstringarray("array_name","/tmp/array","#[^\n]*",":",10,4000); } cfengine-3.2.4/examples/unit_report_state.cf0000644000175000017500000000265311707771422016137 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "report" }; } ########################################################### bundle agent report { reports: linux:: "/etc/passwd except $(const.n)" printfile => pr("/etc/passwd","5"); # showstate => { "otherprocs", "rootprocs" }; } ###################################################################### body printfile pr(file,lines) { file_to_print => "$(file)"; number_of_lines => "$(lines)"; }cfengine-3.2.4/examples/unit_copy_copbl.cf0000644000175000017500000000243011707771422015546 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "mycopy" }; inputs => { "cfengine_stdlib.cf" }; } bundle agent mycopy { files: "/home/mark/tmp/test_plain" copy_from => local_cp("$(sys.workdir)/bin/file"); "/home/mark/tmp/test_remote_plain" copy_from => secure_cp("$(sys.workdir)/bin/file","serverhost"); } cfengine-3.2.4/examples/unit_ordering.cf0000644000175000017500000000342011707771422015226 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ################################################################## # # cfengine 3 - ordering promises into dependent chains # ## # # cf-agent -f ./cftest.cf -K # ################################################################## body common control { bundlesequence => { "order" }; } ################################################################## bundle agent order { vars: "list" slist => { "three", "four" }; commands: ok_later:: "/bin/echo five"; otherthing:: "/bin/echo six"; any:: "/bin/echo one" classes => d("ok_later","otherthing"); "/bin/echo two"; "/bin/echo $(list)"; preserved_class:: "/bin/echo seven"; } ############################################ body classes d(if,else) { promise_repaired => { "$(if)" }; repair_failed => { "$(else)" }; persist_time => "0"; } cfengine-3.2.4/examples/unit_null_config.cf0000644000175000017500000000243411715232734015715 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # The starting point for every configuration # ####################################################### body common control { any:: bundlesequence => { "testbundle" }; } ####################################################### bundle agent testbundle { } cfengine-3.2.4/examples/unit_monitord.cf0000644000175000017500000000247511715232734015256 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################### body monitor control() { #version => "1.2.3.4"; threshold => "0.3"; forgetrate => "0.7"; histograms => "true"; tcpdump => "false"; tcpdumpcommand => "/usr/sbin/tcpdump -i eth1 -n -t -v"; # on linux linux:: # sensor => readfile("/proc/cpu/temperature"); } cfengine-3.2.4/examples/unit_abort.cf0000644000175000017500000000317711707771422014535 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "testbundle" }; version => "1.2.3"; } ########################################### body agent control { abortbundleclasses => { "invalid.Hr16" }; } ########################################### bundle agent testbundle { vars: "userlist" slist => { "xyz", "mark", "jeang", "jonhenrik", "thomas", "eben" }; methods: "any" usebundle => subtest("$(userlist)"); } ########################################### bundle agent subtest(user) { classes: "invalid" not => regcmp("[a-z][a-z][a-z][a-z]","$(user)"); reports: !invalid:: "User name $(user) is valid at 4 letters"; invalid:: "User name $(user) is invalid"; } cfengine-3.2.4/examples/unit_acl_ntfs.cf0000644000175000017500000000111411707771422015204 00000000000000body common control { inputs => { "cfengine_stdlib.cf" }; bundlesequence => { "test" }; host_licenses_paid => "1"; } ### bundle agent test { vars: "acl_secret_dir" slist => { "user:Administrator:rwx:allow", "group:Administrators:rx:allow" }; "acl_secret_file" slist => { "user:Administrator:rw:allow" }; files: windows:: "C:\Secret", acl => ntfs( "@(acl_secret_dir)" ), depth_search => include_base, perms => owner( "Administrator" ); "C:\Secret\file.txt", acl => ntfs( "@(acl_secret_file)" ), perms => owner( "Administrator" ); } cfengine-3.2.4/examples/unit_method.cf0000644000175000017500000000265611707771422014707 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "testbundle" }; version => "1.2.3"; } ########################################### bundle agent testbundle { vars: "userlist" slist => { "mark", "jeang", "jonhenrik", "thomas", "eben" }; methods: "any" usebundle => subtest("$(userlist)"); } ########################################### bundle agent subtest(user) { commands: "/bin/echo Fix $(user)"; reports: linux:: "Finished doing stuff for $(user)"; } cfengine-3.2.4/examples/unit_switchcase.cf0000644000175000017500000000207411707771422015556 00000000000000 body common control { bundlesequence => { "test1", "test2" }; } ################################################## bundle agent test1 { classes: "default" expression => "any"; reports: linux:: "This is a linux box" classes => exclusive; solaris:: "This is a solaris box" classes => exclusive; default:: "This is something not worth mentioning specifically" classes => reset_default; } ################################################## bundle agent test2 { classes: "default" expression => "any"; reports: linux:: "This is another linux box" classes => exclusive; solaris:: "This is another solaris box" classes => exclusive; default:: "This is something else not worth mentioning specifically" classes => reset_default; } ########################################################## body classes exclusive { cancel_kept => { "default" }; cancel_notkept => { "default" }; cancel_repaired => { "default" }; } body classes reset_default { promise_kept => { "default" }; }cfengine-3.2.4/examples/unit_package_msi_version.cf0000644000175000017500000000364311707771422017434 00000000000000# This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # MSI package managment using version criteria # body common control { bundlesequence => { "packages" }; } ############################################# bundle agent packages { vars: "match_package" slist => { "7zip" }; packages: "$(match_package)" package_policy => "update", package_select => ">=", package_architectures => { "x86_64" }, package_version => "3.00", package_method => msi_vmatch; } ############################################# body package_method msi_vmatch { package_changes => "individual"; package_file_repositories => { "$(sys.workdir)\software_updates\windows", "s:\su" }; package_installed_regex => ".*"; package_name_convention => "$(name)-$(version)-$(arch).msi"; package_add_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_update_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /i"; package_delete_command => "\"$(sys.winsysdir)\msiexec.exe\" /qn /x"; } cfengine-3.2.4/examples/unit_process_matching2.cf0000644000175000017500000000305411707771422017032 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test processes # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { processes: "sleep" process_count => up("sleep"); reports: sleep_out_of_control:: "Out of control"; } ######################################################## body process_count up(s) { match_range => "5,10"; # or irange("1","10"); out_of_range_define => { "$(s)_out_of_control" }; } cfengine-3.2.4/examples/unit_readlist.cf0000644000175000017500000000237611707771422015235 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "mylist" ilist => { readintlist("/tmp/listofint","#.*","[\n]",10,400) }; reports: cfengine_3:: "List entry: $(mylist)"; } cfengine-3.2.4/examples/unit_diskfree.cf0000644000175000017500000000232011707771422015207 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "free" int => diskfree("/tmp"); reports: cfengine_3:: "Freedisk $(free)"; } cfengine-3.2.4/examples/unit_process_signalling.cf0000644000175000017500000000330311707771422017302 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test process restart # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { processes: "cfservd" process_count => up("cfservd"); cfservd_out_of_control:: "cfservd" signals => { "stop" , "term" }, restart_class => "start_cfserv"; commands: start_cfserv:: "/usr/local/sbin/cfservd"; } ######################################################## body process_count up(s) { match_range => "1,10"; # or irange("1","10"); out_of_range_define => { "$(s)_out_of_control" }; } cfengine-3.2.4/examples/unit_literal_server.cf0000644000175000017500000000564511707771422016452 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Remote value from server connection to cfServer # ######################################################## # # run this as follows: # # cf-serverd -f runtest_1.cf [-d2] # cf-agent -f runtest_2.cf # # Notice that the same file configures all parts of cfengine ######################################################## body common control { bundlesequence => { "testbundle" }; version => "1.2.3"; } ######################################################## bundle agent testbundle { vars: "encrypt" string => "yes"; "x" string => "scalar2"; "remote1" string => remotescalar("test_scalar1","127.0.0.1","$(encrypt)"); "remote2" string => remotescalar("test_scalar2","127.0.0.1","$(encrypt)"); "remote3" string => remotescalar("test_scalar3","127.0.0.1","$(encrypt)"); "remote_error" string => remotescalar("test_$(x)","127.0.0.2","$(encrypt)"); reports: linux:: "Receive value $(remote1), $(remote2), $(remote3)"; "And an error gives: $(remote_error)"; } ######################################################### # Server config ######################################################### body server control { allowconnects => { "127.0.0.1" , "::1" }; allowallconnects => { "127.0.0.1" , "::1" }; trustkeysfrom => { "127.0.0.1" , "::1" }; allowusers => { "mark" }; } ######################################################### bundle server access_rules() { vars: "localvar" string => "literal string"; access: "Embed a $(localvar) for remote access" handle => "test_scalar1", resource_type => "literal", admit => { "127.0.0.1" }; "Mary had a little lamb whose fleece was white as snow and everywhere that Mary went she wore it lovingly" handle => "test_scalar2", resource_type => "literal", admit => { "127.0.0.1" }; "/etc/passwd" handle => "test_scalar3", admit => { "127.0.0.1" }; } cfengine-3.2.4/examples/unit_process_matching.cf0000644000175000017500000000345511707771422016755 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test processes # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { processes: ".*" process_select => proc_finder("a.*"), process_count => up("cfservd"); } ######################################################## body process_count up(s) { match_range => "1,10"; # or irange("1","10"); out_of_range_define => { "$(s)_out_of_control" }; } ######################################################## body process_select proc_finder(p) { process_owner => { "avahi", "bin" }; command => "$(p)"; pid => "100,199"; vsize => "0,1000"; process_result => "command.(process_owner|vsize)"; } cfengine-3.2.4/examples/unit_warnifline.cf0000644000175000017500000000320311707771422015552 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Warn if line matched # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/var/cfengine/inputs/.*" edit_line => DeleteLinesMatching(".*cfenvd.*"), action => WarnOnly; } ######################################################## bundle edit_line DeleteLinesMatching(regex) { delete_lines: "$(regex)" action => WarnOnly; } ######################################################## body action WarnOnly { action_policy => "warn"; }cfengine-3.2.4/examples/unit_getusers.cf0000644000175000017500000000261011707771422015256 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # GetUsers # ####################################################### body common control { any:: bundlesequence => { test }; } ####################################################### bundle agent test { vars: "allusers" slist => getusers("zenoss,mysql,at","12,0"); reports: linux:: "Found user $(allusers)"; } cfengine-3.2.4/examples/unit_getfields.cf0000644000175000017500000000272511707771422015372 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "no" int => getfields("mark.*","/tmp/passwd",":","userdata"); reports: cfengine_3:: "Found $(no) lines matching"; "Mark's handle = $(userdata[1])"; "Mark's passwd = ... forget it!"; "Mark's uid = $(userdata[3])"; "Mark's gid = $(userdata[4])"; "Mark's name = $(userdata[5])"; "Mark's homedir = $(userdata[6])"; } cfengine-3.2.4/examples/unit_sql.cf0000644000175000017500000000402711707771422014220 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "databases" }; } bundle agent databases { #commands: # "/usr/bin/createdb cf_topic_maps", # contain => as_user("mysql"); databases: "knowledge_bank/topics" database_operation => "create", database_type => "sql", database_columns => { "topic_name,varchar,256", "topic_comment,varchar,1024", "topic_id,varchar,256", "topic_type,varchar,256", "topic_extra,varchar,26" }, database_server => myserver; } ################################################ body database_server myserver { none:: db_server_owner => "postgres"; db_server_password => ""; db_server_host => "localhost"; db_server_type => "postgres"; db_server_connection_db => "postgres"; any:: db_server_owner => "root"; db_server_password => ""; db_server_host => "localhost"; db_server_type => "mysql"; db_server_connection_db => "mysql"; } body contain as_user(x) { exec_owner => "$(x)"; }cfengine-3.2.4/examples/unit_filesexist.cf0000644000175000017500000000250311707771422015575 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "mylist" slist => { "/tmp/a", "/tmp/b", "/tmp/c" }; classes: "exists" expression => filesexist("@(mylist)"); reports: exists:: "File does exist"; !exists:: "Does not yet exist"; } cfengine-3.2.4/examples/unit_edit_comment_lines.cf0000644000175000017500000000423611707771422017264 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ###################################################################### # # File editing # # Normal ordering: # - delete # - replace | colum_edit # - insert # ###################################################################### body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/home/mark/tmp/cf3_test" create => "true", edit_line => myedit("second"); } ######################################################## bundle edit_line myedit(parameter) { vars: "edit_variable" string => "private edit variable is $(parameter)"; replace_patterns: # replace shell comments with C comments "#(.*)" replace_with => C_comment, select_region => MySection("New section"); } ######################################## # Bodies ######################################## body replace_with C_comment { replace_value => "/* $(match.1) */"; # backreference 0 occurrences => "all"; # first, last all } ######################################################## body select_region MySection(x) { select_start => "\[$(x)\]"; select_end => "\[.*\]"; } cfengine-3.2.4/examples/unit_edit_triggerclass.cf0000644000175000017500000000420211707771422017112 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ####################################################### # # Insert a number of lines and trigger a followup if edited # ####################################################### body common control { any:: bundlesequence => { "insert" }; } ####################################################### bundle agent insert { vars: "v" string => " One potato Two potato Three potahto Four "; files: "/tmp/test_insert" edit_line => Insert("$(insert.v)"), edit_defaults => empty, classes => trigger("edited"); commands: edited:: "/bin/echo make bananas"; reports: edited:: "The potatoes are bananas"; } ####################################################### # For the library ####################################################### bundle edit_line Insert(name) { insert_lines: "Begin$(const.n) $(name)$(const.n)End"; } ####################################################### body edit_defaults empty { empty_file_before_editing => "true"; } ####################################################### body classes trigger(x) { promise_repaired => { "$(x)" }; } cfengine-3.2.4/examples/unit_loops.cf0000644000175000017500000000265711707771422014564 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "component" slist => { "cf-monitord", "cf-serverd", "cf-execd" }; "array[cf-monitord]" string => "The monitor"; "array[cf-serverd]" string => "The server"; "array[cf-execd]" string => "The executor, not executioner"; reports: cfengine_3:: "/bin/echo $(component) is $(array[$(component)])"; } cfengine-3.2.4/examples/win_registry.cf0000644000175000017500000000507311707771422015111 00000000000000######################################################################### # # win_registry.cf - Windows Registry Management # ######################################################################### bundle agent win_registry { vars: "cache_keys" slist => { "HKEY_LOCAL_MACHINE\SOFTWARE\Cfengine AS" }; "reg_create" slist => { "value1,REG_SZ,this is the first value...", "value2,REG_SZ,...and this is the second!" }; "reg_delete" slist => { "value1" }; methods: # 1) Cfengine can cache and restore any part of the registry # "any" usebundle => registry_cache("@(win_registry.cache_keys)"); # "any" usebundle => registry_restore("@(win_registry.cache_keys)"); # 2) Registry settings may also be explicitly defined/deleted in policy # "any" usebundle => registry_define("HKEY_LOCAL_MACHINE\SOFTWARE\Cfengine AS\Cfengine", "@(win_registry.reg_create)"); # "any" usebundle => registry_delete("HKEY_LOCAL_MACHINE\SOFTWARE\Cfengine AS\Cfengine", "@(win_registry.reg_delete)"); } ######################################################################### bundle agent registry_cache(keys) { databases: windows:: "$(keys)" database_operation => "cache", database_type => "ms_registry", comment => "Save correct registry settings"; } ######################################################################### bundle agent registry_restore(keys) { databases: windows:: "$(keys)" database_operation => "restore", database_type => "ms_registry", comment => "Make sure correct registry settings are set, according to cached version"; } ######################################################################### bundle agent registry_define(key, contents) { databases: windows:: "$(key)" database_operation => "create", database_rows => { "$(contents)" } , database_type => "ms_registry", comment => "Explicitly define important registry settings"; } ######################################################################### bundle agent registry_delete(key, values) { databases: windows:: "$(key)" database_operation => "delete", database_columns => { "@(values)" } , database_type => "ms_registry", comment => "Remove unwanted registry values"; } cfengine-3.2.4/examples/unit_edit_passwd_file_basic.cf0000644000175000017500000000246011707771422020066 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "edit_passwd" }; } bundle agent edit_passwd { vars: "userset" slist => { "user1", "user2", "user3" }; files: "/etc/passwd" edit_line => set_user_field("mark","7","/set/this/shell"); "/etc/group" edit_line => append_user_field("root","4","@(main.userset)"); } cfengine-3.2.4/examples/promise_knowledge.cf0000644000175000017500000044113011707771422016077 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. bundle knowledge CfengineSiteConfiguration { topics: references:: "bundle reference"; "used in promise"; "has current exemplars"; "is a promise of type"; "occurs in bundle"; "bundle contains promiser"; "makes promise of type"; "promises have been made by"; "makes promises"; "is a promise made by"; system_reports:: "audit report"; "performance report"; "all_locks report"; "active_locks report"; "hashes report"; "classes report"; "lastseen report"; "monitor now report"; "monitor history report"; "monitor summary report"; "compliance report"; "setuid report"; "file_changes report"; "installed software report"; "software patches report"; system_policy:: "bundles"; "bodies"; "contexts"; "promisees"; "promisers"; "promises" comment => "occurrences of promise topics or suggestions"; "promise types"; "body constraints"; "comments" association => a("see instances of","comment","is one of a number of"); "functions" comment => "In built functions that may be used to set variables or classes"; "values" comment => "Formal rvalues in constraint assignments and their legal ranges"; values:: "system signals" comment =>"Should match the generic pattern hup,int,trap,kill,pipe,cont,abrt,stop,quit,term,child,usr1,usr2,bus,segv, i.e. a unix signal name"; "boolean" comment =>"Should match the generic pattern true,false,yes,no,on,off, i.e. a positive or a negative"; "link type" comment =>"Should match the generic pattern symlink,hardlink,relative,absolute,none, i.e. a support link type"; "a time range" comment =>"Should match the generic pattern 0,2147483648, i.e. a value from zero to a maximum system time -- but you should use time functions to convert this"; "a positive integer" comment =>"Should match the generic pattern 0,99999999999, i.e. a number between zero and the maximum value"; "integer" comment =>"Should match the generic pattern -99999999999,9999999999, i.e. a number between the minus and positive maximum values"; "real number" comment =>"Should match the generic pattern -9.99999E100,9.99999E100, i.e. a number between the minus and positive maximum values"; "a single character" comment =>"Should match the generic pattern ^.$, i.e. one symbol"; "posix file mode or permission" comment =>"Should match the generic pattern [0-7augorwxst,+-]+, i.e. something that you would give as an argument to chmod"; "a cfengine class expression" comment =>"Should match the generic pattern [a-zA-Z0-9_!&|.()]+, i.e. an alphanumeric string with option underscores and logical operators"; "a cfengine identifier" comment =>"Should match the generic pattern [a-zA-Z0-9_$.]+, i.e. an alphanumeric string with option underscores"; "a user/group id" comment =>"Should match the generic pattern [a-zA-Z0-9_$.-]+, i.e. an alphanumeric string with option underscores and hyphens"; "a file path" comment =>"Should match the generic pattern [cC]:\\.*|/.*, i.e. a system file path suitable for the target system"; "a syslog level" comment =>"Should match the generic pattern LOG_USER,LOG_DAEMON,LOG_LOCAL0,LOG_LOCAL1,LOG_LOCAL2,LOG_LOCAL3,LOG_LOCAL4,LOG_LOCAL5,LOG_LOCAL6,LOG_LOCAL7, i.e. a syslog constant"; "An arbitrary string" comment =>"Should match the generic pattern , i.e. unspecified characters"; "An arbitrary string" comment =>"Should match the generic pattern .*, i.e. unspecified characters"; "boolean" association => a("is a special case of","int","is the generic type for"); "a time range" association => a("is a special case of","int","is the generic type for"); "a positive integer" association => a("is a special case of","int","is the generic type for"); "integer" association => a("is a special case of","int","is the generic type for"); "real number" association => a("is a special case of","real","is the generic type for"); "a cfengine class expression" association => a("is a special case of","class","is the generic type for"); "a cfengine identifier" association => a("is a special case of","string","is the generic type for"); "a user/group id" association => a("is a special case of","string","is the generic type for"); "a file path" association => a("is a special case of","string","is the generic type for"); "a syslog level" association => a("is a special case of","string","is the generic type for"); "An arbitrary string" association => a("is a special case of","string","is the generic type for"); "An arbitrary string" association => a("is a special case of","string","is the generic type for"); bundles:: "sys" comment => "cfengine's internal bundle of system specific values"; promise_types:: "vars"; body_constraints:: "string" comment => "A scalar string", association => a("is a possible body constraint for","promise_types::vars","can have body constraints"); body_constraints:: "string" association => a("is a body constraint of type","string","has possible body constraints"), comment => "A scalar string"; promise_types:: "vars"; body_constraints:: "int" comment => "A scalar integer", association => a("is a possible body constraint for","promise_types::vars","can have body constraints"); body_constraints:: "int" association => a("is a body constraint of type","int","has possible body constraints"), comment => "A scalar integer"; promise_types:: "vars"; body_constraints:: "real" comment => "A scalar real number", association => a("is a possible body constraint for","promise_types::vars","can have body constraints"); body_constraints:: "real" association => a("is a body constraint of type","real","has possible body constraints"), comment => "A scalar real number"; promise_types:: "vars"; body_constraints:: "slist" comment => "A list of scalar strings", association => a("is a possible body constraint for","promise_types::vars","can have body constraints"); body_constraints:: "slist" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "A list of scalar strings"; "slist" association => a("is a list of type","slist","is used in"); promise_types:: "vars"; body_constraints:: "ilist" comment => "A list of integers", association => a("is a possible body constraint for","promise_types::vars","can have body constraints"); body_constraints:: "ilist" association => a("is a body constraint of type","ilist","has possible body constraints"), comment => "A list of integers"; "ilist" association => a("is a list of type","ilist","is used in"); promise_types:: "vars"; body_constraints:: "rlist" comment => "A list of real numbers", association => a("is a possible body constraint for","promise_types::vars","can have body constraints"); body_constraints:: "rlist" association => a("is a body constraint of type","rlist","has possible body constraints"), comment => "A list of real numbers"; "rlist" association => a("is a list of type","rlist","is used in"); promise_types:: "vars"; body_constraints:: "policy" comment => "The policy for (dis)allowing redefinition of variables", association => a("is a possible body constraint for","promise_types::vars","can have body constraints"); body_constraints:: "policy" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "The policy for (dis)allowing redefinition of variables"; promise_types:: "classes"; body_constraints:: "or" comment => "Combine class sources with inclusive OR", association => a("is a possible body constraint for","promise_types::classes","can have body constraints"); body_constraints:: "or" association => a("is a body constraint of type","clist","has possible body constraints"), comment => "Combine class sources with inclusive OR"; promise_types:: "classes"; body_constraints:: "and" comment => "Combine class sources with AND", association => a("is a possible body constraint for","promise_types::classes","can have body constraints"); body_constraints:: "and" association => a("is a body constraint of type","clist","has possible body constraints"), comment => "Combine class sources with AND"; promise_types:: "classes"; body_constraints:: "xor" comment => "Combine class sources with XOR", association => a("is a possible body constraint for","promise_types::classes","can have body constraints"); body_constraints:: "xor" association => a("is a body constraint of type","clist","has possible body constraints"), comment => "Combine class sources with XOR"; promise_types:: "classes"; body_constraints:: "dist" comment => "Generate a probabilistic class distribution (strategy in cfengine 2)", association => a("is a possible body constraint for","promise_types::classes","can have body constraints"); body_constraints:: "dist" association => a("is a body constraint of type","rlist","has possible body constraints"), comment => "Generate a probabilistic class distribution (strategy in cfengine 2)"; "dist" association => a("is a list of type","rlist","is used in"); promise_types:: "classes"; body_constraints:: "expression" comment => "Evaluate string expression of classes in normal form", association => a("is a possible body constraint for","promise_types::classes","can have body constraints"); body_constraints:: "expression" association => a("is a body constraint of type","class","has possible body constraints"), comment => "Evaluate string expression of classes in normal form"; promise_types:: "classes"; body_constraints:: "not" comment => "Evaluate the negation of string expression in normal form", association => a("is a possible body constraint for","promise_types::classes","can have body constraints"); body_constraints:: "not" association => a("is a body constraint of type","class","has possible body constraints"), comment => "Evaluate the negation of string expression in normal form"; promise_types:: "reports"; body_constraints:: "lastseen" comment => "Integer time threshold in hours since current peers were last seen, report absence", association => a("is a possible body constraint for","promise_types::reports","can have body constraints"); body_constraints:: "lastseen" association => a("is a body constraint of type","int","has possible body constraints"), comment => "Integer time threshold in hours since current peers were last seen, report absence"; promise_types:: "reports"; body_constraints:: "intermittency" comment => "Real number threshold [0,1] of intermittency about current peers, report above", association => a("is a possible body constraint for","promise_types::reports","can have body constraints"); body_constraints:: "intermittency" association => a("is a body constraint of type","real","has possible body constraints"), comment => "Real number threshold [0,1] of intermittency about current peers, report above"; promise_types:: "reports"; body_constraints:: "showstate" comment => "List of services about which status reports should be reported to standard output", association => a("is a possible body constraint for","promise_types::reports","can have body constraints"); body_constraints:: "showstate" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of services about which status reports should be reported to standard output"; "showstate" association => a("is a list of type","slist","is used in"); promise_types:: "reports"; body_constraints:: "printfile" comment => "Quote part of a file to standard output", association => a("is a possible body constraint for","promise_types::reports","can have body constraints"); "number_of_lines" comment => "Integer maximum number of lines to print from selected file", association => a("is a possible sub-body constraint for","printfile","may have sub-body constraints"); body_constraints:: "number_of_lines" association => a("is a body constraint of type","int","has possible body constraints"), comment => "Integer maximum number of lines to print from selected file"; "file_to_print" comment => "Path name to the file that is to be sent to standard output", association => a("is a possible sub-body constraint for","printfile","may have sub-body constraints"); body_constraints:: "file_to_print" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Path name to the file that is to be sent to standard output"; promise_types:: "reports"; body_constraints:: "friend_pattern" comment => "Regular expression to keep selected hosts from the friends report list", association => a("is a possible body constraint for","promise_types::reports","can have body constraints"); body_constraints:: "friend_pattern" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression to keep selected hosts from the friends report list"; promise_types:: "reports"; body_constraints:: "report_to_file" comment => "The path and filename to which output should be appended", association => a("is a possible body constraint for","promise_types::reports","can have body constraints"); body_constraints:: "report_to_file" association => a("is a body constraint of type","string","has possible body constraints"), comment => "The path and filename to which output should be appended"; promise_types:: "*"; body_constraints:: "action" comment => "Output behaviour", association => a("is a possible body constraint for","promise_types::*","can have body constraints"); "action_policy" comment => "Whether to repair or report about non-kept promises", association => a("is a possible sub-body constraint for","action","may have sub-body constraints"); body_constraints:: "action_policy" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Whether to repair or report about non-kept promises"; "ifelapsed" comment => "Number of minutes before next allowed assessment of promise", association => a("is a possible sub-body constraint for","action","may have sub-body constraints"); body_constraints:: "ifelapsed" association => a("is a body constraint of type","int","has possible body constraints"), comment => "Number of minutes before next allowed assessment of promise"; "expireafter" comment => "Number of minutes before a repair action is interrupted and retried", association => a("is a possible sub-body constraint for","action","may have sub-body constraints"); body_constraints:: "expireafter" association => a("is a body constraint of type","int","has possible body constraints"), comment => "Number of minutes before a repair action is interrupted and retried"; "log_string" comment => "A message to be written to the log when a promise verification leads to a repair", association => a("is a possible sub-body constraint for","action","may have sub-body constraints"); body_constraints:: "log_string" association => a("is a body constraint of type","string","has possible body constraints"), comment => "A message to be written to the log when a promise verification leads to a repair"; "log_level" comment => "The reporting level sent to syslog", association => a("is a possible sub-body constraint for","action","may have sub-body constraints"); body_constraints:: "log_level" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "The reporting level sent to syslog"; "log_kept" comment => "This should be filename of a file to which log_string will be saved, if undefined it goes to syslog", association => a("is a possible sub-body constraint for","action","may have sub-body constraints"); body_constraints:: "log_kept" association => a("is a body constraint of type","string","has possible body constraints"), comment => "This should be filename of a file to which log_string will be saved, if undefined it goes to syslog"; "log_repaired" comment => "This should be filename of a file to which log_string will be saved, if undefined it goes to syslog", association => a("is a possible sub-body constraint for","action","may have sub-body constraints"); body_constraints:: "log_repaired" association => a("is a body constraint of type","string","has possible body constraints"), comment => "This should be filename of a file to which log_string will be saved, if undefined it goes to syslog"; "log_failed" comment => "This should be filename of a file to which log_string will be saved, if undefined it goes to syslog", association => a("is a possible sub-body constraint for","action","may have sub-body constraints"); body_constraints:: "log_failed" association => a("is a body constraint of type","string","has possible body constraints"), comment => "This should be filename of a file to which log_string will be saved, if undefined it goes to syslog"; "audit" comment => "true/false switch for detailed audit records of this promise", association => a("is a possible sub-body constraint for","action","may have sub-body constraints"); body_constraints:: "audit" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false switch for detailed audit records of this promise"; "background" comment => "true/false switch for parallelizing the promise repair", association => a("is a possible sub-body constraint for","action","may have sub-body constraints"); body_constraints:: "background" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false switch for parallelizing the promise repair"; "report_level" comment => "The reporting level for standard output", association => a("is a possible sub-body constraint for","action","may have sub-body constraints"); body_constraints:: "report_level" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "The reporting level for standard output"; "measurement_class" comment => "If set performance will be measured and recorded under this identifier", association => a("is a possible sub-body constraint for","action","may have sub-body constraints"); body_constraints:: "measurement_class" association => a("is a body constraint of type","string","has possible body constraints"), comment => "If set performance will be measured and recorded under this identifier"; promise_types:: "*"; body_constraints:: "classes" comment => "Signalling behaviour", association => a("is a possible body constraint for","promise_types::*","can have body constraints"); "promise_repaired" comment => "A list of classes to be defined", association => a("is a possible sub-body constraint for","classes","may have sub-body constraints"); body_constraints:: "promise_repaired" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "A list of classes to be defined"; "promise_repaired" association => a("is a list of type","slist","is used in"); "repair_failed" comment => "A list of classes to be defined", association => a("is a possible sub-body constraint for","classes","may have sub-body constraints"); body_constraints:: "repair_failed" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "A list of classes to be defined"; "repair_failed" association => a("is a list of type","slist","is used in"); "repair_denied" comment => "A list of classes to be defined", association => a("is a possible sub-body constraint for","classes","may have sub-body constraints"); body_constraints:: "repair_denied" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "A list of classes to be defined"; "repair_denied" association => a("is a list of type","slist","is used in"); "repair_timeout" comment => "A list of classes to be defined", association => a("is a possible sub-body constraint for","classes","may have sub-body constraints"); body_constraints:: "repair_timeout" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "A list of classes to be defined"; "repair_timeout" association => a("is a list of type","slist","is used in"); "promise_kept" comment => "A list of classes to be defined", association => a("is a possible sub-body constraint for","classes","may have sub-body constraints"); body_constraints:: "promise_kept" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "A list of classes to be defined"; "promise_kept" association => a("is a list of type","slist","is used in"); "persist_time" comment => "A number of minutes the specified classes should remain active", association => a("is a possible sub-body constraint for","classes","may have sub-body constraints"); body_constraints:: "persist_time" association => a("is a body constraint of type","int","has possible body constraints"), comment => "A number of minutes the specified classes should remain active"; "timer_policy" comment => "Whether a persistent class restarts its counter when rediscovered", association => a("is a possible sub-body constraint for","classes","may have sub-body constraints"); body_constraints:: "timer_policy" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Whether a persistent class restarts its counter when rediscovered"; promise_types:: "*"; body_constraints:: "ifvarclass" comment => "Extended classes ANDed with context", association => a("is a possible body constraint for","promise_types::*","can have body constraints"); body_constraints:: "ifvarclass" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Extended classes ANDed with context"; promise_types:: "*"; body_constraints:: "handle" comment => "A unique id-tag string for referring to this as a promisee elsewhere", association => a("is a possible body constraint for","promise_types::*","can have body constraints"); body_constraints:: "handle" association => a("is a body constraint of type","string","has possible body constraints"), comment => "A unique id-tag string for referring to this as a promisee elsewhere"; promise_types:: "*"; body_constraints:: "depends_on" comment => "A list of promise handles that this promise builds on or depends on somehow (for knowledge management)", association => a("is a possible body constraint for","promise_types::*","can have body constraints"); body_constraints:: "depends_on" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "A list of promise handles that this promise builds on or depends on somehow (for knowledge management)"; "depends_on" association => a("is a list of type","slist","is used in"); promise_types:: "*"; body_constraints:: "comment" comment => "A comment about this promise's real intention that follows through the program", association => a("is a possible body constraint for","promise_types::*","can have body constraints"); body_constraints:: "comment" association => a("is a body constraint of type","string","has possible body constraints"), comment => "A comment about this promise's real intention that follows through the program"; promise_types:: "*"; body_constraints:: "select_region" comment => "Limit edits to a demarked region of the file", association => a("is a possible body constraint for","promise_types::*","can have body constraints"); "select_start" comment => "Regular expression matching start of edit region", association => a("is a possible sub-body constraint for","select_region","may have sub-body constraints"); body_constraints:: "select_start" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression matching start of edit region"; "select_end" comment => "Regular expression matches end of edit region from start", association => a("is a possible sub-body constraint for","select_region","may have sub-body constraints"); body_constraints:: "select_end" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression matches end of edit region from start"; promise_types:: "commands"; body_constraints:: "args" comment => "Alternative string of arguments for the command (concatenated with promiser string)", association => a("is a possible body constraint for","promise_types::commands","can have body constraints"); body_constraints:: "args" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Alternative string of arguments for the command (concatenated with promiser string)"; promise_types:: "commands"; body_constraints:: "contain" comment => "Containment options for the execution process", association => a("is a possible body constraint for","promise_types::commands","can have body constraints"); "useshell" comment => "true/false embed the command in a shell environment (true)", association => a("is a possible sub-body constraint for","contain","may have sub-body constraints"); body_constraints:: "useshell" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false embed the command in a shell environment (true)"; "umask" comment => "The umask value for the child process", association => a("is a possible sub-body constraint for","contain","may have sub-body constraints"); body_constraints:: "umask" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "The umask value for the child process"; "exec_owner" comment => "The user name or id under which to run the process", association => a("is a possible sub-body constraint for","contain","may have sub-body constraints"); body_constraints:: "exec_owner" association => a("is a body constraint of type","string","has possible body constraints"), comment => "The user name or id under which to run the process"; "exec_group" comment => "The group name or id under which to run the process", association => a("is a possible sub-body constraint for","contain","may have sub-body constraints"); body_constraints:: "exec_group" association => a("is a body constraint of type","string","has possible body constraints"), comment => "The group name or id under which to run the process"; "exec_timeout" comment => "Timeout in seconds for command completion", association => a("is a possible sub-body constraint for","contain","may have sub-body constraints"); body_constraints:: "exec_timeout" association => a("is a body constraint of type","int","has possible body constraints"), comment => "Timeout in seconds for command completion"; "chdir" comment => "Directory for setting current/base directory for the process", association => a("is a possible sub-body constraint for","contain","may have sub-body constraints"); body_constraints:: "chdir" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Directory for setting current/base directory for the process"; "chroot" comment => "Directory of root sandbox for process", association => a("is a possible sub-body constraint for","contain","may have sub-body constraints"); body_constraints:: "chroot" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Directory of root sandbox for process"; "preview" comment => "true/false preview command when running in dry-run mode (with -n)", association => a("is a possible sub-body constraint for","contain","may have sub-body constraints"); body_constraints:: "preview" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false preview command when running in dry-run mode (with -n)"; "no_output" comment => "true/false discard all output from the command", association => a("is a possible sub-body constraint for","contain","may have sub-body constraints"); body_constraints:: "no_output" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false discard all output from the command"; promise_types:: "commands"; body_constraints:: "module" comment => "true/false whether to expect the cfengine module protocol", association => a("is a possible body constraint for","promise_types::commands","can have body constraints"); body_constraints:: "module" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false whether to expect the cfengine module protocol"; promise_types:: "databases"; body_constraints:: "database_server" comment => "Credentials for connecting to a local/remote database server", association => a("is a possible body constraint for","promise_types::databases","can have body constraints"); "db_server_owner" comment => "User name for database connection", association => a("is a possible sub-body constraint for","database_server","may have sub-body constraints"); body_constraints:: "db_server_owner" association => a("is a body constraint of type","string","has possible body constraints"), comment => "User name for database connection"; "db_server_password" comment => "Clear text password for database connection", association => a("is a possible sub-body constraint for","database_server","may have sub-body constraints"); body_constraints:: "db_server_password" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Clear text password for database connection"; "db_server_host" comment => "Hostname or address for connection to database, blank means localhost", association => a("is a possible sub-body constraint for","database_server","may have sub-body constraints"); body_constraints:: "db_server_host" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Hostname or address for connection to database, blank means localhost"; "db_server_type" comment => "The dialect of the database server", association => a("is a possible sub-body constraint for","database_server","may have sub-body constraints"); body_constraints:: "db_server_type" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "The dialect of the database server"; "db_server_connection_db" comment => "The name of an existing database to connect to in order to create/manage other databases", association => a("is a possible sub-body constraint for","database_server","may have sub-body constraints"); body_constraints:: "db_server_connection_db" association => a("is a body constraint of type","string","has possible body constraints"), comment => "The name of an existing database to connect to in order to create/manage other databases"; promise_types:: "databases"; body_constraints:: "database_type" comment => "The type of database that is to be manipulated", association => a("is a possible body constraint for","promise_types::databases","can have body constraints"); body_constraints:: "database_type" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "The type of database that is to be manipulated"; promise_types:: "databases"; body_constraints:: "database_operation" comment => "The nature of the promise - to be or not to be", association => a("is a possible body constraint for","promise_types::databases","can have body constraints"); body_constraints:: "database_operation" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "The nature of the promise - to be or not to be"; promise_types:: "databases"; body_constraints:: "database_columns" comment => "A list of column definitions to be promised by SQL databases", association => a("is a possible body constraint for","promise_types::databases","can have body constraints"); body_constraints:: "database_columns" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "A list of column definitions to be promised by SQL databases"; "database_columns" association => a("is a list of type","slist","is used in"); promise_types:: "databases"; body_constraints:: "database_rows" comment => "An ordered list of row values to be promised by SQL databases", association => a("is a possible body constraint for","promise_types::databases","can have body constraints"); body_constraints:: "database_rows" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "An ordered list of row values to be promised by SQL databases"; "database_rows" association => a("is a list of type","slist","is used in"); promise_types:: "databases"; body_constraints:: "registry_exclude" comment => "A list of regular expressions to ignore in key/value verification", association => a("is a possible body constraint for","promise_types::databases","can have body constraints"); body_constraints:: "registry_exclude" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "A list of regular expressions to ignore in key/value verification"; "registry_exclude" association => a("is a list of type","slist","is used in"); promise_types:: "files"; body_constraints:: "file_select" comment => "Choose which files select in a search", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); "leaf_name" comment => "List of regexes that match an acceptable name", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "leaf_name" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of regexes that match an acceptable name"; "leaf_name" association => a("is a list of type","slist","is used in"); "path_name" comment => "List of pathnames to match acceptable target", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "path_name" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of pathnames to match acceptable target"; "path_name" association => a("is a list of type","slist","is used in"); "search_mode" comment => "A list of mode masks for acceptable file permissions", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "search_mode" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "A list of mode masks for acceptable file permissions"; "search_mode" association => a("is a list of type","slist","is used in"); "search_size" comment => "Integer range of file sizes", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "search_size" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Integer range of file sizes"; "search_owners" comment => "List of acceptable user names or ids for the file, or regexes to match", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "search_owners" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of acceptable user names or ids for the file, or regexes to match"; "search_owners" association => a("is a list of type","slist","is used in"); "search_groups" comment => "List of acceptable group names or ids for the file, or regexes to match", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "search_groups" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of acceptable group names or ids for the file, or regexes to match"; "search_groups" association => a("is a list of type","slist","is used in"); "search_bsdflags" comment => "String of flags for bsd file system flags expected set", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "search_bsdflags" association => a("is a body constraint of type","string","has possible body constraints"), comment => "String of flags for bsd file system flags expected set"; "ctime" comment => "Range of change times (ctime) for acceptable files", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "ctime" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Range of change times (ctime) for acceptable files"; "mtime" comment => "Range of modification times (mtime) for acceptable files", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "mtime" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Range of modification times (mtime) for acceptable files"; "atime" comment => "Range of access times (atime) for acceptable files", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "atime" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Range of access times (atime) for acceptable files"; "exec_regex" comment => "Matches file if this regular expression matches any full line returned by the command", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "exec_regex" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Matches file if this regular expression matches any full line returned by the command"; "exec_program" comment => "Execute this command on each file and match if the exit status is zero", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "exec_program" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Execute this command on each file and match if the exit status is zero"; "file_types" comment => "List of acceptable file types from menu choices", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "file_types" association => a("is a body constraint of type","(option list)","has possible body constraints"), comment => "List of acceptable file types from menu choices"; "issymlinkto" comment => "List of regular expressions to match file objects", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "issymlinkto" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of regular expressions to match file objects"; "issymlinkto" association => a("is a list of type","slist","is used in"); "file_result" comment => "Logical expression combining classes defined by file search criteria", association => a("is a possible sub-body constraint for","file_select","may have sub-body constraints"); body_constraints:: "file_result" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Logical expression combining classes defined by file search criteria"; promise_types:: "files"; body_constraints:: "copy_from" comment => "Criteria for copying file from a source", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); "source" comment => "Reference source file from which to copy", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "source" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Reference source file from which to copy"; "servers" comment => "List of servers in order of preference from which to copy", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "servers" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of servers in order of preference from which to copy"; "servers" association => a("is a list of type","slist","is used in"); "portnumber" comment => "Port number to connect to on server host", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "portnumber" association => a("is a body constraint of type","int","has possible body constraints"), comment => "Port number to connect to on server host"; "copy_backup" comment => "Menu option policy for file backup/version control", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "copy_backup" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Menu option policy for file backup/version control"; "stealth" comment => "true/false whether to preserve time stamps on copied file", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "stealth" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false whether to preserve time stamps on copied file"; "preserve" comment => "true/false whether to preserve file permissions on copied file", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "preserve" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false whether to preserve file permissions on copied file"; "linkcopy_patterns" comment => "List of patterns matching symbolic links that should be replaced with copies", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "linkcopy_patterns" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of patterns matching symbolic links that should be replaced with copies"; "linkcopy_patterns" association => a("is a list of type","slist","is used in"); "copylink_patterns" comment => "List of patterns matching files that should be linked instead of copied", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "copylink_patterns" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of patterns matching files that should be linked instead of copied"; "copylink_patterns" association => a("is a list of type","slist","is used in"); "compare" comment => "Menu option policy for comparing source and image file attributes", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "compare" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Menu option policy for comparing source and image file attributes"; "link_type" comment => "Menu option for type of links to use when copying", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "link_type" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Menu option for type of links to use when copying"; "type_check" comment => "true/false compare file types before copying and require match", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "type_check" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false compare file types before copying and require match"; "force_update" comment => "true/false force copy update always", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "force_update" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false force copy update always"; "force_ipv4" comment => "true/false force use of ipv4 on ipv6 enabled network", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "force_ipv4" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false force use of ipv4 on ipv6 enabled network"; "copy_size" comment => "Integer range of file sizes that may be copied", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "copy_size" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Integer range of file sizes that may be copied"; "trustkey" comment => "true/false trust public keys from remote server if previously unknown", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "trustkey" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false trust public keys from remote server if previously unknown"; "encrypt" comment => "true/false use encrypted data stream to connect to remote host", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "encrypt" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false use encrypted data stream to connect to remote host"; "verify" comment => "true/false verify transferred file by hashing after copy (resource penalty)", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "verify" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false verify transferred file by hashing after copy (resource penalty)"; "purge" comment => "true/false purge files on client that do not match files on server when depth_search", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "purge" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false purge files on client that do not match files on server when depth_search"; "check_root" comment => "true/false check permissions on the root directory when depth_search", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "check_root" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false check permissions on the root directory when depth_search"; "findertype" comment => "Menu option for default finder type on MacOSX", association => a("is a possible sub-body constraint for","copy_from","may have sub-body constraints"); body_constraints:: "findertype" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Menu option for default finder type on MacOSX"; promise_types:: "files"; body_constraints:: "link_from" comment => "Criteria for linking file from a source", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); "source" comment => "The source file to which the link should point", association => a("is a possible sub-body constraint for","link_from","may have sub-body constraints"); body_constraints:: "source" association => a("is a body constraint of type","string","has possible body constraints"), comment => "The source file to which the link should point"; "link_type" comment => "The type of link used to alias the file", association => a("is a possible sub-body constraint for","link_from","may have sub-body constraints"); body_constraints:: "link_type" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "The type of link used to alias the file"; "copy_patterns" comment => "A set of patterns that should be copied ansd synchronized instead of linked", association => a("is a possible sub-body constraint for","link_from","may have sub-body constraints"); body_constraints:: "copy_patterns" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "A set of patterns that should be copied ansd synchronized instead of linked"; "copy_patterns" association => a("is a list of type","slist","is used in"); "when_no_source" comment => "Behaviour when the source file to link to does not exist", association => a("is a possible sub-body constraint for","link_from","may have sub-body constraints"); body_constraints:: "when_no_source" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Behaviour when the source file to link to does not exist"; "link_children" comment => "true/false whether to link all directory's children to source originals", association => a("is a possible sub-body constraint for","link_from","may have sub-body constraints"); body_constraints:: "link_children" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false whether to link all directory's children to source originals"; "when_linking_children" comment => "Policy for overriding existing files when linking directories of children", association => a("is a possible sub-body constraint for","link_from","may have sub-body constraints"); body_constraints:: "when_linking_children" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Policy for overriding existing files when linking directories of children"; promise_types:: "files"; body_constraints:: "perms" comment => "Criteria for setting permissions on a file", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); "mode" comment => "File permissions (like posix chmod)", association => a("is a possible sub-body constraint for","perms","may have sub-body constraints"); body_constraints:: "mode" association => a("is a body constraint of type","string","has possible body constraints"), comment => "File permissions (like posix chmod)"; "owners" comment => "List of acceptable owners or user ids, first is change target", association => a("is a possible sub-body constraint for","perms","may have sub-body constraints"); body_constraints:: "owners" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of acceptable owners or user ids, first is change target"; "owners" association => a("is a list of type","slist","is used in"); "groups" comment => "List of acceptable groups of group ids, first is change target", association => a("is a possible sub-body constraint for","perms","may have sub-body constraints"); body_constraints:: "groups" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of acceptable groups of group ids, first is change target"; "groups" association => a("is a list of type","slist","is used in"); "rxdirs" comment => "true/false add execute flag for directories if read flag is set", association => a("is a possible sub-body constraint for","perms","may have sub-body constraints"); body_constraints:: "rxdirs" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false add execute flag for directories if read flag is set"; "bsdflags" comment => "List of menu options for bsd file system flags to set", association => a("is a possible sub-body constraint for","perms","may have sub-body constraints"); body_constraints:: "bsdflags" association => a("is a body constraint of type","(option list)","has possible body constraints"), comment => "List of menu options for bsd file system flags to set"; promise_types:: "files"; body_constraints:: "changes" comment => "Criteria for change management", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); "hash" comment => "Hash files for change detection", association => a("is a possible sub-body constraint for","changes","may have sub-body constraints"); body_constraints:: "hash" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Hash files for change detection"; "report_changes" comment => "Specify criteria for change warnings", association => a("is a possible sub-body constraint for","changes","may have sub-body constraints"); body_constraints:: "report_changes" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Specify criteria for change warnings"; "update_hashes" comment => "Update hash values immediately after change warning", association => a("is a possible sub-body constraint for","changes","may have sub-body constraints"); body_constraints:: "update_hashes" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Update hash values immediately after change warning"; promise_types:: "files"; body_constraints:: "delete" comment => "Criteria for deleting files", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); "dirlinks" comment => "Menu option policy for dealing with symbolic links to directories during deletion", association => a("is a possible sub-body constraint for","delete","may have sub-body constraints"); body_constraints:: "dirlinks" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Menu option policy for dealing with symbolic links to directories during deletion"; "rmdirs" comment => "true/false whether to delete empty directories during recursive deletion", association => a("is a possible sub-body constraint for","delete","may have sub-body constraints"); body_constraints:: "rmdirs" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false whether to delete empty directories during recursive deletion"; promise_types:: "files"; body_constraints:: "rename" comment => "Criteria for renaming files", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); "newname" comment => "The desired name for the current file", association => a("is a possible sub-body constraint for","rename","may have sub-body constraints"); body_constraints:: "newname" association => a("is a body constraint of type","string","has possible body constraints"), comment => "The desired name for the current file"; "disable_suffix" comment => "The suffix to add to files when disabling (.cfdisabled)", association => a("is a possible sub-body constraint for","rename","may have sub-body constraints"); body_constraints:: "disable_suffix" association => a("is a body constraint of type","string","has possible body constraints"), comment => "The suffix to add to files when disabling (.cfdisabled)"; "disable" comment => "true/false automatically rename and remove permissions", association => a("is a possible sub-body constraint for","rename","may have sub-body constraints"); body_constraints:: "disable" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false automatically rename and remove permissions"; "rotate" comment => "Maximum number of file rotations to keep", association => a("is a possible sub-body constraint for","rename","may have sub-body constraints"); body_constraints:: "rotate" association => a("is a body constraint of type","int","has possible body constraints"), comment => "Maximum number of file rotations to keep"; "disable_mode" comment => "The permissions to set when a file is disabled", association => a("is a possible sub-body constraint for","rename","may have sub-body constraints"); body_constraints:: "disable_mode" association => a("is a body constraint of type","string","has possible body constraints"), comment => "The permissions to set when a file is disabled"; promise_types:: "files"; body_constraints:: "repository" comment => "Name of a repository for versioning", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); body_constraints:: "repository" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Name of a repository for versioning"; promise_types:: "files"; body_constraints:: "edit_line" comment => "Line editing model for file", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); body_constraints:: "edit_line" association => a("is a body constraint of type","(ext bundle)","has possible body constraints"), comment => "Line editing model for file"; promise_types:: "files"; body_constraints:: "edit_xml" comment => "XML editing model for file", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); body_constraints:: "edit_xml" association => a("is a body constraint of type","(ext bundle)","has possible body constraints"), comment => "XML editing model for file"; promise_types:: "files"; body_constraints:: "edit_defaults" comment => "Default promise details for file edits", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); "edit_backup" comment => "Menu option for backup policy on edit changes", association => a("is a possible sub-body constraint for","edit_defaults","may have sub-body constraints"); body_constraints:: "edit_backup" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Menu option for backup policy on edit changes"; "max_file_size" comment => "Do not edit files bigger than this number of bytes", association => a("is a possible sub-body constraint for","edit_defaults","may have sub-body constraints"); body_constraints:: "max_file_size" association => a("is a body constraint of type","int","has possible body constraints"), comment => "Do not edit files bigger than this number of bytes"; "empty_file_before_editing" comment => "Baseline memory model of file to zero/empty before commencing promised edits", association => a("is a possible sub-body constraint for","edit_defaults","may have sub-body constraints"); body_constraints:: "empty_file_before_editing" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Baseline memory model of file to zero/empty before commencing promised edits"; promise_types:: "files"; body_constraints:: "depth_search" comment => "Criteria for file depth searches", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); "include_dirs" comment => "List of regexes of directory names to include in depth search", association => a("is a possible sub-body constraint for","depth_search","may have sub-body constraints"); body_constraints:: "include_dirs" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of regexes of directory names to include in depth search"; "include_dirs" association => a("is a list of type","slist","is used in"); "exclude_dirs" comment => "List of regexes of directory names NOT to include in depth search", association => a("is a possible sub-body constraint for","depth_search","may have sub-body constraints"); body_constraints:: "exclude_dirs" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of regexes of directory names NOT to include in depth search"; "exclude_dirs" association => a("is a list of type","slist","is used in"); "include_basedir" comment => "true/false include the start/root dir of the search results", association => a("is a possible sub-body constraint for","depth_search","may have sub-body constraints"); body_constraints:: "include_basedir" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false include the start/root dir of the search results"; "depth" comment => "Maximum depth level for search", association => a("is a possible sub-body constraint for","depth_search","may have sub-body constraints"); body_constraints:: "depth" association => a("is a body constraint of type","int","has possible body constraints"), comment => "Maximum depth level for search"; "xdev" comment => "true/false exclude directories that are on different devices", association => a("is a possible sub-body constraint for","depth_search","may have sub-body constraints"); body_constraints:: "xdev" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false exclude directories that are on different devices"; "traverse_links" comment => "true/false traverse symbolic links to directories (false)", association => a("is a possible sub-body constraint for","depth_search","may have sub-body constraints"); body_constraints:: "traverse_links" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false traverse symbolic links to directories (false)"; "rmdeadlinks" comment => "true/false remove links that point to nowhere", association => a("is a possible sub-body constraint for","depth_search","may have sub-body constraints"); body_constraints:: "rmdeadlinks" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false remove links that point to nowhere"; promise_types:: "files"; body_constraints:: "touch" comment => "true/false whether to touch time stamps on file", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); body_constraints:: "touch" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false whether to touch time stamps on file"; promise_types:: "files"; body_constraints:: "create" comment => "true/false whether to create non-existing file", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); body_constraints:: "create" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false whether to create non-existing file"; promise_types:: "files"; body_constraints:: "move_obstructions" comment => "true/false whether to move obstructions to file-object creation", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); body_constraints:: "move_obstructions" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false whether to move obstructions to file-object creation"; promise_types:: "files"; body_constraints:: "transformer" comment => "Shell command (with full path) used to transform current file", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); body_constraints:: "transformer" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Shell command (with full path) used to transform current file"; promise_types:: "files"; body_constraints:: "pathtype" comment => "Menu option for interpreting promiser file object", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); body_constraints:: "pathtype" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Menu option for interpreting promiser file object"; promise_types:: "files"; body_constraints:: "acl" comment => "Criteria for access control lists on file", association => a("is a possible body constraint for","promise_types::files","can have body constraints"); "acl_method" comment => "Editing method for access control list", association => a("is a possible sub-body constraint for","acl","may have sub-body constraints"); body_constraints:: "acl_method" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Editing method for access control list"; "acl_type" comment => "Access control list type for the affected file system", association => a("is a possible sub-body constraint for","acl","may have sub-body constraints"); body_constraints:: "acl_type" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Access control list type for the affected file system"; "acl_directory_inherit" comment => "Access control list type for the affected file system", association => a("is a possible sub-body constraint for","acl","may have sub-body constraints"); body_constraints:: "acl_directory_inherit" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Access control list type for the affected file system"; "aces" comment => "Native settings for access control entry", association => a("is a possible sub-body constraint for","acl","may have sub-body constraints"); body_constraints:: "aces" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Native settings for access control entry"; "aces" association => a("is a list of type","slist","is used in"); "inherit_aces" comment => "Native settings for access control entry", association => a("is a possible sub-body constraint for","acl","may have sub-body constraints"); body_constraints:: "inherit_aces" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Native settings for access control entry"; "inherit_aces" association => a("is a list of type","slist","is used in"); promise_types:: "insert_lines"; body_constraints:: "location" comment => "Specify where in a file an insertion will be made", association => a("is a possible body constraint for","promise_types::insert_lines","can have body constraints"); "select_line_matching" comment => "Regular expression for matching file line location", association => a("is a possible sub-body constraint for","location","may have sub-body constraints"); body_constraints:: "select_line_matching" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression for matching file line location"; "before_after" comment => "Menu option, point cursor before of after matched line", association => a("is a possible sub-body constraint for","location","may have sub-body constraints"); body_constraints:: "before_after" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Menu option, point cursor before of after matched line"; "first_last" comment => "Menu option, choose first or last occurrence of match in file", association => a("is a possible sub-body constraint for","location","may have sub-body constraints"); body_constraints:: "first_last" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Menu option, choose first or last occurrence of match in file"; promise_types:: "insert_lines"; body_constraints:: "insert_type" comment => "Type of object the promiser string refers to (default literal)", association => a("is a possible body constraint for","promise_types::insert_lines","can have body constraints"); body_constraints:: "insert_type" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Type of object the promiser string refers to (default literal)"; promise_types:: "insert_lines"; body_constraints:: "insert_select" comment => "Insert only if lines pass filter criteria", association => a("is a possible body constraint for","promise_types::insert_lines","can have body constraints"); "insert_if_startwith_from_list" comment => "Insert line if it starts with a string in the list", association => a("is a possible sub-body constraint for","insert_select","may have sub-body constraints"); body_constraints:: "insert_if_startwith_from_list" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Insert line if it starts with a string in the list"; "insert_if_startwith_from_list" association => a("is a list of type","slist","is used in"); "insert_if_not_startwith_from_list" comment => "Insert line if it DOES NOT start with a string in the list", association => a("is a possible sub-body constraint for","insert_select","may have sub-body constraints"); body_constraints:: "insert_if_not_startwith_from_list" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Insert line if it DOES NOT start with a string in the list"; "insert_if_not_startwith_from_list" association => a("is a list of type","slist","is used in"); "insert_if_match_from_list" comment => "Insert line if it fully matches a regex in the list", association => a("is a possible sub-body constraint for","insert_select","may have sub-body constraints"); body_constraints:: "insert_if_match_from_list" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Insert line if it fully matches a regex in the list"; "insert_if_match_from_list" association => a("is a list of type","slist","is used in"); "insert_if_not_match_from_list" comment => "Insert line if it DOES NOT fully match a regex in the list", association => a("is a possible sub-body constraint for","insert_select","may have sub-body constraints"); body_constraints:: "insert_if_not_match_from_list" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Insert line if it DOES NOT fully match a regex in the list"; "insert_if_not_match_from_list" association => a("is a list of type","slist","is used in"); "insert_if_contains_from_list" comment => "Insert line if a regex in the list match a line fragment", association => a("is a possible sub-body constraint for","insert_select","may have sub-body constraints"); body_constraints:: "insert_if_contains_from_list" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Insert line if a regex in the list match a line fragment"; "insert_if_contains_from_list" association => a("is a list of type","slist","is used in"); "insert_if_not_contains_from_list" comment => "Insert line if a regex in the list DOES NOT match a line fragment", association => a("is a possible sub-body constraint for","insert_select","may have sub-body constraints"); body_constraints:: "insert_if_not_contains_from_list" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Insert line if a regex in the list DOES NOT match a line fragment"; "insert_if_not_contains_from_list" association => a("is a list of type","slist","is used in"); promise_types:: "insert_lines"; body_constraints:: "expand_scalars" comment => "Expand any unexpanded variables", association => a("is a possible body constraint for","promise_types::insert_lines","can have body constraints"); body_constraints:: "expand_scalars" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Expand any unexpanded variables"; promise_types:: "field_edits"; body_constraints:: "edit_field" comment => "Edit line-based file as matrix of fields", association => a("is a possible body constraint for","promise_types::field_edits","can have body constraints"); "field_separator" comment => "The regular expression used to separate fields in a line", association => a("is a possible sub-body constraint for","edit_field","may have sub-body constraints"); body_constraints:: "field_separator" association => a("is a body constraint of type","string","has possible body constraints"), comment => "The regular expression used to separate fields in a line"; "select_field" comment => "Integer index of the field required 1..n", association => a("is a possible sub-body constraint for","edit_field","may have sub-body constraints"); body_constraints:: "select_field" association => a("is a body constraint of type","int","has possible body constraints"), comment => "Integer index of the field required 1..n"; "value_separator" comment => "Character separator for subfields inside the selected field", association => a("is a possible sub-body constraint for","edit_field","may have sub-body constraints"); body_constraints:: "value_separator" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Character separator for subfields inside the selected field"; "field_value" comment => "Set field value to a fixed value", association => a("is a possible sub-body constraint for","edit_field","may have sub-body constraints"); body_constraints:: "field_value" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Set field value to a fixed value"; "field_operation" comment => "Menu option policy for editing subfields", association => a("is a possible sub-body constraint for","edit_field","may have sub-body constraints"); body_constraints:: "field_operation" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Menu option policy for editing subfields"; "extend_fields" comment => "true/false add new fields at end of line if necessary to complete edit", association => a("is a possible sub-body constraint for","edit_field","may have sub-body constraints"); body_constraints:: "extend_fields" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false add new fields at end of line if necessary to complete edit"; "allow_blank_fields" comment => "true/false allow blank fields in a line (do not purge)", association => a("is a possible sub-body constraint for","edit_field","may have sub-body constraints"); body_constraints:: "allow_blank_fields" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false allow blank fields in a line (do not purge)"; promise_types:: "replace_patterns"; body_constraints:: "replace_with" comment => "Search-replace pattern", association => a("is a possible body constraint for","promise_types::replace_patterns","can have body constraints"); "replace_value" comment => "Value used to replace regular expression matches in search", association => a("is a possible sub-body constraint for","replace_with","may have sub-body constraints"); body_constraints:: "replace_value" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Value used to replace regular expression matches in search"; "occurrences" comment => "Menu option to replace all occurrences or just first (NB the latter is non-convergent)", association => a("is a possible sub-body constraint for","replace_with","may have sub-body constraints"); body_constraints:: "occurrences" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Menu option to replace all occurrences or just first (NB the latter is non-convergent)"; promise_types:: "delete_lines"; body_constraints:: "not_matching" comment => "true/false negate match criterion", association => a("is a possible body constraint for","promise_types::delete_lines","can have body constraints"); body_constraints:: "not_matching" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false negate match criterion"; promise_types:: "delete_lines"; body_constraints:: "delete_select" comment => "Delete only if lines pass filter criteria", association => a("is a possible body constraint for","promise_types::delete_lines","can have body constraints"); "delete_if_startwith_from_list" comment => "Delete line if it starts with a string in the list", association => a("is a possible sub-body constraint for","delete_select","may have sub-body constraints"); body_constraints:: "delete_if_startwith_from_list" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Delete line if it starts with a string in the list"; "delete_if_startwith_from_list" association => a("is a list of type","slist","is used in"); "delete_if_not_startwith_from_list" comment => "Delete line if it DOES NOT start with a string in the list", association => a("is a possible sub-body constraint for","delete_select","may have sub-body constraints"); body_constraints:: "delete_if_not_startwith_from_list" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Delete line if it DOES NOT start with a string in the list"; "delete_if_not_startwith_from_list" association => a("is a list of type","slist","is used in"); "delete_if_match_from_list" comment => "Delete line if it fully matches a regex in the list", association => a("is a possible sub-body constraint for","delete_select","may have sub-body constraints"); body_constraints:: "delete_if_match_from_list" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Delete line if it fully matches a regex in the list"; "delete_if_match_from_list" association => a("is a list of type","slist","is used in"); "delete_if_not_match_from_list" comment => "Delete line if it DOES NOT fully match a regex in the list", association => a("is a possible sub-body constraint for","delete_select","may have sub-body constraints"); body_constraints:: "delete_if_not_match_from_list" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Delete line if it DOES NOT fully match a regex in the list"; "delete_if_not_match_from_list" association => a("is a list of type","slist","is used in"); "delete_if_contains_from_list" comment => "Delete line if a regex in the list match a line fragment", association => a("is a possible sub-body constraint for","delete_select","may have sub-body constraints"); body_constraints:: "delete_if_contains_from_list" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Delete line if a regex in the list match a line fragment"; "delete_if_contains_from_list" association => a("is a list of type","slist","is used in"); "delete_if_not_contains_from_list" comment => "Delete line if a regex in the list DOES NOT match a line fragment", association => a("is a possible sub-body constraint for","delete_select","may have sub-body constraints"); body_constraints:: "delete_if_not_contains_from_list" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Delete line if a regex in the list DOES NOT match a line fragment"; "delete_if_not_contains_from_list" association => a("is a list of type","slist","is used in"); promise_types:: "interfaces"; body_constraints:: "tcp_ip" comment => "Interface tcp/ip properties", association => a("is a possible body constraint for","promise_types::interfaces","can have body constraints"); "ipv4_address" comment => "IPv4 address for the interface", association => a("is a possible sub-body constraint for","tcp_ip","may have sub-body constraints"); body_constraints:: "ipv4_address" association => a("is a body constraint of type","string","has possible body constraints"), comment => "IPv4 address for the interface"; "ipv4_netmask" comment => "Netmask for the interface", association => a("is a possible sub-body constraint for","tcp_ip","may have sub-body constraints"); body_constraints:: "ipv4_netmask" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Netmask for the interface"; "ipv6_address" comment => "IPv6 address for the interface", association => a("is a possible sub-body constraint for","tcp_ip","may have sub-body constraints"); body_constraints:: "ipv6_address" association => a("is a body constraint of type","string","has possible body constraints"), comment => "IPv6 address for the interface"; promise_types:: "methods"; body_constraints:: "usebundle" comment => "Specify the name of a bundle to run as a parameterized method", association => a("is a possible body constraint for","promise_types::methods","can have body constraints"); body_constraints:: "usebundle" association => a("is a body constraint of type","(ext bundle)","has possible body constraints"), comment => "Specify the name of a bundle to run as a parameterized method"; promise_types:: "packages"; body_constraints:: "package_policy" comment => "Criteria for package installation/upgrade on the current system", association => a("is a possible body constraint for","promise_types::packages","can have body constraints"); body_constraints:: "package_policy" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Criteria for package installation/upgrade on the current system"; promise_types:: "packages"; body_constraints:: "package_method" comment => "Criteria for installation and verification", association => a("is a possible body constraint for","promise_types::packages","can have body constraints"); "package_changes" comment => "Menu option - whether to group packages into a single aggregate command", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_changes" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Menu option - whether to group packages into a single aggregate command"; "package_file_repositories" comment => "A list of machine-local directories to search for packages", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_file_repositories" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "A list of machine-local directories to search for packages"; "package_file_repositories" association => a("is a list of type","slist","is used in"); "package_list_command" comment => "Command to obtain a list of installed packages", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_list_command" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Command to obtain a list of installed packages"; "package_list_version_regex" comment => "Regular expression with one backreference to extract package version string", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_list_version_regex" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression with one backreference to extract package version string"; "package_list_name_regex" comment => "Regular expression with one backreference to extract package name string", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_list_name_regex" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression with one backreference to extract package name string"; "package_list_arch_regex" comment => "Regular expression with one backreference to extract package architecture string", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_list_arch_regex" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression with one backreference to extract package architecture string"; "package_patch_list_command" comment => "Command to obtain a list of available patches or updates", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_patch_list_command" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Command to obtain a list of available patches or updates"; "package_patch_version_regex" comment => "Regular expression with one backreference to extract update version string", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_patch_version_regex" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression with one backreference to extract update version string"; "package_patch_name_regex" comment => "Regular expression with one backreference to extract update name string", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_patch_name_regex" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression with one backreference to extract update name string"; "package_patch_arch_regex" comment => "Regular expression with one backreference to extract update architecture string", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_patch_arch_regex" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression with one backreference to extract update architecture string"; "package_patch_installed_regex" comment => "Regular expression which matches packages that are already installed", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_patch_installed_regex" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression which matches packages that are already installed"; "package_version_regex" comment => "Regular expression with one backreference to extract package version string", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_version_regex" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression with one backreference to extract package version string"; "package_name_regex" comment => "Regular expression with one backreference to extract package name string", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_name_regex" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression with one backreference to extract package name string"; "package_arch_regex" comment => "Regular expression with one backreference to extract package architecture string", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_arch_regex" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression with one backreference to extract package architecture string"; "package_installed_regex" comment => "Regular expression which matches packages that are already installed", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_installed_regex" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression which matches packages that are already installed"; "package_add_command" comment => "Command to install a package to the system", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_add_command" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Command to install a package to the system"; "package_delete_command" comment => "Command to remove a package from the system", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_delete_command" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Command to remove a package from the system"; "package_update_command" comment => "Command to update to the latest version a currently installed package", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_update_command" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Command to update to the latest version a currently installed package"; "package_patch_command" comment => "Command to update to the latest patch release of an installed package", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_patch_command" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Command to update to the latest patch release of an installed package"; "package_verify_command" comment => "Command to verify the correctness of an installed package", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_verify_command" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Command to verify the correctness of an installed package"; "package_noverify_regex" comment => "Regular expression to match verification failure output", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_noverify_regex" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression to match verification failure output"; "package_noverify_returncode" comment => "Integer return code indicating package verification failure", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_noverify_returncode" association => a("is a body constraint of type","int","has possible body constraints"), comment => "Integer return code indicating package verification failure"; "package_name_convention" comment => "This is how the package manager expects the file to be referred to, e.g. $(name).$(arch)", association => a("is a possible sub-body constraint for","package_method","may have sub-body constraints"); body_constraints:: "package_name_convention" association => a("is a body constraint of type","string","has possible body constraints"), comment => "This is how the package manager expects the file to be referred to, e.g. $(name).$(arch)"; promise_types:: "packages"; body_constraints:: "package_version" comment => "Version reference point for determining promised version", association => a("is a possible body constraint for","promise_types::packages","can have body constraints"); body_constraints:: "package_version" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Version reference point for determining promised version"; promise_types:: "packages"; body_constraints:: "package_architectures" comment => "Select the architecture for package selection", association => a("is a possible body constraint for","promise_types::packages","can have body constraints"); body_constraints:: "package_architectures" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "Select the architecture for package selection"; "package_architectures" association => a("is a list of type","slist","is used in"); promise_types:: "packages"; body_constraints:: "package_select" comment => "A criterion for first acceptable match relative to \"package_version\"", association => a("is a possible body constraint for","promise_types::packages","can have body constraints"); body_constraints:: "package_select" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "A criterion for first acceptable match relative to \"package_version\""; promise_types:: "processes"; body_constraints:: "signals" comment => "A list of menu options representing signals to be sent to a process", association => a("is a possible body constraint for","promise_types::processes","can have body constraints"); body_constraints:: "signals" association => a("is a body constraint of type","(option list)","has possible body constraints"), comment => "A list of menu options representing signals to be sent to a process"; promise_types:: "processes"; body_constraints:: "process_stop" comment => "A command used to stop a running process", association => a("is a possible body constraint for","promise_types::processes","can have body constraints"); body_constraints:: "process_stop" association => a("is a body constraint of type","string","has possible body constraints"), comment => "A command used to stop a running process"; promise_types:: "processes"; body_constraints:: "process_count" comment => "Criteria for constraining the number of processes matching other criteria", association => a("is a possible body constraint for","promise_types::processes","can have body constraints"); "match_range" comment => "Integer range for acceptable number of matches for this process", association => a("is a possible sub-body constraint for","process_count","may have sub-body constraints"); body_constraints:: "match_range" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Integer range for acceptable number of matches for this process"; "in_range_define" comment => "List of classes to define if the matches are in range", association => a("is a possible sub-body constraint for","process_count","may have sub-body constraints"); body_constraints:: "in_range_define" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of classes to define if the matches are in range"; "in_range_define" association => a("is a list of type","slist","is used in"); "out_of_range_define" comment => "List of classes to define if the matches are out of range", association => a("is a possible sub-body constraint for","process_count","may have sub-body constraints"); body_constraints:: "out_of_range_define" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of classes to define if the matches are out of range"; "out_of_range_define" association => a("is a list of type","slist","is used in"); promise_types:: "processes"; body_constraints:: "process_select" comment => "Criteria for matching processes in the system process table", association => a("is a possible body constraint for","promise_types::processes","can have body constraints"); "process_owner" comment => "List of regexes matching the user of a process", association => a("is a possible sub-body constraint for","process_select","may have sub-body constraints"); body_constraints:: "process_owner" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of regexes matching the user of a process"; "process_owner" association => a("is a list of type","slist","is used in"); "pid" comment => "Range of integers matching the process id of a process", association => a("is a possible sub-body constraint for","process_select","may have sub-body constraints"); body_constraints:: "pid" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Range of integers matching the process id of a process"; "ppid" comment => "Range of integers matching the parent process id of a process", association => a("is a possible sub-body constraint for","process_select","may have sub-body constraints"); body_constraints:: "ppid" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Range of integers matching the parent process id of a process"; "pgid" comment => "Range of integers matching the parent group id of a process", association => a("is a possible sub-body constraint for","process_select","may have sub-body constraints"); body_constraints:: "pgid" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Range of integers matching the parent group id of a process"; "rsize" comment => "Range of integers matching the resident memory size of a process", association => a("is a possible sub-body constraint for","process_select","may have sub-body constraints"); body_constraints:: "rsize" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Range of integers matching the resident memory size of a process"; "vsize" comment => "Range of integers matching the virtual memory size of a process", association => a("is a possible sub-body constraint for","process_select","may have sub-body constraints"); body_constraints:: "vsize" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Range of integers matching the virtual memory size of a process"; "status" comment => "Regular expression matching the status field of a process", association => a("is a possible sub-body constraint for","process_select","may have sub-body constraints"); body_constraints:: "status" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression matching the status field of a process"; "ttime_range" comment => "Range of integers matching the total elapsed time of a process", association => a("is a possible sub-body constraint for","process_select","may have sub-body constraints"); body_constraints:: "ttime_range" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Range of integers matching the total elapsed time of a process"; "stime_range" comment => "Range of integers matching the start time of a process", association => a("is a possible sub-body constraint for","process_select","may have sub-body constraints"); body_constraints:: "stime_range" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Range of integers matching the start time of a process"; "command" comment => "Regular expression matching the command/cmd field of a process", association => a("is a possible sub-body constraint for","process_select","may have sub-body constraints"); body_constraints:: "command" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression matching the command/cmd field of a process"; "tty" comment => "Regular expression matching the tty field of a process", association => a("is a possible sub-body constraint for","process_select","may have sub-body constraints"); body_constraints:: "tty" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression matching the tty field of a process"; "priority" comment => "Range of integers matching the priority field (PRI/NI) of a process", association => a("is a possible sub-body constraint for","process_select","may have sub-body constraints"); body_constraints:: "priority" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Range of integers matching the priority field (PRI/NI) of a process"; "threads" comment => "Range of integers matching the threads (NLWP) field of a process", association => a("is a possible sub-body constraint for","process_select","may have sub-body constraints"); body_constraints:: "threads" association => a("is a body constraint of type","irange [int,int]","has possible body constraints"), comment => "Range of integers matching the threads (NLWP) field of a process"; "process_result" comment => "Boolean class expression returning the logical combination of classes set by a process selection test", association => a("is a possible sub-body constraint for","process_select","may have sub-body constraints"); body_constraints:: "process_result" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Boolean class expression returning the logical combination of classes set by a process selection test"; promise_types:: "processes"; body_constraints:: "restart_class" comment => "A class to be set if the process is not running, so that a command: rule can be referred to restart the process", association => a("is a possible body constraint for","promise_types::processes","can have body constraints"); body_constraints:: "restart_class" association => a("is a body constraint of type","string","has possible body constraints"), comment => "A class to be set if the process is not running, so that a command: rule can be referred to restart the process"; promise_types:: "storage"; body_constraints:: "mount" comment => "Criteria for mounting foreign file systems", association => a("is a possible body constraint for","promise_types::storage","can have body constraints"); "mount_type" comment => "Protocol type of remote file system", association => a("is a possible sub-body constraint for","mount","may have sub-body constraints"); body_constraints:: "mount_type" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Protocol type of remote file system"; "mount_source" comment => "Path of remote file system to mount", association => a("is a possible sub-body constraint for","mount","may have sub-body constraints"); body_constraints:: "mount_source" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Path of remote file system to mount"; "mount_server" comment => "Hostname or IP or remote file system server", association => a("is a possible sub-body constraint for","mount","may have sub-body constraints"); body_constraints:: "mount_server" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Hostname or IP or remote file system server"; "mount_options" comment => "List of option strings to add to the file system table (\"fstab\")", association => a("is a possible sub-body constraint for","mount","may have sub-body constraints"); body_constraints:: "mount_options" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of option strings to add to the file system table (\"fstab\")"; "mount_options" association => a("is a list of type","slist","is used in"); "edit_fstab" comment => "true/false add or remove entries to the file system table (\"fstab\")", association => a("is a possible sub-body constraint for","mount","may have sub-body constraints"); body_constraints:: "edit_fstab" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false add or remove entries to the file system table (\"fstab\")"; "unmount" comment => "true/false unmount a previously mounted filesystem", association => a("is a possible sub-body constraint for","mount","may have sub-body constraints"); body_constraints:: "unmount" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false unmount a previously mounted filesystem"; promise_types:: "storage"; body_constraints:: "volume" comment => "Criteria for monitoring/probing mounted volumes", association => a("is a possible body constraint for","promise_types::storage","can have body constraints"); "check_foreign" comment => "true/false verify storage that is mounted from a foreign system on this host", association => a("is a possible sub-body constraint for","volume","may have sub-body constraints"); body_constraints:: "check_foreign" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false verify storage that is mounted from a foreign system on this host"; "freespace" comment => "Absolute or percentage minimum disk space that should be available before warning", association => a("is a possible sub-body constraint for","volume","may have sub-body constraints"); body_constraints:: "freespace" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Absolute or percentage minimum disk space that should be available before warning"; "sensible_size" comment => "Minimum size in bytes that should be used on a sensible-looking storage device", association => a("is a possible sub-body constraint for","volume","may have sub-body constraints"); body_constraints:: "sensible_size" association => a("is a body constraint of type","int","has possible body constraints"), comment => "Minimum size in bytes that should be used on a sensible-looking storage device"; "sensible_count" comment => "Minimum number of files that should be defined on a sensible-looking storage device", association => a("is a possible sub-body constraint for","volume","may have sub-body constraints"); body_constraints:: "sensible_count" association => a("is a body constraint of type","int","has possible body constraints"), comment => "Minimum number of files that should be defined on a sensible-looking storage device"; "scan_arrivals" comment => "true/false generate pseudo-periodic disk change arrival distribution", association => a("is a possible sub-body constraint for","volume","may have sub-body constraints"); body_constraints:: "scan_arrivals" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false generate pseudo-periodic disk change arrival distribution"; promise_types:: "access"; body_constraints:: "admit" comment => "List of host names or IP addresses to grant access to file objects", association => a("is a possible body constraint for","promise_types::access","can have body constraints"); body_constraints:: "admit" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of host names or IP addresses to grant access to file objects"; "admit" association => a("is a list of type","slist","is used in"); promise_types:: "access"; body_constraints:: "deny" comment => "List of host names or IP addresses to deny access to file objects", association => a("is a possible body constraint for","promise_types::access","can have body constraints"); body_constraints:: "deny" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of host names or IP addresses to deny access to file objects"; "deny" association => a("is a list of type","slist","is used in"); promise_types:: "access"; body_constraints:: "maproot" comment => "List of host names or IP addresses to grant full read-privilege on the server", association => a("is a possible body constraint for","promise_types::access","can have body constraints"); body_constraints:: "maproot" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of host names or IP addresses to grant full read-privilege on the server"; "maproot" association => a("is a list of type","slist","is used in"); promise_types:: "access"; body_constraints:: "ifencrypted" comment => "true/false whether the current file access promise is conditional on the connection from the client being encrypted", association => a("is a possible body constraint for","promise_types::access","can have body constraints"); body_constraints:: "ifencrypted" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "true/false whether the current file access promise is conditional on the connection from the client being encrypted"; promise_types:: "access"; body_constraints:: "resource_type" comment => "The type of object being granted access. The default is access to files.", association => a("is a possible body constraint for","promise_types::access","can have body constraints"); body_constraints:: "resource_type" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "The type of object being granted access. The default is access to files."; promise_types:: "roles"; body_constraints:: "authorize" comment => "List of public-key user names that are allowed to activate the promised class during remote agent activation", association => a("is a possible body constraint for","promise_types::roles","can have body constraints"); body_constraints:: "authorize" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of public-key user names that are allowed to activate the promised class during remote agent activation"; "authorize" association => a("is a list of type","slist","is used in"); promise_types:: "topics"; body_constraints:: "association" comment => "Declare associated topics", association => a("is a possible body constraint for","promise_types::topics","can have body constraints"); "forward_relationship" comment => "Name of forward association between promiser topic and associates", association => a("is a possible sub-body constraint for","association","may have sub-body constraints"); body_constraints:: "forward_relationship" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Name of forward association between promiser topic and associates"; "backward_relationship" comment => "Name of backward/inverse association from associates to promiser topic", association => a("is a possible sub-body constraint for","association","may have sub-body constraints"); body_constraints:: "backward_relationship" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Name of backward/inverse association from associates to promiser topic"; "associates" comment => "List of associated topics by this forward relationship", association => a("is a possible sub-body constraint for","association","may have sub-body constraints"); body_constraints:: "associates" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of associated topics by this forward relationship"; "associates" association => a("is a list of type","slist","is used in"); promise_types:: "topics"; body_constraints:: "comment" comment => "Retained comment about this promise's real intention", association => a("is a possible body constraint for","promise_types::topics","can have body constraints"); body_constraints:: "comment" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Retained comment about this promise's real intention"; promise_types:: "occurrences"; body_constraints:: "represents" comment => "List of subtopics that explains the type(s) of information represented by the occurrence", association => a("is a possible body constraint for","promise_types::occurrences","can have body constraints"); body_constraints:: "represents" association => a("is a body constraint of type","slist","has possible body constraints"), comment => "List of subtopics that explains the type(s) of information represented by the occurrence"; "represents" association => a("is a list of type","slist","is used in"); promise_types:: "occurrences"; body_constraints:: "representation" comment => "How to interpret the promiser string e.g. actual data or reference to data", association => a("is a possible body constraint for","promise_types::occurrences","can have body constraints"); body_constraints:: "representation" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "How to interpret the promiser string e.g. actual data or reference to data"; promise_types:: "occurrences"; body_constraints:: "web_root" comment => "Base URL of the occurrence when rendered as a web-URL (replaces path_root)", association => a("is a possible body constraint for","promise_types::occurrences","can have body constraints"); body_constraints:: "web_root" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Base URL of the occurrence when rendered as a web-URL (replaces path_root)"; promise_types:: "occurrences"; body_constraints:: "path_root" comment => "Base path of the occurrence when locating file (replaced by web_root)", association => a("is a possible body constraint for","promise_types::occurrences","can have body constraints"); body_constraints:: "path_root" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Base path of the occurrence when locating file (replaced by web_root)"; promise_types:: "measurements"; body_constraints:: "stream_type" comment => "The datatype being collected.", association => a("is a possible body constraint for","promise_types::measurements","can have body constraints"); body_constraints:: "stream_type" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "The datatype being collected."; promise_types:: "measurements"; body_constraints:: "data_type" comment => "The datatype being collected.", association => a("is a possible body constraint for","promise_types::measurements","can have body constraints"); body_constraints:: "data_type" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "The datatype being collected."; promise_types:: "measurements"; body_constraints:: "history_type" comment => "Whether the data can be seen as a time-series or just an isolated value", association => a("is a possible body constraint for","promise_types::measurements","can have body constraints"); body_constraints:: "history_type" association => a("is a body constraint of type","(menu option)","has possible body constraints"), comment => "Whether the data can be seen as a time-series or just an isolated value"; promise_types:: "measurements"; body_constraints:: "units" comment => "The engineering dimensions of this value or a note about its intent used in plots", association => a("is a possible body constraint for","promise_types::measurements","can have body constraints"); body_constraints:: "units" association => a("is a body constraint of type","string","has possible body constraints"), comment => "The engineering dimensions of this value or a note about its intent used in plots"; promise_types:: "measurements"; body_constraints:: "match_value" comment => "Criteria for extracting the measurement from a datastream", association => a("is a possible body constraint for","promise_types::measurements","can have body constraints"); "select_line_matching" comment => "Regular expression for matching line location", association => a("is a possible sub-body constraint for","match_value","may have sub-body constraints"); body_constraints:: "select_line_matching" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression for matching line location"; "select_line_number" comment => "Read from the n-th line of the output (fixed format)", association => a("is a possible sub-body constraint for","match_value","may have sub-body constraints"); body_constraints:: "select_line_number" association => a("is a body constraint of type","int","has possible body constraints"), comment => "Read from the n-th line of the output (fixed format)"; "extraction_regex" comment => "Regular expression that should contain a single backreference for extracting a value", association => a("is a possible sub-body constraint for","match_value","may have sub-body constraints"); body_constraints:: "extraction_regex" association => a("is a body constraint of type","string","has possible body constraints"), comment => "Regular expression that should contain a single backreference for extracting a value"; "action"; "classes"; "ifvarclass"; "handle"; "depends_on"; "comment"; "select_region"; functions:: "accessedbefore" comment => "True if arg1 was accessed before arg2 (atime)", association => a("returns data-type","class","is returned by function"); "accumulated" comment => "Convert an accumulated amount of time into a system representation", association => a("returns data-type","int","is returned by function"); "ago" comment => "Convert a time relative to now to an integer system representation", association => a("returns data-type","int","is returned by function"); "canonify" comment => "Convert an abitrary string into a legal class name", association => a("returns data-type","string","is returned by function"); "changedbefore" comment => "True if arg1 was changed before arg2 (ctime)", association => a("returns data-type","class","is returned by function"); "classify" comment => "True if the canonicalization of the argument is a currently defined class", association => a("returns data-type","class","is returned by function"); "classmatch" comment => "True if the regular expression matches any currently defined class", association => a("returns data-type","class","is returned by function"); "execresult" comment => "Execute named command and assign output to variable", association => a("returns data-type","string","is returned by function"); "fileexists" comment => "True if the named file can be accessed", association => a("returns data-type","class","is returned by function"); "filesexist" comment => "True if the named list of files can ALL be accessed", association => a("returns data-type","class","is returned by function"); "getindices" comment => "Get a list of keys to the array whose id is the argument and assign to variable", association => a("returns data-type","slist","is returned by function"); "getgid" comment => "Return the integer group id of the named group on this host", association => a("returns data-type","int","is returned by function"); "getuid" comment => "Return the integer user id of the named user on this host", association => a("returns data-type","int","is returned by function"); "groupexists" comment => "True if group or numerical id exists on this host", association => a("returns data-type","class","is returned by function"); "hash" comment => "Return the hash of arg1, type arg2 and assign to a variable", association => a("returns data-type","string","is returned by function"); "hashmatch" comment => "Compute the hash of arg1, of type arg2 and test if it matches the value in arg 3", association => a("returns data-type","class","is returned by function"); "hostrange" comment => "True if the current host lies in the range of enumerated hostnames specified", association => a("returns data-type","class","is returned by function"); "hostinnetgroup" comment => "True if the current host is in the named netgroup", association => a("returns data-type","class","is returned by function"); "iprange" comment => "True if the current host lies in the range of IP addresses specified", association => a("returns data-type","class","is returned by function"); "irange" comment => "Define a range of integer values for cfengine internal use", association => a("returns data-type","irange [int,int]","is returned by function"); "isdir" comment => "True if the named object is a directory", association => a("returns data-type","class","is returned by function"); "isgreaterthan" comment => "True if arg1 is numerically greater than arg2, else compare strings like strcmp", association => a("returns data-type","class","is returned by function"); "islessthan" comment => "True if arg1 is numerically less than arg2, else compare strings like NOT strcmp", association => a("returns data-type","class","is returned by function"); "islink" comment => "True if the named object is a symbolic link", association => a("returns data-type","class","is returned by function"); "isnewerthan" comment => "True if arg1 is newer (modified later) than arg2 (mtime)", association => a("returns data-type","class","is returned by function"); "isplain" comment => "True if the named object is a plain/regular file", association => a("returns data-type","class","is returned by function"); "isvariable" comment => "True if the named variable is defined", association => a("returns data-type","class","is returned by function"); "lastnode" comment => "Extract the last of a separated string, e.g. filename from a path", association => a("returns data-type","string","is returned by function"); "ldaparray" comment => "Extract all values from an ldap record", association => a("returns data-type","class","is returned by function"); "ldaplist" comment => "Extract all named values from multiple ldap records", association => a("returns data-type","slist","is returned by function"); "ldapvalue" comment => "Extract the first matching named value from ldap", association => a("returns data-type","string","is returned by function"); "now" comment => "Convert the current time into system representation", association => a("returns data-type","int","is returned by function"); "on" comment => "Convert an exact date/time to an integer system representation", association => a("returns data-type","int","is returned by function"); "peers" comment => "Get a list of peers (not including ourself) from the partition to which we belong", association => a("returns data-type","slist","is returned by function"); "peerleader" comment => "Get the assigned peer-leader of the partition to which we belong", association => a("returns data-type","string","is returned by function"); "peerleaders" comment => "Get a list of peer leaders from the named partitioning", association => a("returns data-type","slist","is returned by function"); "randomint" comment => "Generate a random integer between the given limits", association => a("returns data-type","int","is returned by function"); "readfile" comment => "Read max number of bytes from named file and assign to variable", association => a("returns data-type","string","is returned by function"); "readintarray" comment => "Read an array of integers from a file and assign the dimension to a variable", association => a("returns data-type","int","is returned by function"); "readintlist" comment => "Read and assign a list variable from a file of separated ints", association => a("returns data-type","ilist","is returned by function"); "readrealarray" comment => "Read an array of real numbers from a file and assign the dimension to a variable", association => a("returns data-type","int","is returned by function"); "readreallist" comment => "Read and assign a list variable from a file of separated real numbers", association => a("returns data-type","rlist","is returned by function"); "readstringarray" comment => "Read an array of strings from a file and assign the dimension to a variable", association => a("returns data-type","int","is returned by function"); "readstringlist" comment => "Read and assign a list variable from a file of separated strings", association => a("returns data-type","slist","is returned by function"); "readtcp" comment => "Connect to tcp port, send string and assign result to variable", association => a("returns data-type","string","is returned by function"); "regarray" comment => "True if arg1 matches any item in the associative array with id=arg2", association => a("returns data-type","class","is returned by function"); "regcmp" comment => "True if arg2 is a regular expression matching arg1", association => a("returns data-type","class","is returned by function"); "registryvalue" comment => "Returns a value for an MS-Win registry key,value pair", association => a("returns data-type","string","is returned by function"); "regline" comment => "True if arg2 is a regular expression matching a line in file arg1", association => a("returns data-type","class","is returned by function"); "reglist" comment => "True if arg2 matches any item in the list with id=arg1", association => a("returns data-type","class","is returned by function"); "regldap" comment => "True if arg6 is a regular expression matching a value item in an ldap search", association => a("returns data-type","class","is returned by function"); "remotescalar" comment => "Read a scalar value from a remote cfengine server", association => a("returns data-type","string","is returned by function"); "returnszero" comment => "True if named shell command has exit status zero", association => a("returns data-type","class","is returned by function"); "rrange" comment => "Define a range of real numbers for cfengine internal use", association => a("returns data-type","rrange [real,real]","is returned by function"); "selectservers" comment => "Select tcp servers which respond correctly to a query and return their number, set array of names", association => a("returns data-type","int","is returned by function"); "splayclass" comment => "True if the first argument's time-slot has arrived, according to a policy in arg2", association => a("returns data-type","class","is returned by function"); "splitstring" comment => "Convert a string in arg1 into a list of max arg3 strings by splitting on a regular expression in arg2", association => a("returns data-type","slist","is returned by function"); "strcmp" comment => "True if the two strings match exactly", association => a("returns data-type","class","is returned by function"); "usemodule" comment => "Execute cfengine module script and set class if successful", association => a("returns data-type","class","is returned by function"); "userexists" comment => "True if user name or numerical id exists on this host", association => a("returns data-type","class","is returned by function"); topics: bundles:: "update"; contexts:: "any"; promisers:: "master_location" association => a("occurs in bundle","bundles::update","bundle contains promiser"); "master_location" association => a("makes promise of type","promise_types::vars","promises have been made by"); "master_location" association => a("makes promises","promise_unit_update_cf_13","is a promise made by"); promise_types:: "vars" association => a("is employed in bundle","update","employs promises of type"); promises:: "promise_unit_update_cf_13" comment => "(Uncommented promise of type vars made by: master_location..)"; "promise_unit_update_cf_13" association => a("is activated by class context","any","activates promises"); "promise_unit_update_cf_13" association => a("is a promise of type","vars","has current exemplars"); occurrences: promise_unit_update_cf_13:: "promises.cf.html#promise_unit_update_cf_13" comment => "A promise of type vars made by: master_location", represents => { "any", "vars" }; any:: "promises.cf.html#promise_unit_update_cf_13" represents => { "promise", "master_location", "vars" }; update:: "promises.cf.html#bundle_update" represents => { "bundle reference" }; string:: "promises.cf.html#promise_unit_update_cf_13" represents => { "used in promise", "promise_unit_update_cf_13" }; topics: bundles:: "update"; contexts:: "any"; promisers:: "pservers" association => a("occurs in bundle","bundles::update","bundle contains promiser"); "pservers" association => a("makes promise of type","promise_types::vars","promises have been made by"); "pservers" association => a("makes promises","promise_unit_update_cf_15","is a promise made by"); promise_types:: "vars" association => a("is employed in bundle","update","employs promises of type"); promises:: "promise_unit_update_cf_15" comment => "IP address to locate your policy host."; "promise_unit_update_cf_15" association => a("is activated by class context","any","activates promises"); "promise_unit_update_cf_15" association => a("is a promise of type","vars","has current exemplars"); occurrences: promise_unit_update_cf_15:: "promises.cf.html#promise_unit_update_cf_15" comment => "IP address to locate your policy host.", represents => { "any", "vars" }; any:: "promises.cf.html#promise_unit_update_cf_15" represents => { "promise", "pservers", "vars" }; update:: "promises.cf.html#bundle_update" represents => { "bundle reference" }; int:: "promises.cf.html#promise_unit_update_cf_15" represents => { "used in promise", "promise_unit_update_cf_15" }; comment:: "promises.cf.html#promise_unit_update_cf_15" represents => { "used in promise", "promise_unit_update_cf_15" }; "IP address to locate your policy host." representation => "literal", represents => { "promise_unit_update_cf_15" }; promise_unit_update_cf_15:: "IP address to locate your policy host." representation => "literal", represents => { "comment" }; topics: bundles:: "update"; contexts:: "!have_ppkeys"; promisers:: "/usr/local/sbin/cf-key" association => a("occurs in bundle","bundles::update","bundle contains promiser"); "/usr/local/sbin/cf-key" association => a("makes promise of type","promise_types::commands","promises have been made by"); "/usr/local/sbin/cf-key" association => a("makes promises","promise_unit_update_cf_31","is a promise made by"); promise_types:: "commands" association => a("is employed in bundle","update","employs promises of type"); promises:: "promise_unit_update_cf_31" comment => "(Uncommented promise of type commands made by: /usr/local/sbin/cf-key..)"; "promise_unit_update_cf_31" association => a("is activated by class context","!have_ppkeys","activates promises"); "promise_unit_update_cf_31" association => a("is a promise of type","commands","has current exemplars"); occurrences: promise_unit_update_cf_31:: "promises.cf.html#promise_unit_update_cf_31" comment => "A promise of type commands made by: /usr/local/sbin/cf-key", represents => { "!have_ppkeys", "commands" }; _have_ppkeys:: "promises.cf.html#promise_unit_update_cf_31" represents => { "promise", "/usr/local/sbin/cf-key", "commands" }; update:: "promises.cf.html#bundle_update" represents => { "bundle reference" }; topics: bundles:: "update"; contexts:: "xx"; promisers:: "/var/cfengine/inputs" association => a("occurs in bundle","bundles::update","bundle contains promiser"); "/var/cfengine/inputs" association => a("makes promise of type","promise_types::files","promises have been made by"); "/var/cfengine/inputs" association => a("makes promises","update_policy","is a promise made by"); promise_types:: "files" association => a("is employed in bundle","update","employs promises of type"); promises:: "update_policy" comment => "(Uncommented promise of type files made by: /var/cfengine/inputs..)"; "update_policy" association => a("is activated by class context","xx","activates promises"); "update_policy" association => a("is a promise of type","files","has current exemplars"); occurrences: update_policy:: "promises.cf.html#update_policy" comment => "A promise of type files made by: /var/cfengine/inputs", represents => { "xx", "files" }; xx:: "promises.cf.html#update_policy" represents => { "promise", "/var/cfengine/inputs", "files" }; update:: "promises.cf.html#bundle_update" represents => { "bundle reference" }; handle:: "promises.cf.html#update_policy" represents => { "used in promise", "update_policy" }; perms:: "promises.cf.html#update_policy" represents => { "used in promise", "update_policy" }; mode:: "promises.cf.html#update_policy" represents => { "used in promise", "update_policy" }; copy_from:: "promises.cf.html#update_policy" represents => { "used in promise", "update_policy" }; source:: "promises.cf.html#update_policy" represents => { "used in promise", "update_policy" }; compare:: "promises.cf.html#update_policy" represents => { "used in promise", "update_policy" }; trustkey:: "promises.cf.html#update_policy" represents => { "used in promise", "update_policy" }; servers:: "promises.cf.html#update_policy" represents => { "used in promise", "update_policy" }; depth_search:: "promises.cf.html#update_policy" represents => { "used in promise", "update_policy" }; depth:: "promises.cf.html#update_policy" represents => { "used in promise", "update_policy" }; action:: "promises.cf.html#update_policy" represents => { "used in promise", "update_policy" }; ifelapsed:: "promises.cf.html#update_policy" represents => { "used in promise", "update_policy" }; topics: bundles:: "update"; contexts:: "xx"; promisers:: "/var/cfengine/bin" association => a("occurs in bundle","bundles::update","bundle contains promiser"); "/var/cfengine/bin" association => a("makes promise of type","promise_types::files","promises have been made by"); "/var/cfengine/bin" association => a("makes promises","promise_unit_update_cf_47","is a promise made by"); promise_types:: "files" association => a("is employed in bundle","update","employs promises of type"); promises:: "promise_unit_update_cf_47" comment => "(Uncommented promise of type files made by: /var/cfengine/bin..)"; "promise_unit_update_cf_47" association => a("is activated by class context","xx","activates promises"); "promise_unit_update_cf_47" association => a("is a promise of type","files","has current exemplars"); occurrences: promise_unit_update_cf_47:: "promises.cf.html#promise_unit_update_cf_47" comment => "A promise of type files made by: /var/cfengine/bin", represents => { "xx", "files" }; xx:: "promises.cf.html#promise_unit_update_cf_47" represents => { "promise", "/var/cfengine/bin", "files" }; update:: "promises.cf.html#bundle_update" represents => { "bundle reference" }; perms:: "promises.cf.html#promise_unit_update_cf_47" represents => { "used in promise", "promise_unit_update_cf_47" }; mode:: "promises.cf.html#promise_unit_update_cf_47" represents => { "used in promise", "promise_unit_update_cf_47" }; copy_from:: "promises.cf.html#promise_unit_update_cf_47" represents => { "used in promise", "promise_unit_update_cf_47" }; source:: "promises.cf.html#promise_unit_update_cf_47" represents => { "used in promise", "promise_unit_update_cf_47" }; compare:: "promises.cf.html#promise_unit_update_cf_47" represents => { "used in promise", "promise_unit_update_cf_47" }; trustkey:: "promises.cf.html#promise_unit_update_cf_47" represents => { "used in promise", "promise_unit_update_cf_47" }; servers:: "promises.cf.html#promise_unit_update_cf_47" represents => { "used in promise", "promise_unit_update_cf_47" }; depth_search:: "promises.cf.html#promise_unit_update_cf_47" represents => { "used in promise", "promise_unit_update_cf_47" }; depth:: "promises.cf.html#promise_unit_update_cf_47" represents => { "used in promise", "promise_unit_update_cf_47" }; action:: "promises.cf.html#promise_unit_update_cf_47" represents => { "used in promise", "promise_unit_update_cf_47" }; ifelapsed:: "promises.cf.html#promise_unit_update_cf_47" represents => { "used in promise", "promise_unit_update_cf_47" }; topics: bundles:: "update"; contexts:: "any|bootstrap_mode.policy_host"; promisers:: "I am the policy host - i.e. with ipv4 address $(policy_server[0])" association => a("occurs in bundle","bundles::update","bundle contains promiser"); "I am the policy host - i.e. with ipv4 address $(policy_server[0])" association => a("makes promise of type","promise_types::reports","promises have been made by"); "I am the policy host - i.e. with ipv4 address $(policy_server[0])" association => a("makes promises","promise_unit_update_cf_56","is a promise made by"); promise_types:: "reports" association => a("is employed in bundle","update","employs promises of type"); promises:: "promise_unit_update_cf_56" comment => "(Uncommented promise of type reports made by: I am the policy host - i...)"; "promise_unit_update_cf_56" association => a("is activated by class context","any|bootstrap_mode.policy_host","activates promises"); "promise_unit_update_cf_56" association => a("is a promise of type","reports","has current exemplars"); occurrences: promise_unit_update_cf_56:: "promises.cf.html#promise_unit_update_cf_56" comment => "A promise of type reports made by: I am the policy host - i.e. with ipv4 address $(policy_server[0])", represents => { "any|bootstrap_mode.policy_host", "reports" }; any_bootstrap_mode_policy_host:: "promises.cf.html#promise_unit_update_cf_56" represents => { "promise", "I am the policy host - i.e. with ipv4 address $(policy_server[0])", "reports" }; update:: "promises.cf.html#bundle_update" represents => { "bundle reference" }; topics: bundles:: "update"; contexts:: "nofile"; promisers:: "found file" association => a("occurs in bundle","bundles::update","bundle contains promiser"); "found file" association => a("makes promise of type","promise_types::reports","promises have been made by"); "found file" association => a("makes promises","promise_unit_update_cf_60","is a promise made by"); promise_types:: "reports" association => a("is employed in bundle","update","employs promises of type"); promises:: "promise_unit_update_cf_60" comment => "(Uncommented promise of type reports made by: found file..)"; "promise_unit_update_cf_60" association => a("is activated by class context","nofile","activates promises"); "promise_unit_update_cf_60" association => a("is a promise of type","reports","has current exemplars"); occurrences: promise_unit_update_cf_60:: "promises.cf.html#promise_unit_update_cf_60" comment => "A promise of type reports made by: found file", represents => { "nofile", "reports" }; nofile:: "promises.cf.html#promise_unit_update_cf_60" represents => { "promise", "found file", "reports" }; update:: "promises.cf.html#bundle_update" represents => { "bundle reference" }; } cfengine-3.2.4/examples/unit_mount_fs.cf0000644000175000017500000000264011707771422015252 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # cfengine 3 # # cf-agent -f ./cftest.cf -K # body common control { bundlesequence => { "mounts" }; } # bundle agent mounts { storage: "/mnt" mount => nfs("slogans.iu.hio.no","/home"); } ###################################################################### body mount nfs(server,source) { mount_type => "nfs"; mount_source => "$(source)"; mount_server => "$(server)"; #mount_options => { "rw" }; edit_fstab => "true"; unmount => "true"; } cfengine-3.2.4/examples/unit_hostrange.cf0000644000175000017500000000236611707771422015417 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { classes: "compute_nodes" expression => hostrange("cpu-","01-32"); reports: compute_nodes:: "No computer is a cluster"; } cfengine-3.2.4/examples/unit_classvar_convergence.cf0000644000175000017500000000263111707771422017614 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "tryclasses_1" }; } ################################# bundle agent tryclasses_1 { vars: "x" string => "one"; "y" slist => { "linux", "Friday" }; classes: "three" and => { "$(x)", "two" }; "four" or => { @(y) }; "one" expression => "any"; "two" expression => "any"; reports: three:: "Evaluated true"; four:: "List substitution works"; } #################################cfengine-3.2.4/examples/unit_definitions.cf0000644000175000017500000000522111707771422015731 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # # Testing some variable/class definitions - note scope # # Use browser -f promise_output_agent.html to view # body common control { bundlesequence => { "mycommon", "assign" }; } ########################################################### bundle common mycommon { classes: "global_class" expression => "any"; "another_global" xor => { "any", "linux", "solaris"}; } ########################################################### bundle agent assign { vars: "scalar" int => "16k"; # "xxx" string => readfile( "/home/mark/tmp/testfile" , "33" ); "ran" int => randomint(4,88); # "yyy" slist => { readstringlist("/home/mark/tmp/testlist","#[a-zA-Z0-9 ]*","[^a-zA-Z0-9]",15,4000) }; # "zzz" slist => { readstringlist("/home/mark/tmp/testlist2","#[^\n]*",",",5,4000) }; # "aaa" ilist => { readintlist("/home/mark/tmp/testilist","#[a-zA-Z0-9 ]*",",",10,4000) }; "dim_array" int => readstringarray("array_name","/etc/passwd","#[^\n]*",":",10,4000); classes: # Standard aliasing "myclass" or => { "solaris", "linux" }; # got_array is a class that says whether the read was successful # array_name[] is the lval # Create a distribution "my_dist" dist => { "10", "20", "30", "40" }; # # Now like "alerts" in cf2 # reports: linux:: "Dimension of passwd array $(dim_array)"; "Read item from list: $(yyy)"; # Any kind of rule can define classes on exit "Read this file: [$(xxx)] ..." classes => persist("alertclass","20"); } ###################################################################### body classes persist(class,time) { promise_repaired => { "$(class)" }; persist_time => "$(time)"; timer_policy => "absolute"; }cfengine-3.2.4/examples/unit_software_dist.cf0000644000175000017500000001444211715232734016275 00000000000000# This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################################### # # software_local.cf - Application Deployment From Directory Repository # # NOTE: Windows needs to support WMI queries about installed msi files # in order for Cfengine to detect them. On Windows 2003, # go to Control Panel -> Add/Remove Programs -> # Windows Components -> Mgmnt and Monitoring Tools and check # WMI Windows Installer Provider. # # NOTE: Naming conventions are important when updating packages. # By default, Cfengine expects "name-version-arch.msi" # on Windows, where name is lowercase, and arch is # i686 or x86_64. No spaces should be included in the filename. # The Caption and Version fields inside the msi package # are important. They must correspond to the file name as # follows: name = lowercase(spacetodash(Caption)), # version = Version. For any msi-file, use InstEd # (www.instedit.com) to check/modify the # Caption and Version fields # (Tables->Property->ProductName/ProductVersion). # # For example, ProductName "Cfengine Nova" with ProductVersion # "1.1.2" for 32-bit Windows will correspond to the filename # "cfengine-nova-1.1.2-i686.msi". # ######################################################################### bundle agent check_software { vars: # software to install if not installed "include_software" slist => { "7-zip-4.50-$(sys.arch).msi" }; # this software gets updated if it is installed "autoupdate_software" slist => { "7-zip" }; # software to uninstall if it is installed "exclude_software" slist => { "7-zip-4.65-$(sys.arch).msi" }; methods: # "any" usebundle => add_software( "@(check_software.include_software)", "$(sys.policy_hub)" ); # "any" usebundle => update_software( "@(check_software.autoupdate_software)", "$(sys.policy_hub)" ); # "any" usebundle => remove_software( "@(check_software.exclude_software)", "$(sys.policy_hub)" ); } ######################################################################### bundle agent add_software(pkg_name, srv) { vars: # dir to install from locally - can also check multiple directories "local_software_dir" string => "C:\Program Files\Cfengine\software\add"; files: "$(local_software_dir)" copy_from => remote_cp("/var/cfengine/master_software_updates/$(sys.flavour)_$(sys.arch)/add", "$(srv)"), depth_search => recurse("1"), classes => if_repaired("got_newpkg"), comment => "Copy software from remote repository"; packages: # When to check if the package is installed ? got_newpkg|any:: "$(pkg_name)" package_policy => "add", package_method => msi_implicit( "$(local_software_dir)" ), classes => if_else("add_success", "add_fail" ), comment => "Install new software, if not already present"; reports:: add_fail:: "Failed to install one or more packages"; } ######################################################################### bundle agent update_software(sw_names, srv) { vars: # dir to install from locally - can also check multiple directories "local_software_dir" string => "C:\Program Files\Cfengine\software\update"; files: "$(local_software_dir)" copy_from => remote_cp("/var/cfengine/master_software_updates/$(sys.flavour)_$(sys.arch)/update", "$(srv)"), depth_search => recurse("1"), classes => if_repaired("got_newpkg"), comment => "Copy software updates from remote repository"; packages: # When to check if the package is updated ? got_newpkg|any:: "$(sw_names)" package_policy => "update", package_select => ">=", # picks the newest update available package_architectures => { "$(sys.arch)" }, # install 32 or 64 bit package ? package_version => "1.0", # at least version 1.0 package_method => msi_explicit( "$(local_software_dir)" ), classes => if_else("update_success", "update_fail"); reports:: update_fail:: "Failed to update one or more packages"; } ######################################################################### bundle agent remove_software(pkg_name, srv) { vars: # dir to install from locally - can also check multiple directories "local_software_dir" string => "C:\Program Files\Cfengine\software\remove"; files: "$(local_software_dir)" copy_from => remote_cp("/var/cfengine/master_software_updates/$(sys.flavour)_$(sys.arch)/remove", "$(srv)"), depth_search => recurse("1"), classes => if_repaired("got_newpkg"), comment => "Copy removable software from remote repository"; packages: got_newpkg:: "$(pkg_name)" package_policy => "delete", package_method => msi_implicit( "$(local_software_dir)" ), classes => if_else("remove_success", "remove_fail" ), comment => "Remove software, if present"; reports:: remove_fail:: "Failed to remove one or more packages"; } cfengine-3.2.4/examples/unit_user_edit.cf0000644000175000017500000000333011707771422015400 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. # body common control { bundlesequence => { "users" }; } body agent control { abortbundleclasses => { "ldap_fail" }; } ################################################################################ bundle agent users { vars: "users" slist => { "mark", "nakarin", "jonhenrik" }; files: "/tmp/passwd2" create => "true", edit_line => fix_passwd("$(users)"); reports: !ldap_fail:: "Editing user $(users)"; } ################################################################################################### bundle edit_line fix_passwd(x) { classes: "ldap_fail" not => ldaparray("dat","ldap://eternity.iu.hio.no","dc=cfengine,dc=com","(uid=$(x))","subtree","none"); insert_lines: "Hello $(x),$(dat[uid]),$(dat[gecos])"; }cfengine-3.2.4/examples/unit_setuidlog.cf0000644000175000017500000000277111707771422015424 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { files: "/home/mark/tmp" -> "me" changes => tripwire, depth_search => recurse("1"); } ######################################################### body changes tripwire { hash => "md5"; report_changes => "content"; update_hashes => "true"; } ######################################################### body depth_search recurse(d) { depth => "$(d)"; } cfengine-3.2.4/examples/unit_fileperms.cf0000644000175000017500000000250311707771422015404 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "main" }; } ######################################################### bundle agent main { files: "/tmp/foo" perms => p("at","0750"); } ######################################################### body perms p(user,mode) { owners => { "$(user)" }; mode => "$(mode)"; } cfengine-3.2.4/examples/unit_ago.cf0000644000175000017500000000334511707771422014171 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ######################################################## # # Simple test processes # ######################################################## body common control { bundlesequence => { "testbundle" }; } ######################################################## bundle agent testbundle { processes: ".*" process_count => anyprocs, process_select => proc_finder; reports: any_procs:: "Found processes out of range"; } ######################################################## body process_select proc_finder { stime_range => irange(ago(0,6,0,5,30,0),ago(0,0,0,0,20,0)); process_result => "stime"; } ######################################################## body process_count anyprocs { match_range => "0,0"; out_of_range_define => { "any_procs" }; } cfengine-3.2.4/examples/unit_hash.cf0000644000175000017500000000302111707771422014335 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "example" }; } ########################################################### bundle agent example { vars: "md5" string => hash("Cfengine is not cryptic","md5"); "sha256" string => hash("Cfengine is not cryptic","sha256"); "sha384" string => hash("Cfengine is not cryptic","sha384"); "sha512" string => hash("Cfengine is not cryptic","sha512"); reports: cfengine_3:: "Hashed to: md5 $(md5)"; "Hashed to: sha256 $(sha256)"; "Hashed to: sha384 $(sha384)"; "Hashed to: sha512 $(sha512)"; } cfengine-3.2.4/examples/unit_reporttofile.cf0000644000175000017500000000220711707771422016135 00000000000000# Copyright (C) Cfengine AS # This file is part of Cfengine 3 - written and maintained by Cfengine AS. # 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; version 3. # 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 # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commerical Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. body common control { bundlesequence => { "test" }; } # bundle agent test { reports: linux:: "$(sys.date),This is a report" report_to_file => "/tmp/test_log"; }cfengine-3.2.4/examples/unit_parsestringarray.cf0000644000175000017500000000106411707771422017017 00000000000000 body common control { bundlesequence => { test("/tmp/test.txt") }; } bundle agent test(f) { vars: ####################################### # Define data inline for convenience ####################################### "table" string => "one: a two: b three: c"; ####################################### "dim" int => parsestringarray( "items", "$(table)", "\s*#[^\n]*", ":", "1000", "200000" ); "keys" slist => getindices("items"); reports: cfengine_3:: "$(keys)"; } cfengine-3.2.4/ChangeLog0000644000175000017500000004361511715232733012006 000000000000003.2.4 (Bugfix and Stability release) Fixed failure in network transfer in case of misbehaving peer A few tiny memory leaks on error paths fixed 3.2.3 (Bugfix and Stability release) A few tiny memory leaks fixed Improved performance of cf-serverd under heavy load with TokyoCabinet database Full list of issues fixed is available on https://cfengine.com/bugtracker/changelog_page.php 3.2.2 (Bugfix and Stability release) Enabled compilation in "large files" mode under AIX Alleviated problem with broken file transfers over unstable Internet links. Full list of issues fixed is available on https://cfengine.com/bugtracker/changelog_page.php 3.2.1 (Bugfix and Stability release) Fixed compilation under HP-UX and Solaris Enabled compilation using HP ANSI C compiler Full list of issues fixed is available on https://cfengine.com/bugtracker/changelog_page.php 3.2.0 (Feature release) New bootstrap method with single-command bootstrapping: - cf-agent --bootstrap --policy-server 123.456.789.123 - Associated policy template files are added, partially maintained by CFEngine Bug fixes for file-editing, package versioning, and embedded database corruption (We recommend using TokyoCabinet instead of BerkeleyDB if building from source). Improved upgrade path for Nova. Patches for improved run-agent concurrency Reorganization of documentation and community resources 100% on regression test suite on 3 operating systems (Ubuntu, Debian, SuSE on x86-64 hardware) Support for multiple release environments package_policy update and addupdate now check if user-supplied version is larger than currently installed - updates only if so Help text of cf-report -r corrected - a list of key hashes is required, not ip addresses. New Emacs mode for CFEngine policy files (thanks to Ted Zlatanov!) Warnings are on edit_line changes can now give greater degree of information without spamming promise logs Class expressions parser accepts '||' as an alias for '|' again. Invalidation of package list cache on installation/removal of packages. New option cf-key -r to remove host key by IP or hostname. Added detection of network interfaces which belong to BSD jails. Improve robustness of multi-threaded code, in particular fix problems with spurious acces denials in server and losing of authentication rules after policy reload. cf-promises accepts option -b matching cf-agent, which causes it to do not complain about missing bundlesequence. New functions and(), not(), or() and concat() to ease use of ifvarclass() clause. Full list of issues fixed is available on https://cfengine.com/bugtracker/changelog_page.php 3.1.5 (Bugfix and Stability release) New class parser, '||' is no longer allowed in expressions (use '|'). Class setting in the promise types insert_lines, delete_lines, replace_patterns, field_edits, vars, classes is restored. suspiciousnames implemented. New function getvalues(). New functions parse{read,int,string}array to match read{read,int,string}array. Testsuite added to check for core functionality. Syslog prefix is fixed to say 'cf3' instead of 'community'. 3.1.4 (Bugfix and Stability release) Some urgent patches to 3.1.3. Class validation parse bug fixed. Global zone handling error for solaris fixed. Package architectures handled correctly (bug #456). Reading and writing of key name "root-.pub" eliminated (bug #442, #453). cf-serverd crash because of race condition on SERVER_KEYSEEN fixed. Lock purging to avoid remnant complexity explosion (bug #430). Some copyright notices added that got lost. 3.1.3 (Stability release) Major memory leaks in cf-monitord, cf-execd, cf-serverd fixed (bug #427). The daemons now show no growth even with very complex policies. cf-serverd crash due to race condition in DeleteScope() fixed (bug #406). Added 30 second timeout on recv() on Linux. package_noverify_returncode implemented (bug #256). A flexible mechanism for setting classes based on return codes of commands has been introduced. Allows for setting promise kept, repaired or failed based on any return codes. This is currently implemented for commands-promises, package-manager commands and transformer in files. In classes body, see attributes kept_returncodes, repaired_returncodes, failed_returncodes (bug #248, #329). New function ip2host - reverse DNS lookup (bug #146). 3.1.2 (Scalability/efficiency release) Big efficiency improvements by caching output from cf-promises. Can also be used for much more efficent policy deployment (only pull if changed). Caching state of ps command for greater efficiency. Reloaded for each bundle. Index class lookup improves efficiency of class evaluation for huge configurations. Fixed issue where certain promiser strings got corrupted. Minor memory access issues fixed. Iterator bug introduced in 3.1.0 fixed 3.1.1 (Bugfix release) Memory leaks in server tracked down and fixed. List expansion bug (one list items not executed) fixed. Security issue introduced by change of runcommand shell policy fixed. If users defined a runcommand for cf-runagent/cf-serverd communication, possible to execute commands. cf-key -s command for showing key hash/IP address identity pairs 3.1.0 Change in storage of public keys. Cfengine now hashes the public key and uses this as the keyname. Keys will be converted automatically. The old dynamic addresses lists are deprecated. Caching of dns and key information for greater server speed. Change in last-seen format reflects the public key usage. New package policy addupdate - installs package if not there and updates it otherwise. Support for package_changes => "bulk" in file repository as well. New special function readstringarrayidx, similar to readstringarray, but uses integer indeces. Very useful if first row elements are not good identifiers (e.g. contains spaces, non-unique, etc.). Change two log formats to use time() instead of date() - filechanges - total compliance Change from using md5 to sha256 as default digest for commercial version, community retains md5 for compat. Commands not returning 0 in commands-promises are flagged as repair_failed. Adjustable timeout on connect(). Defaults to 10 seconds, adjustable with default_timeout in agent control. Redesign of the knowledge map infrastructure. Now possible to use variables to call methods, e.g methods: "name $(list)" usebundle => $(list)("abc"); See reference manual notes Changes to normal ordering to optimize execution. Increased stability by always initializing Attribute and Promise structures. When running cf-promises in dry-run mode (-n), the user does not need to put binaries in WORKDIR/bin. For example, non-privileged users can verify root policies. Source control revision added in version string if run in verbose mode (e.g. "cf-promises -vV"). This needs some refining, uses revision of a header now. New semantics in return values of list functions. Null values are now allowed and there is no iteration over empty lists. The value "cf_null" is reserved for use as a null iterator. 3.0.5p1 Showing paths allowed/denied access to when cf-serverd is run in verbose mode. Bug in server fixed for dynamic addresses. File handle closure bugfix - too many open databases. Seg fault in mount files fix. Twin used in cf-execd without checking. Check_root set wrong directory permissions at source not destination. Error message degraded in body definition. Undefined body not warned as error. Various build enahncements. Package_list_update called only once per manager, and fixed crash. Version number bug in packages. 3.0.5 Encryption problems fixed - client key buffer was uninitialized. Classes-promisers are now automatically canonified when class strings are defined, to simplifying the use of variables in classes. New scalars sys.cf_version and sys.nova_version that hold Cfengine version information. Attribute package_delete_convention added, to allow customizable package name in delete command during update. package_list_update_ifelapsed limit added. Private variable $(firstrepo) is available in package_name_convention and package_delete_convention in order to expand the full path to a package, which is required by some managers. Some of the threading code is rewritten and made more robust. This includes synchronizing access to the lastseen database from the server. Bad initialization of BSD flags fixed Multiple variable expansion issues in control fixed for server and agent Allow ignore_missing_bundles to affect methods: bundles too Run agent trust dialogue fixed Bug in CPU monitoring, increasing time scale caused linear decay of CPU measurement. Bug in Setuid log storage, fix. Hooks added for new Nova virtualization promises. Multithreading mutex failed to collide during cfservd leading to dropped authentication under heavy load. 3.0.4 Class cancellation in promises to create better class feedback, allows emulation of switch/case semantics etc Value of SA measurement promises Special function getenv() which returns the contents of an environment variable (on all platforms). New function translatepath for generic Windows New function escape() to escape literals as regular expressions (like SQL) New function host2ip for caching IP address lookup New function regextract for setting variables with backreferences New variables for the components $(sys.cf_agent), $(sys.cf_know) etc pointing to the binaries. More robust integrated database implementation; closing all handles when receiving signals, self-healing on corruption. Package installation on localhost without a manager like yum completed, multiple repositories searched, and universal methods. Numerous bugfixes 3.0.3 sha256 .. new hashes in openssl included in syntax tree. End of line autocropping in readfile (hopefully intelligent) hashmatch function incorrectly implemented - old debugging code left behind. Fix. sys.crontab variable Unknown user is now interpretated as "same user", so that we give cfengine a chance to fix Unregistered addresses no longer report "(Non registered IP)", but return as the address itself when doing reverse lookups. 3.0.2 IMPORTANT: Change in normal ordering of editing. replace comes after insert lines Much testing and minor bug fixing Memory leaks fixed Many hooks added for Nova enterprise extensions. promise_output reports now placed in WORKDIR/reports directory Initialization correction and self-correx in monitord Many new body constraints added. Code readied for enterprise version Nova. -b option can override the bundlesequence (must not contain parameters yet) collapse_destination_dir option added to copy so that files can be aggregated from subdirectories into a single destination. Preparation for release: unit_accessed_before.cf x unit_accumulated_time.cf x unit_acl.cf x unit_acl_generic.cf x unit_ago.cf x unit_arrays.cf x unit_backreferences_files.cf x unit_badpromise.cf x unit_badtype.cf x unit_bsdflags.cf x unit_cf2_integration.cf x unit_changedbefore.cf x unit_change_detect.cf x unit_chdir.cf x unit_classes_global.cf x unit_classmatch.cf x unit_classvar_convergence.cf x unit_compare.cf x unit_controlclasses.cf x unit_control_expand.cf x unit_copy.cf x unit_copy_edit.cf x unit_copylinks.cf x unit_createdb.cf x unit_create_filedir.cf x unit_definitions.cf x unit_deletelines.cf x unit_disable_and_rotate_files.cf x unit_dollar.cf x unit_edit_column_files.cf x unit_edit_comment_lines.cf x unit_edit_deletenotmatch.cf x unit_edit_insert_lines.cf x unit_edit_insert_lines_silly.cf x unit_edit_replace_string.cf x unit_edit_sectioned_file.cf x unit_edit_setvar.cf x unit_edit_triggerclass.cf x unit-env.cf x unit_epimenides.cf x unit_exec_args.cf x unit_execd.cf x unit_exec_in_sequence.cf x unit_execresult.cf x unit_expand.cf x unit_failsafe.cf x unit_file_change_detection.cf x unit_fileexists.cf x unit_file_owner_list_template.cf x unit_fileperms.cf x unit_filesexist2.cf x unit_filesexist.cf x unit_getgid.cf x unit_getindices.cf x unit_getregistry.cf x unit_getuid.cf x unit_global_list_expansion_2.cf x unit_global_list_expansion.cf x unit_groupexists.cf x unit_hash.cf x unit_hashcomment.cf x unit_hashmatch.cf x unit_helloworld.cf x unit_hostrange.cf x unit_intarray.cf x unit_iprange.cf x unit_irange.cf x unit_isdir.cf x unit_islink.cf x unit_isnewerthan.cf x unit_isplain.cf x unit_isvariable.cf x unit_iteration.cf x unit_knowledge_txt.cf x unit_lastnode.cf x unit_ldap.cf x unit_linking.cf x unit_literal_server.cf x unit_locate_files_and_compress.cf x unit_log_private.cf x unit_loops.cf x unit_measurements.cf x unit_method.cf x unit_method_validate.cf x unit_module_exec_2.cf unit_module_exec.cf unit_mount_fs.cf x unit_neighbourhood_watch.cf x unit_null_config.cf x unit_occurrences.cf x unit_ordering.cf x unit_package_apt.cf x unit_package_hash.cf x unit_package_rpm.cf x unit_package_yum.cf x unit_package_zypper.cf x unit_parallel_exec.cf x unit_pathtype.cf x unit_pattern_and_edit.cf x unit_peers.cf x unit_postfix.cf x unit_process_kill.cf x unit_process_matching2.cf x unit_process_matching.cf x unit_process_signalling.cf x unit_readlist.cf x unit_readtcp.cf x unit_regarray.cf x unit_registry.cf x unit_regline.cf x unit_reglist.cf x unit_remove_deadlinks.cf x unit_rename.cf x unit_report_state.cf x unit_reporttofile.cf x unit_returnszero.cf x unit_select_mode.cf x unit_select_region.cf x unit_selectservers.cf x unit_select_size.cf x unit_server_copy_localhost.cf x unit_server_copy_remote.cf x unit_server_copy_purge.cf x unit_splitstring.cf x unit_sql.cf x unit_storage.cf x unit_strcmp.cf x unit_stringarray.cf x unit_syslog.cf x unit_template.cf x unit_tidy_all_files.cf x unit_user_edit.cf x unit_user_edit_method.cf x unit_userexists.cf x unit_varclass.cf x unit_vars.cf x unit_warnifline.cf x unit_webserver.cf x 3.0.1 First standalone release, independent of cfengine 2 Purge old definitions and check consistency. NB: changed search_mode to be a list of matching values Reporting rationalized in cf-promises with -r only to avoid leaving output files everywhere. Hooks added for upcoming commerical additions to cfengine. Added classify() and hostinnetgroup() functions Added additional change management options for change detection Package management added - generic mechanisms. Limits on backgrounding added to avoid resource contention during cfengine runs. Image type added to cf-know. New classes for quartly shifts: Morning,Afternoon,Evening,Night Bug fixes in editfiles - line insertion for multiple line objects Change the name of the variables and context from the monitord for better separation of data, and shorter names. sys -> mon average -> av, stddev -> dev canonical name for windows changed from "nt" to "windows", also version names added "vista","xp" etc.. License notices updated for dual license editions. 3.0.0 First release of cfengine 3. Known omissions: - no support for ACLs - no support for packages - no support for interface configuration These will be added in the next release. cfengine-3.2.4/configure.ac0000644000175000017500000007444611715232733012530 00000000000000dnl ########################################################################## dnl # dnl # BUILD CFENGINE dnl # dnl # Run ./autogen.sh to build configure script dnl # dnl ########################################################################## AC_PREREQ(2.59) AC_INIT AC_CONFIG_SRCDIR([src/cfpromises.c]) AC_CANONICAL_TARGET define([svnversion], [r]esyscmd([sh -c "svnversion --no-newline || echo exported | tr -d '\n'" 2>/dev/null]))dnl dnl dnl The version in the next line is the only one to set dnl dnl 'svnversion' need to be removed before release and added back after. dnl AM_INIT_AUTOMAKE(cfengine, 3.2.4) dnl remember to set version AM_MAINTAINER_MODE([enable]) AC_DEFINE(BUILD_YEAR, esyscmd([date +%Y | tr -d '\n']), "Software build year") m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) AC_CONFIG_HEADERS([src/conf.h]) dnl Libtool madness AC_CONFIG_MACRO_DIR([m4]) dnl dnl hide [s]include macros, so old aclocal (automake < 1.10) won't find them and dnl won't complain about something/something.m4 not found dnl m4_define(incstart,sinc) m4_define(incend,lude) dnl ###################################################################### dnl Use pthreads if available dnl ###################################################################### ACX_PTHREAD CC="$PTHREAD_CC" CFLAGS="$PTHREAD_CFLAGS $CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" dnl ###################################################################### dnl Checks for programs. dnl ###################################################################### AC_PROG_CC AC_EXEEXT # Use either new LT_INIT or old AC_DISABLE_STATIC/AC_PROG_LIBTOOL macros m4_ifdef([LT_INIT], [LT_INIT([disable-static])], [AC_DISABLE_STATIC AC_PROG_LIBTOOL]) AM_PROG_LEX AC_PROG_YACC AC_PROG_INSTALL AC_CONFIG_LIBOBJ_DIR(pub) AC_FUNC_GETLOADAVG AC_PATH_PROG(GETCONF, getconf, false, $PATH:$prefix/bin:/usr/bin:/usr/local/bin:/sw/bin) AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = "xyes") # # Add to the default list of places in CPPFLAGS to match LDFLAGS above # Don't add if cross-compiling (setting host), to avoid using native libs. # if test "x$cross_compiling" = "xno"; then for x in /usr/local/include /usr/local/gnu/include /opt/dce/include /sw/include /usr/pkg/include /usr/X11R7/include do if test -d "$x"; then y=`expr " $CPPFLAGS " : ".* -I$x "` if test $y -eq 0; then CPPFLAGS="$CPPFLAGS -I$x" fi fi done fi dnl ###################################################################### dnl Checks for libraries. dnl ###################################################################### AC_ARG_WITH(diagnostics, AS_HELP_STRING(--with-diagnostics, [enable test suite]),[], with_diagnostics=no) if test "x$with_diagnostics" != xno; then AC_DEFINE(BUILD_TESTSUITE, 1, [Build Test suite]) fi dnl Now check for database connectors AC_ARG_WITH([sql], [AS_HELP_STRING([--with-sql[[=PATH]]], [Enable SQL database connectors (deprecated, use --with[[out]]-postgresql and --with[[out]]-mysql instead)])],[with_postgresql=$with_sql; with_mysql=$with_sql],[]) dnl PostgreSQL AC_ARG_WITH([postgresql], [AS_HELP_STRING([--with-postgresql[[=PATH]]], [Enable PostgreSQL connector])], [], [with_postgresql=check]) if test "x$with_postgresql" != "xno"; then if test "x$with_postgresql" != xyes && test "x$with_postgresql" != xcheck; then PG_CONFIG=$with_postgresql/bin/pg_config else PG_CONFIG=pg_config fi # pg_config is only for native builds if test "x$cross_compiling" = "xno"; then if test x`which $PG_CONFIG` != x ; then CPPFLAGS="$CPPFLAGS -I`$PG_CONFIG --includedir`" fi fi CF3_WITH_LIBRARY(postgresql, [ AC_CHECK_LIB(pq, PQconnectdb, [], [if test "x$with_postgresql" != xcheck; then AC_MSG_ERROR(Cannot find PostgreSQL client library); fi]) AC_CHECK_HEADERS(libpq-fe.h, [], [if test "x$with_postgresql" != xcheck; then AC_MSG_ERROR(Cannot find PostgreSQL client library); fi]) ]) fi dnl MySQL AC_ARG_WITH([mysql], [AS_HELP_STRING([--with-mysql[[=PATH]]], [Enable MySQL connector])], [], [with_mysql=check]) if test "x$with_mysql" != "xno"; then if test "x$with_mysql" != xyes && test "x$with_mysql" != xcheck; then MYSQL_CONFIG=$with_mysql/bin/mysql_config else MYSQL_CONFIG=mysql_config fi # mysql_config is only for native builds if test "x$cross_compiling" = "xno"; then if test x`which $MYSQL_CONFIG` != x ; then CPPFLAGS="$CPPFLAGS `$MYSQL_CONFIG --include`" fi fi CF3_WITH_LIBRARY(mysql, [ AC_CHECK_LIB(mysqlclient, mysql_real_connect, [], [if test "x$with_mysql" != xcheck; then AC_MSG_ERROR(Cannot find MySQL client library); fi]) AC_CHECK_HEADERS(mysql.h, [], [if test "x$with_mysql" != xcheck; then AC_MSG_ERROR(Cannot find MySQL client library); fi]) ]) fi dnl Enterprise extensions m4_indir(incstart[]incend, [nova/options.m4]) AM_CONDITIONAL([HAVE_NOVA], [test "x$with_nova" != xno && test -d ${srcdir}/nova]) m4_indir(incstart[]incend, [constellation/options.m4]) AM_CONDITIONAL([HAVE_CONSTELLATION], [test "x$with_constellation" != xno && test -d ${srcdir}/constellation]) m4_indir(incstart[]incend, [galaxy/options.m4]) AM_CONDITIONAL([HAVE_GALAXY], [test "x$with_galaxy" != xno && test -d ${srcdir}/galaxy]) dnl Tokyo Cabinet AC_ARG_WITH([tokyocabinet], [AS_HELP_STRING([--with-tokyocabinet[[=PATH]]], [use Tokyo Cabinet to store runtime data])]) AS_IF([test -n "$with_tokyocabinet" && test "x$with_tokyocabinet" != "xno"], [WITH_TOKYO=1], [WITH_TOKYO=0]) if test $WITH_TOKYO = 1; then CF3_WITH_LIBRARY(tokyocabinet, [ AC_CHECK_LIB(tokyocabinet, tchdbnew, [], [AC_MSG_ERROR(Cannot find Tokyo Cabinet)]) AC_CHECK_HEADERS(tcutil.h, [], [AC_MSG_ERROR(Cannot find Tokyo Cabinet)]) AC_CHECK_HEADERS(tchdb.h, [], [AC_MSG_ERROR(Cannot find Tokyo Cabinet)]) AC_DEFINE(TCDB, 1, [Define if Tokyo Cabinet is available.]) ]) fi dnl SQLite 3 AC_ARG_WITH([sqlite3], [AS_HELP_STRING([--with-sqlite3[[=PATH]]], [use SQLite 3 to store runtime data (EXPERIMENTAL, BROKEN)])]) AS_IF([test "x$with_sqlite3" = "xyes"], [WITH_SQLITE3=1], [WITH_SQLITE3=0]) if test $WITH_SQLITE3 = 1; then AC_MSG_CHECKING(SQLite 3) AC_CHECK_LIB(sqlite3, sqlite3_open, [], [AC_MSG_ERROR(Cannot find SQLite 3)]) AC_CHECK_HEADERS(sqlite3.h) AC_DEFINE(SQLITE3, 1, [Define if SQLite 3 is available.]) fi dnl QDBM AC_ARG_WITH([qdbm], [AS_HELP_STRING([--with-qdbm[[=PATH]]], [use QDBM to store runtime data])]) AS_IF([test "x$with_qdbm" = "xyes"], [WITH_QDBM=1], [WITH_QDBM=0]) if test $WITH_QDBM = 1; then AC_MSG_CHECKING(for QDBM) AC_CHECK_LIB(qdbm,main, [], [AC_MSG_ERROR(Cannot find Quick Database Manager)]) AC_CHECK_HEADERS(depot.h) AC_DEFINE(QDB, 1, [Define if QDBM is available.]) fi dnl Berkeley DB. if test $WITH_QDBM = 0 -a $WITH_TOKYO = 0 -a $WITH_SQLITE3 = 0; then AC_ARG_WITH(berkeleydb, [ --with-berkeleydb[[=PATH]] directory where BerkeleyDB exists], BERKELEYDB_DIR=$with_berkeleydb, BERKELEYDB_DIR=default) AC_MSG_CHECKING(for BerkeleyDB location in $BERKELEYDB_DIR) if test "x$BERKELEYDB_DIR" = "xno" ; then AC_MSG_RESULT( ) AC_MSG_ERROR(This release of cfengine requires a version of BerkeleyDB 4.4 or later) else if test "x$BERKELEYDB_DIR" = "xdefault" ; then for v in BerkeleyDB.4.2 BerkeleyDB.4.3 BerkeleyDB.4.4 BerkeleyDB.4.5 BerkeleyDB.4.6 BerkeleyDB.4.7 BerkeleyDB.4.8; do for d in $prefix /opt /usr/local /usr/pkg /usr; do test -d "$d/$v" && BERKELEYDB_DIR="$d/$v" done done fi if test "x$BERKELEYDB_DIR" = "xdefault" ; then for d in $prefix /opt /usr/local /usr; do for v in db-4 db4 db3 db db40 db41 db42 db43 db44 db45 db46 db47 db48 db50 db51; do if test -f "$d/include/$v/db.h" ; then echo "Found header in $d/include/$v " test "x$d" != "x/usr" && BERKELEYDB_LDFLAGS="-L$d/lib/$v" BERKELEYDB_CFLAGS="-I$d/include/$v" late_LIBS=$LIBS # In RedHat 8, for instance, we have /usr/include/db4 # and libdb-4.0.a. Debian has /usr/lib/libdb-4.1.a, for # instance. Look for the appropriate library. if test $v = db4 -o $v = db40; then save_CFLAGS="$CFLAGS" save_LDFLAGS="$LDFLAGS" CFLAGS="$CFLAGS $BERKELEYDB_CFLAGS" LDFLAGS="$LDFLAGS $BERKELEYDB_LDFLAGS" AC_SEARCH_LIBS(db_create, [db-4 db4 db-4.8 db-4.7 db-4.6 db-4.5 db-4.4 db-4.3 db-4.2 db-4.1 db-4.0], [BERKELEYDB_LIBS=$ac_cv_search_db_create]) CFLAGS="$save_CFLAGS" LDFLAGS="$save_LDFLAGS" else BERKELEYDB_LIBS="-ldb" fi LIBS=$late_LIBS AC_MSG_RESULT($d) break fi done test "x$BERKELEYDB_LIBS" != "x" && break if test -f "$d/include/db.h"; then if test "x$d" != "x/usr"; then BERKELEYDB_LDFLAGS="-L$d/lib64 -L$d/lib" BERKELEYDB_CFLAGS="-I$d/include" fi BERKELEYDB_LIBS="-ldb" AC_MSG_RESULT($d) break fi done if test "x$BERKELEYDB_LIBS" = "x" ; then AC_MSG_ERROR(Cannot find BerkeleyDB) fi elif test -f "$BERKELEYDB_DIR/include/db.h";then case "$target_os" in solaris*) #If we are staticlly linking the BDB files, we do not want a #-R flag. If .so's are present, assume we are dynamic linking if test -n "`ls $BERKELEYDB_DIR/lib/*.so 2>/dev/null`" then BERKELEYDB_LDFLAGS="-L$BERKELEYDB_DIR/lib -R$BERKELEYDB_DIR/lib" else BERKELEYDB_LDFLAGS="-L$BERKELEYDB_DIR/lib" fi;; *) BERKELEYDB_LDFLAGS="-L$BERKELEYDB_DIR/lib";; esac BERKELEYDB_CFLAGS="-I$BERKELEYDB_DIR/include" BERKELEYDB_LIBS="-ldb" AC_MSG_RESULT($BERKELEYDB_DIR) elif test -d "$BERKELEYDB_DIR"; then BERKELEYDB_CFLAGS="-I$BERKELEYDB_DIR/include" for v in . db48 db47 db46 db45 db44 db43 db42 db41 db40 db4 db33 db32 db3 db; do if test -f "$BERKELEYDB_DIR/include/$v/db.h"; then BERKELEYDB_INCLUDEDIR="$BERKELEYDB_DIR/include/$v" BERKELEYDB_CFLAGS="-I$BERKELEYDB_INCLUDEDIR" break fi done if test -f "$BERKELEYDB_INCLUDEDIR/db.h"; then BERKELEYDB_LIBS="-ldb" for v in db-4.8 db48 db-4.7 db4.7 db47 db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44; do if test -f "$BERKELEYDB_DIR/lib/lib$v.so"; then BERKELEYDB_LIBS="-l$v" break fi if test -f "$BERKELEYDB_DIR/lib64/lib$v.so"; then BERKELEYDB_LIBS="-l$v" break fi done case "$target_os" in solaris*) #If we are staticlly linking the BDB files, we do not want a #-R flag. If .so's are present, assume we are dynamic linking if test -n "`ls $BERKELEYDB_DIR/lib/*.so 2>/dev/null`" then BERKELEYDB_LDFLAGS="-L$BERKELEYDB_DIR/lib -R$BERKELEYDB_DIR/lib" else BERKELEYDB_LDFLAGS="-L$BERKELEYDB_DIR/lib" fi;; *) BERKELEYDB_LDFLAGS="-L$BERKELEYDB_DIR/lib";; esac AC_MSG_RESULT($BERKELEYDB_DIR) else AC_MSG_ERROR(Cannot find BerkeleyDB) fi else AC_MSG_ERROR(Cannot find BerkeleyDB) fi AC_DEFINE(USE_BERKELEYDB, 1, [Define if BerkeleyDB is available.]) BERKELEYDB_SAVE_LDFLAGS=$LDFLAGS BERKELEYDB_SAVE_CPPFLAGS=$CPPFLAGS BERKELEYDB_SAVE_LIBS=$LIBS LDFLAGS="$LDFLAGS $BERKELEYDB_LDFLAGS" CPPFLAGS="$CFLAGS $BERKELEYDB_CFLAGS" LIBS="$LIBS $BERKELEYDB_LIBS" AC_MSG_CHECKING(for Berkeley DB API) AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ #include #if DB_VERSION_MAJOR < 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 1) #Ancient Berkeley DB version #endif ]])],[AC_MSG_RESULT(OK)],[AC_DEFINE(CF_OLD_DB,1,Define if old Berkeley API) ],[]) AC_CHECK_LIB(db, db_create) LDFLAGS=$BERKELEYDB_SAVE_LDFLAGS CPPFLAGS=$BERKELEYDB_SAVE_CPPFLAGS LIBS=$BERKELEYDB_SAVE_LIBS fi AC_SUBST(BERKELEYDB_LDFLAGS) AC_SUBST(BERKELEYDB_CFLAGS) AC_SUBST(BERKELEYDB_LIBS) fi dnl OpenSSL AC_ARG_WITH(openssl, [AS_HELP_STRING([--with-openssl[[=PATH]]], [Specify OpenSSL path])], [], [with_openssl=yes]) if test x"$with_openssl" = xno ; then AC_MSG_ERROR([This release of CFEngine requires OpenSSL >= 0.9.7]) fi CF3_WITH_LIBRARY(openssl, [ AC_CHECK_LIB(crypto, RSA_generate_key, [], [AC_MSG_ERROR(Cannot find OpenSSL)]) AC_CHECK_HEADERS([openssl/opensslv.h], [], [AC_MSG_ERROR(Cannot find OpenSSL)]) AC_MSG_CHECKING(for OpenSSL version) AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ #include #if OPENSSL_VERSION_NUMBER < 0x0090602fL #This OpenSSL is too old #endif ]])],[AC_MSG_RESULT(OK)],[AC_MSG_ERROR(This release of CFEngine requires OpenSSL >= 0.9.7)]) ]) dnl PCRE AC_ARG_WITH([pcre], [AS_HELP_STRING([--with-pcre[[=PATH]]], [Specify PCRE path])], [], [with_pcre=yes]) if test "x$with_pcre" = "xno"; then AC_MSG_ERROR([PCRE is required]) fi CF3_WITH_LIBRARY(pcre, [ AC_CHECK_LIB(pcre, pcre_exec, [], [AC_MSG_ERROR(Cannot find PCRE)]) AC_CHECK_HEADERS([pcre.h pcre/pcre.h], [break], [AC_MSG_ERROR(Cannot find PCRE)]) ]) dnl dnl ###################################################################### dnl Checks for header files. dnl ###################################################################### AC_CHECK_HEADERS(unistd.h stdlib.h sys/loadavg.h) AC_CHECK_HEADERS(sys/param.h) # sys/param.h is required for sys/mount.h on OpenBSD AC_CHECK_HEADERS(sys/mount.h, [], [], [AC_INCLUDES_DEFAULT #ifdef HAVE_SYS_PARAM_H # include #endif ]) AC_CHECK_HEADERS(utime.h) AC_CHECK_HEADERS(time.h) AC_CHECK_HEADERS(sys/time.h) AC_CHECK_HEADERS(malloc.h sys/malloc.h) AC_CHECK_HEADERS(vfs.h) AC_CHECK_HEADERS(sys/vfs.h) AC_CHECK_HEADERS(sys/sockio.h) AC_CHECK_HEADERS(sys/statvfs.h) AC_CHECK_HEADERS(sys/statfs.h) AC_CHECK_HEADERS(fcntl.h) AC_CHECK_HEADERS(sys/filesys.h) AC_CHECK_HEADERS(dustat.h) AC_CHECK_HEADERS(sys/systeminfo.h) AC_CHECK_HEADERS(sys/acl.h winsock2.h) AC_CHECK_HEADERS(zone.h) AC_CHECK_HEADERS(sys/uio.h) AC_HEADER_STDC AC_HEADER_TIME AC_HEADER_SYS_WAIT AC_HEADER_DIRENT AC_HEADER_STDBOOL dnl ###################################################################### dnl Checks for data types dnl ###################################################################### AC_TYPE_MODE_T AC_TYPE_SIZE_T AC_TYPE_UID_T AC_TYPE_PID_T AC_CHECK_TYPES(clockid_t) dnl ###################################################################### dnl Checks for typedefs, structures, and compiler characteristics. dnl ###################################################################### AC_C_CONST AC_SYS_LARGEFILE AC_TYPE_OFF_T # # AC_SYS_LARGEFILE correctly figures out necessary macros for large files, but # on AIX there is a gotcha: # # Code generated by flex #includes at the beginning of the file, which # picks up 32-bit wide off_t. Then it #includes which provides LFS # macros, and finally it includes another system header, now with 64-bit wide # off_t, which causes a conflict. # if test "x$ac_cv_sys_large_files" = x1; then CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=1" fi dnl ###################################################################### dnl Check for libraries dnl ###################################################################### AC_CHECK_LIB(m, sqrt) AC_CHECK_LIB(rt, clock_gettime) dnl ###################################################################### dnl Check for special functions dnl ###################################################################### AC_CHECK_DECLS(clock_gettime, [], [], [[#include ]]) AC_REPLACE_FUNCS(clock_gettime) AC_CHECK_DECLS(unsetenv) AC_REPLACE_FUNCS(unsetenv) AC_CHECK_DECLS(strnlen) AC_REPLACE_FUNCS(strnlen) AC_CHECK_DECLS(strndup) AC_REPLACE_FUNCS(strndup) AC_CHECK_DECLS(setlinebuf) AC_REPLACE_FUNCS(setlinebuf) AC_CHECK_DECLS(strlcat) AC_REPLACE_FUNCS(strlcat) AC_CHECK_DECLS(strlcpy) AC_REPLACE_FUNCS(strlcpy) AC_CHECK_DECLS(realpath) AC_CHECK_FUNCS(realpath) AC_CHECK_DECLS(round, [], [], [[#include ]]) AC_REPLACE_FUNCS(round) AC_CHECK_DECLS(strdup) AC_REPLACE_FUNCS(strdup) AC_CHECK_DECLS(nanosleep) AC_REPLACE_FUNCS(nanosleep) AC_CHECK_FUNCS(getcwd getnetgrent waitpid seteuid setegid setreuid setregid) AC_CHECK_FUNCS(uname gethostname chflags) AC_CHECK_FUNCS(strstr strsep putenv drand48 srand48 getaddrinfo) AC_CHECK_FUNCS(bcopy mkfifo statfs statvfs door) AC_CHECK_FUNCS(sysinfo setsid strrchr strerror snprintf sysconf) AC_CHECK_FUNCS(getzoneid getzonenamebyid) AC_CHECK_FUNCS(fpathconf) dnl dirfd might be a function or a macro AC_CHECK_DECLS(dirfd, [], [], [AC_INCLUDES_DEFAULT #ifdef HAVE_DIRENT_H # include #endif ]) AC_CHECK_FUNCS(dirfd, [], [ AC_MSG_CHECKING([for dirfd macro]) AC_EGREP_CPP([dirfd_found], AC_INCLUDES_DEFAULT [#ifdef HAVE_DIRENT_H # include #endif #ifdef dirfd dirfd_found #endif ], [AC_MSG_RESULT(yes) DIRFD_MACRO_FOUND=1], [AC_MSG_RESULT(no)]) if test x$DIRFD_MACRO_FOUND = x; then AC_LIBOBJ([dirfd]) fi]) AC_CHECK_FUNCS(jail_get) dnl dnl Various functions dnl AC_CHECK_FUNC(door_create,door) AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt)) AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent)) AC_CHECK_FUNC(getaddrinfo, , AC_CHECK_LIB(socket, getaddrinfo)) AC_SEARCH_LIBS(socket, socket, , [AC_CHECK_LIB(nsl, socket, LIBS="$LIBS -lsocket -lnsl", , -lsocket)]) AC_CHECK_FUNC(lchown, AC_DEFINE(HAVE_LCHOWN, [], [Whether to use lchown(3) to change ownerships])) AC_CHECK_LIB(pthread,main) AC_CHECK_FUNC(pthread_attr_setstacksize, AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE, [], [Whether the thread library has setstacksize]), AC_CHECK_LIB(pthread, pthread_create)) AC_CHECK_FUNC(pthread_sigmask, AC_DEFINE(HAVE_PTHREAD_SIGMASK, [], [Whether the thread library has setmask]), AC_CHECK_LIB(pthread, pthread_create)) if test "$ac_cv_lib_pthread_main" = "yes"; then AC_CHECK_HEADERS(pthread.h) AC_CHECK_HEADERS(sched.h) fi # # Temporarily force C macros to enable threading in CFEngine if pthreads were # found by ACX_PTHREAD, and errorneously disabled by another pthread-related # checks. # if test "x$acx_pthread_ok" = "xyes"; then AC_DEFINE(HAVE_PTHREAD_H) AC_DEFINE(HAVE_LIBPTHREAD) fi dnl ###################################################################### dnl Check for sa_len in struct sockaddr dnl ###################################################################### AC_CHECK_MEMBERS([struct sockaddr.sa_len], , , [ #include #include ]) dnl ####################################################################### dnl Newer BSD systems don't have a compatible rtentry - use ortentry dnl ####################################################################### rtry=none AC_MSG_CHECKING(for either struct rtentry or struct ortentry) AC_EGREP_HEADER(rtentry, net/route.h, rtry=rtentry) if test "$rtry" = rtentry; then AC_DEFINE(HAVE_RTENTRY, 1, [Do we have any route entry structure?]) fi AC_EGREP_HEADER(ortentry, net/route.h, rtry=ortentry) if test "$rtry" = ortentry; then AC_DEFINE(HAVE_ORTENTRY, 1) fi AC_MSG_RESULT([$rtry]) dnl ###################################################################### dnl Give the chance to enable SELINUX dnl ###################################################################### AC_ARG_ENABLE([selinux], [AS_HELP_STRING([--enable-selinux], [Enable SELinux support])]) AS_IF([test "x$enable_selinux" = "xyes"], [ AC_DEFINE(WITH_SELINUX, 1, [Define if you want to use SELinux]) LIB_SELINUX="-lselinux" LIBS="$LIBS $LIB_SELINUX" AC_SUBST(LIB_SELINUX) ]) dnl ###################################################################### dnl Collect all the options dnl ###################################################################### CPPFLAGS="$CPPFLAGS $POSTGRESQL_CPPFLAGS $MYSQL_CPPFLAGS $TOKYOCABINET_CPPFLAGS $PCRE_CPPFLAGS $BERKELEYDB_CPPFLAGS $OPENSSL_CPPFLAGS $MONGO_CPPFLAGS $LDAP_CPPFLAGS $LIBVIRT_CPPFLAGS" CFLAGS="$CFLAGS $POSTGRESQL_CFLAGS $MYSQL_CFLAGS $TOKYOCABINET_CFLAGS $PCRE_CFLAGS $BERKELEYDB_CFLAGS $OPENSSL_CFLAGS $MONGO_CFLAGS $LDAP_CFLAGS $LIBVIRT_CFLAGS" LDFLAGS="$LDFLAGS $POSTGRESQL_LDFLAGS $MYSQL_LDFLAGS $TOKYOCABINET_LDFLAGS $PCRE_LDFLAGS $BERKELEYDB_LDFLAGS $OPENSSL_LDFLAGS $MONGO_LDFLAGS $LDAP_LDFLAGS $LIBVIRT_LDFLAGS" LIBS="$LIBS $POSTGRESQL_LIBS $MYSQL_LIBS $TOKYOCABINET_LIBS $PCRE_LIBS $BERKELEYDB_LIBS $OPENSSL_LIBS $MONGO_LIBS $LDAP_LIBS $LIBVIRT_LIBS" dnl ###################################################################### dnl OS specific stuff dnl ###################################################################### dnl To ensure conf.h is picked up via VPATH if test "$srcdir" != "."; then CPPFLAGS="$CPPFLAGS -I`pwd`/src" fi case "$target_os" in sunos3*) AC_DEFINE(SUN3, [], [SunOS 3.x build]) ;; sunos4*) AC_DEFINE(SUN4, [], [SunOS 4.x build]) ;; solaris2.4*) AC_DEFINE(SOLARIS) AC_DEFINE(HAVE_SYS_ACL_H,) CPPFLAGS="-w $CPPFLAGS" LIBS="$LIBS -lelf" ;; solaris2.5*) AC_DEFINE(SOLARIS) AC_DEFINE(_POSIX_C_SOURCE, [], [SVR4 header stuff]) AC_DEFINE(__EXTENSIONS__, [], [SVR4 header stuff]) LIBS="$LIBS -lelf -lsec" ;; solaris2*) AC_DEFINE(SOLARIS, [], [Solaris build]) AC_DEFINE(__BIT_TYPES_DEFINED__, [], [Solaris 2.6-related stuff]) # avoid conflict with db.h AC_PREPROC_IFELSE([ AC_LANG_PROGRAM([[ #define _POSIX_C_SOURCE 1 #include ]], [])], [AC_DEFINE(_POSIX_C_SOURCE)], [AC_DEFINE(_POSIX_C_SOURCE, 200112loL)]) AC_DEFINE(__EXTENSIONS__) LIBS="$LIBS -lelf -lsec" ;; solaris*) AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Use POSIX pthread semantics on Solaris]) ;; ultrix*) AC_DEFINE(ULTRIX, [], [Ultrix build]) ;; hpux*|hp-ux*) AC_DEFINE(HPuUX, [], [HP/UX build]) if test "$GCC" != "yes"; then AC_DEFINE(REGEX_MALLOC, [], [Whether to use the local regex functions]) fi LIBS="$LIBS -lc" AC_CHECK_LIB(PW, main) ;; aix*) AC_DEFINE(AIX, [], [AIX build]) CPPFLAGS="$CPPFLAGS -w" AC_CHECK_LIB(pthreads, main) AC_CHECK_HEADER(pthreads.h) ;; osf*) AC_DEFINE(OSF, [], [OSF/1 build]) if test "$GCC" = yes; then AC_MSG_WARN([pthreads may not work with GCC under Tru64]) AC_MSG_WARN([If you get build errors mentioning PTHREADDEFAULTS etc.,]) AC_MSG_WARN([re-configure with CC=cc.]) fi ;; irix6*) # rtentry is detected OK on a 6.5.19 system. AC_DEFINE(HAVE_ORTENTRY, 1, [The old route entry structure in newer BSDs]) # Have to hack this for 6.* owing to bug AC_DEFINE(IRIX, [], [IRIX build]) CFLAGS="$CFLAGS -w" ;; irix4*) AC_DEFINE(IRIX) CFLAGS="$CFLAGS -w" LIBS="$LIBS -lsun" ;; irix*) AC_DEFINE(IRIX) CFLAGS="$CFLAGS -w" ;; linux*) AC_DEFINE(LINUX, [], [Linux build]) AC_CHECK_LIB(nss_nis, yp_get_default_domain) AC_CHECK_LIB(acl,main) AC_CHECK_HEADERS(acl.h sys/acl.h acl/libacl.h) ;; freebsd*|dragonfly*) AC_DEFINE(FREEBSD, [], [FreeBSD build]) CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE -DBUILDTIN_GCC_THREAD" AC_CHECK_HEADERS(pthread.h) ;; netbsd*) AC_DEFINE(NETBSD, [], [NetBSD build]) ;; newsos*) AC_DEFINE(NEWS_OS, [], [NewsOS build]) ;; bsd/os*) AC_DEFINE(BSDOS, [], [BSD/OS build]) ;; bsd*) AC_DEFINE(BSD43, [], [4.3BSD build]) ;; aos*) AC_DEFINE(AOS, [], [AOS build]) ;; nextstep*) AC_DEFINE(NEXTSTEP, [], [NeXTSTEP build]) ;; unicos*) AC_DEFINE(CFCRAY, [], [Cray build]) ;; cray*) AC_DEFINE(CFCRAY) ;; qnx*) AC_DEFINE(CFQNX, [], [QNX build]) ;; openbsd*|obsd*) AC_DEFINE(OPENBSD, [], [OpenBSD build]) ;; gnu*) AC_DEFINE(CFGNU, [], [GNU build]) ;; sysv4.2MP|unix_sv*) AC_DEFINE(UNIXWARE, [], [Unixware build]) AC_CHECK_LIB(thread,main) dnl POSIX threads, weird setup if test "$ac_cv_lib_thread_main" = "yes"; then AC_CHECK_HEADERS(thread.h) fi ;; cygwin*) AC_DEFINE(CFCYG, 1, [Cygwin NT build]) AC_DEFINE(NT, [], [NT build]) ;; mingw*) AC_DEFINE(MINGW, 1, [Native NT build]) AC_DEFINE(NT) LIBS="$LIBS -liphlpapi -lws2_32 -lpsapi -lole32 -loleaut32 -luuid" ;; sco*) AC_DEFINE(SCO, [], [SCO build]) ;; darwin*) AC_DEFINE(DARWIN, [], [Darwin build]) LDFLAGS="-Xlinker -m $LDFLAGS" ;; *) AC_MSG_ERROR(Unknown system type $target_os) ;; esac # # OS kernels conditionals. Don't use those unless it is really needed (if code # depends on the *kernel* feature, and even then -- some kernel features are # shared by different kernels). # # Good example: use LINUX to select code which uses inotify and netlink sockets. # Bad example: use LINUX to select code which parses output of coreutils' ps(1). # AM_CONDITIONAL([LINUX], [test -n "`echo ${target_os} | grep linux`"]) AM_CONDITIONAL([SOLARIS], [test -n "`(echo ${target_os} | egrep 'solaris|sunos')`"]) AM_CONDITIONAL([NT], [test -n "`(echo ${target_os} | egrep 'mingw|cygwin')`"]) AM_CONDITIONAL([AIX], [test -n "`(echo ${target_os} | grep aix)`"]) AM_CONDITIONAL([HPUX], [test -n "`(echo ${target_os} | egrep 'hpux|hp-ux')`"]) AM_CONDITIONAL([FREEBSD], [test -n "`(echo ${target_os} | grep freebsd)`"]) AM_CONDITIONAL([NETBSD], [test -n "`(echo ${target_os} | grep netbsd)`"]) AM_CONDITIONAL([XNU], [test -n "`(echo ${target_os} | grep darwin)`"]) dnl ##################################################################### dnl Configure LOCKDIR and LOGDIR dnl ##################################################################### AC_ARG_WITH(workdir, [ --with-workdir=WORKDIR default internal for trusted cache ], [ if test x$withval != x ; then WORKDIR=$withval else WORKDIR=/var/cfengine fi AC_DEFINE_UNQUOTED(WORKDIR, "${WORKDIR}", [lock and log directories]) AC_SUBST(workdir, "${WORKDIR}") ], [ case "$target_os" in mingw*) WORKDIR=$(cmd /c "echo %PROGRAMFILES%\\Cfengine" | sed 's/\\/\\\\/g') ;; *) WORKDIR=/var/cfengine ;; esac AC_DEFINE_UNQUOTED(WORKDIR, "${WORKDIR}") ] ) dnl ##################################################################### dnl Fix for lex/flex dnl ##################################################################### AC_MSG_CHECKING(for 8-bit support in Flex) if test "$LEX" = "flex"; then EIGHTBIT="\200-\377" AC_SUBST(EIGHTBIT) AC_MSG_RESULT(8-bit support added) NOWRAP="%option noyywrap" else AC_MSG_RESULT(no 8-bit support) NOWRAP="" fi AC_SUBST(NOWRAP) dnl #################################################################### dnl Set GCC CFLAGS only if using GCC. dnl #################################################################### AC_MSG_CHECKING(for HP-UX aC) AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ #if defined __HP_cc #This is HP-UX ANSI C #endif ]])], [AC_MSG_RESULT(no)],[AC_MSG_RESULT(yes) CFLAGS="$CFLAGS -Agcc" CPPFLAGS="$CPPFLAGS -Agcc" HP_UX_AC=yes]) AC_MSG_CHECKING(for GCC specific compile flags) if test x"$GCC" = "xyes" && test x"$HP_UX_AC" != x"yes"; then dnl # -Wformat - to be considered GCC_CFLAG="-g -Wreturn-type -Wmissing-prototypes" case "$CFLAGS" in "-O"*|*" -O"*) GCC_CFLAG="$GCC_CFLAG -Wuninitialized" ;; esac AC_MSG_RESULT(yes) AC_SUBST(GCC_CFLAG) else GCC_CFLAG="" AC_MSG_RESULT(no) AC_SUBST(GCC_CFLAG) fi dnl ##################################################################### dnl Hostname and Version stuff dnl ##################################################################### AC_PATH_PROG(HOSTNAME, hostname, "", $PATH) AC_DEFINE_UNQUOTED(AUTOCONF_HOSTNAME, "`$HOSTNAME`", [Special Cfengine symbol]) AC_DEFINE_UNQUOTED(AUTOCONF_SYSNAME, "$target_os", [Speial Cfengine symbol]) dnl ##################################################################### dnl xen cpuid-based hvm detection dnl ##################################################################### AC_MSG_CHECKING(for Xen cpuid-based HVM detection) if test x"$GCC" = "xyes"; then case $host_cpu in i[[3456]]86*|x86_64*) AC_DEFINE(XEN_CPUID_SUPPORT, 1, [Define if XEN cpuid-based HVM detection is available.]) AC_MSG_RESULT(yes) ;; *) AC_MSG_RESULT(no) ;; esac else AC_MSG_RESULT(no) fi dnl dnl dnl dnl ###################################################################### dnl Summarize dnl ###################################################################### AC_MSG_RESULT( ) AC_MSG_RESULT( Summary of options...) AC_MSG_RESULT([-> PCRE: $PCRE_PATH]) if test "x$ac_cv_lib_mysqlclient_mysql_real_connect" != "xno"; then AC_MSG_RESULT([-> MySQL connector: $MYSQL_PATH]) else AC_MSG_RESULT([-> MySQL connector: disabled]) fi if test "x$ac_cv_lib_pq_PQconnectdb" = "xyes"; then AC_MSG_RESULT([-> PostgreSQL connector: $POSTGRESQL_PATH]) else AC_MSG_RESULT([-> PostgreSQL connector: disabled]) fi if test $WITH_TOKYO = 1; then AC_MSG_RESULT([-> DB: Tokyo Cabinet: $TOKYOCABINET_PATH]) elif test $WITH_QDBM = 1; then AC_MSG_RESULT([-> DB: QDBM]) elif test $WITH_SQLITE3 = 1; then AC_MSG_RESULT([-> DB: SQLite 3 (EXPERIMENTAL, BROKEN)]) else AC_MSG_RESULT([-> DB: Berkeley DB: $BERKELEYDB_DIR]) fi m4_indir(incstart[]incend, [nova/config.m4]) m4_indir(incstart[]incend, [constellation/config.m4]) m4_indir(incstart[]incend, [galaxy/config.m4]) AC_MSG_RESULT( ) dnl ###################################################################### dnl Now make the Makefiles dnl ###################################################################### AC_CONFIG_FILES([Makefile pub/Makefile src/Makefile src/cf3lex.l docs/Makefile examples/Makefile examples/example_config/Makefile masterfiles/Makefile]) m4_indir(incstart[]incend, [nova/output.m4]) m4_indir(incstart[]incend, [constellation/output.m4]) m4_indir(incstart[]incend, [galaxy/output.m4]) AC_OUTPUT AC_MSG_RESULT(DONE: Configuration done. Run make/gmake to build cfengine.) cfengine-3.2.4/AUTHORS0000644000175000017500000001216211707771421011300 00000000000000 The cfengine 3 design and code is by Cfengine AS and all rights are reserved. In order to offer commericial support of cfengine to customers it is important for Cfengine AS to have an uncomplicated ownership of rights to cfengine 3 code in future products. For that reason we will require that substantial code contrbutions (contributions of sufficient size to warrant copyright) be accompanied by a signed transfer of rights form to cfengine AS. Such a transfer will not take away any of your freedoms under the GNU public licence, but will guarantee that community contributions can be included in cfengine's commerical future, without the need to split cfengine into multiple versions i.e. this allows cfengine AS to make money on commerical versions of cfengine thus supporting future in-house development. ======================================================================== Cfengine AS Contributor statement The terms stated below apply to your contribution of computer code and other material to software or projects owned or managed by Cfengine AS (“project”), and set out the intellectual property rights in the contributed material you transfer to Cfengine. If this contribution is on behalf of a company, “you” will also mean the company you identify below. 1. "Material" and "contribution" shall mean any source code, object code, patch, tool, sample, graphic, specification, manual, documentation, or any other code or other material posted or submitted by you to the project or us. 2. Regarding any worldwide copyrights, or copyright applications and registrations, in your contribution: * You hereby assign to us joint ownership, and to the extent that such assignment is or becomes invalid, ineffective or unenforceable, you hereby grant to us a perpetual, irrevocable, non-exclusive, worldwide, no-charge, royalty-free, unrestricted license to exercise all rights under those copyrights. This includes, at our option, the right to sublicense these same rights to third parties through multiple levels of sublicensees or other licensing arrangements; * You agree that each of us can do all things in relation to your contribution as if each of us were the sole right holder, and if one of us makes a derivative work of your contribution, the one who makes the derivative work (or has it made) will be the sole owner of that derivative work, hereunder make, have made, use, sell, offer to sell, import, and otherwise transfer your contribution in whole or in part; * You agree that neither of us has any duty to consult with, obtain the consent of, pay or render an accounting to the other for any use or distribution of the material. 3. If you own or may license any patent without payment to any third party, you hereby grant us a perpetual, irrevocable, non-exclusive, worldwide, no-charge, royalty-free license to use, transfer and otherwise control such material, to the same extent as described above for copyright. 4. You keep all right, title, and interest in your contribution, exempted only as stated above. The rights that you grant to us under these terms are effective on the date you first submitted a contribution to us, even if your submission took place before the date you sign these terms. Any contribution we make available under any license will also be made available under a suitable FSF (Free Software Foundation) or OSI (Open Source Initiative) approved license. 5. With respect to your contribution, you represent that: * it is an original work and that you can legally grant the rights set out in these terms; * it does not to the best of your knowledge violate any third party's copyrights, trademarks, patents, or other intellectual property rights; and * you are authorized to sign this contract on behalf of your company (if identified below). 6. These terms will be governed by the laws of Norway. Legal venue is Oslo, Norway. If available, please list your cfengine.com username(s) and the name of the project(s) (or project website(s)) for which you would like to contribute materials. Your username: Project name (or project website) and nature of contribution: ______________ _____________________________________________________________ ______________ _____________________________________________________________ ______________ _____________________________________________________________ Your contact information (Please print clearly): Your name: _____________________________________________________________________ Your company's name (if relevant): _____________________________________________ Physical mail address: _________________________________________________________ Phone, fax and email address: __________________________________________________ ________________________________________________________________________________ Signature: _____________________________________________________________________ Date: __________________________________________________________________________ To send these terms to us, scan and email the signed agreement as PDF to contact@cfengine.com cfengine-3.2.4/pub/0000755000175000017500000000000011715233355011072 500000000000000cfengine-3.2.4/pub/unsetenv.c0000644000175000017500000000445711707771422013042 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifdef HAVE_CONFIG_H #include "../src/conf.h" #endif #include #include #include #include #include #if !HAVE_DECL_UNSETENV int unsetenv(const char *name); #endif /* Under MinGW putenv('var=') will remove variable from environment */ #ifdef __MINGW32__ int unsetenv(const char *name) { int retval; char *buf; if (name == NULL || *name == 0 || strchr(name, '=') != 0) { errno = EINVAL; return -1; } buf = malloc(strlen(name) + 2); if (!buf) { errno = ENOMEM; return -1; } sprintf(buf, "%s=", name); retval = putenv(buf); free(buf); return retval; } #endif /* * Under SVR4 (Solaris 8/9, HP-UX 11.11) we need to manually update 'environ' * variable */ #if defined(__sun) || defined (__hpux) /* * Note: this function will leak memory as we don't know how to free data * previously used by environment variables. */ extern char **environ; int unsetenv(const char *name) { char **c; int len; if (name == NULL || *name == 0 || strchr(name, '=') != 0) { errno = EINVAL; return -1; } len = strlen(name); /* Find variable */ for (c = environ; *c; ++c) { if (strncmp(name, *c, len) == 0 && ((*c)[len] == '=' || (*c)[len] == 0)) { break; } } /* Shift remaining values */ for(; *c; ++c) { *c = *(c+1); } return 0; } #endif cfengine-3.2.4/pub/strlcat.c0000644000175000017500000000331311707771422012635 00000000000000/* $OpenBSD: strlcat.c,v 1.12 2005/03/30 20:13:52 otto Exp $ */ /* * Copyright (c) 1998 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include size_t strlcat(char *dst, const char *src, size_t siz); /* * Appends src to string dst of size siz (unlike strncat, siz is the * full size of dst, not space left). At most siz-1 characters * will be copied. Always NUL terminates (unless siz <= strlen(dst)). * Returns strlen(src) + MIN(siz, strlen(initial dst)). * If retval >= siz, truncation occurred. */ size_t strlcat(char *dst, const char *src, size_t siz) { char *d = dst; const char *s = src; size_t n = siz; size_t dlen; /* Find the end of dst and adjust bytes left but don't go past end */ while (n-- != 0 && *d != '\0') d++; dlen = d - dst; n = siz - dlen; if (n == 0) return(dlen + strlen(s)); while (*s != '\0') { if (n != 1) { *d++ = *s; n--; } s++; } *d = '\0'; return(dlen + (s - src)); /* count does not include NUL */ } cfengine-3.2.4/pub/getopt.h0000644000175000017500000001106011707771422012466 00000000000000/* Declarations for getopt. Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _GETOPT_H #define _GETOPT_H 1 #define __GETOPT_H__ 1 #ifdef __cplusplus extern "C" { #endif /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns EOF, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { #if defined (__STDC__) && __STDC__ const char *name; #else char *name; #endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ #define no_argument 0 #define required_argument 1 #define optional_argument 2 #if defined (__STDC__) && __STDC__ #ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int argc, char *const *argv, const char *shortopts); #else /* not __GNU_LIBRARY__ */ extern int getopt (); #endif /* __GNU_LIBRARY__ */ extern int getopt_long (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); extern int getopt_long_only (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind, int long_only); #else /* not __STDC__ */ extern int getopt (); extern int getopt_long (); extern int getopt_long_only (); extern int _getopt_internal (); #endif /* __STDC__ */ #ifdef __cplusplus } #endif #endif /* _GETOPT_H */ cfengine-3.2.4/pub/strndup.c0000644000175000017500000000230111707771422012654 00000000000000/* $OpenBSD: strndup.c,v 1.1 2010/05/18 22:24:55 tedu Exp $ */ /* * Copyright (c) 2010 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include char *strndup(const char *str, size_t n); char * strndup(const char *str, size_t maxlen) { char *copy; size_t len; len = strnlen(str, maxlen); copy = malloc(len + 1); if (copy != NULL) { (void)memcpy(copy, str, len); copy[len] = '\0'; } return copy; } cfengine-3.2.4/pub/setlinebuf.c0000644000175000017500000000226711707771422013330 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifdef HAVE_CONFIG_H #include "../src/conf.h" #endif #include #if !HAVE_DECL_SETLINEBUF void setlinebuf(FILE *stream); #endif void setlinebuf(FILE *stream) { setvbuf(stream, (char *) NULL, _IOLBF, 0); } cfengine-3.2.4/pub/Makefile.am0000644000175000017500000000140111715232734013042 00000000000000 AM_CFLAGS = @CFLAGS@ @GCC_CFLAG@ -fPIC -DPIC AM_CPPFLAGS = $(NOVA_CFLAGS) $(CONSTELLATION_CFLAGS) noinst_LTLIBRARIES = libcfpub.la libcfpub_la_SOURCES = \ getopt.c \ getopt1.c \ snprintf.c libcfpub_la_LIBADD = $(LTLIBOBJS) EXTRA_DIST = \ getopt.h \ snprintf.h # # Some basic clean ups # MOSTLYCLEANFILES = *~ # # Get everything removed down to where rebuilding requires: # "make; make install" # CLEANFILES = # # Get everything removed down to where rebuilding requires: # "configure; make; make install" # DISTCLEANFILES = # # Get everything removed down to where rebuilding requires: # "aclocal; autoconf; autoheader; automake --add-missing" # "configure; make; make install" # MAINTAINERCLEANFILES = Makefile.in cfengine-3.2.4/pub/dirfd.c0000644000175000017500000000265111715232734012252 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifdef HAVE_CONFIG_H #include "../src/conf.h" #endif #include #ifdef HAVE_DIRENT_H #include #endif #if !HAVE_DECL_DIRFD int dirfd(DIR *dirp); #endif /* Under Solaris dirfd(3) is just looking inside structure */ #if defined(__sun) int dirfd(DIR *dirp) { return dirp->d_fd != -1 ? dirp->d_fd : ENOTSUP; } #endif #if defined(__hpux) || defined(_AIX) int dirfd(DIR *dirp) { return dirp->dd_fd != -1 ? dirp->dd_fd : ENOTSUP; } #endif cfengine-3.2.4/pub/snprintf.h0000644000175000017500000000172611715232734013034 00000000000000#ifndef _PORTABLE_SNPRINTF_H_ #define _PORTABLE_SNPRINTF_H_ #define PORTABLE_SNPRINTF_VERSION_MAJOR 2 #define PORTABLE_SNPRINTF_VERSION_MINOR 2 #ifdef HAVE_SNPRINTF #include #else #include #include extern int snprintf(char *, size_t, const char *, /*args*/ ...); extern int vsnprintf(char *, size_t, const char *, va_list); #endif #if defined(HAVE_SNPRINTF) && defined(PREFER_PORTABLE_SNPRINTF) extern int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...); extern int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap); #define snprintf portable_snprintf #define vsnprintf portable_vsnprintf #endif extern int asprintf (char **ptr, const char *fmt, /*args*/ ...); extern int vasprintf (char **ptr, const char *fmt, va_list ap); extern int asnprintf (char **ptr, size_t str_m, const char *fmt, /*args*/ ...); extern int vasnprintf(char **ptr, size_t str_m, const char *fmt, va_list ap); #endif cfengine-3.2.4/pub/snprintf.c0000644000175000017500000012200611715232734013022 00000000000000/* * snprintf.c - a portable implementation of snprintf * * AUTHOR * Mark Martinec , April 1999. * * Copyright 1999, Mark Martinec. All rights reserved. * * TERMS AND CONDITIONS * This program is free software; you can redistribute it and/or modify * it under the terms of the "Frontier Artistic License" which comes * with this Kit. * * 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 Frontier Artistic License for more details. * * You should have received a copy of the Frontier Artistic License * with this Kit in the file named LICENSE.txt . * If not, I'll be glad to provide one. * * FEATURES * - careful adherence to specs regarding flags, field width and precision; * - good performance for large string handling (large format, large * argument or large paddings). Performance is similar to system's sprintf * and in several cases significantly better (make sure you compile with * optimizations turned on, tell the compiler the code is strict ANSI * if necessary to give it more freedom for optimizations); * - return value semantics per ISO/IEC 9899:1999 ("ISO C99"); * - written in standard ISO/ANSI C - requires an ANSI C compiler. * * SUPPORTED CONVERSION SPECIFIERS AND DATA TYPES * * This snprintf only supports the following conversion specifiers: * s, c, d, u, o, x, X, p (and synonyms: i, D, U, O - see below) * with flags: '-', '+', ' ', '0' and '#'. * An asterisk is supported for field width as well as precision. * * Length modifiers 'h' (short int), 'l' (long int), * and 'll' (long long int) are supported. * NOTE: * If macro SNPRINTF_LONGLONG_SUPPORT is not defined (default) the * length modifier 'll' is recognized but treated the same as 'l', * which may cause argument value truncation! Defining * SNPRINTF_LONGLONG_SUPPORT requires that your system's sprintf also * handles length modifier 'll'. long long int is a language extension * which may not be portable. * * Conversion of numeric data (conversion specifiers d, u, o, x, X, p) * with length modifiers (none or h, l, ll) is left to the system routine * sprintf, but all handling of flags, field width and precision as well as * c and s conversions is done very carefully by this portable routine. * If a string precision (truncation) is specified (e.g. %.8s) it is * guaranteed the string beyond the specified precision will not be referenced. * * Length modifiers h, l and ll are ignored for c and s conversions (data * types wint_t and wchar_t are not supported). * * The following common synonyms for conversion characters are supported: * - i is a synonym for d * - D is a synonym for ld, explicit length modifiers are ignored * - U is a synonym for lu, explicit length modifiers are ignored * - O is a synonym for lo, explicit length modifiers are ignored * The D, O and U conversion characters are nonstandard, they are supported * for backward compatibility only, and should not be used for new code. * * The following is specifically NOT supported: * - flag ' (thousands' grouping character) is recognized but ignored * - numeric conversion specifiers: f, e, E, g, G and synonym F, * as well as the new a and A conversion specifiers * - length modifier 'L' (long double) and 'q' (quad - use 'll' instead) * - wide character/string conversions: lc, ls, and nonstandard * synonyms C and S * - writeback of converted string length: conversion character n * - the n$ specification for direct reference to n-th argument * - locales * * It is permitted for str_m to be zero, and it is permitted to specify NULL * pointer for resulting string argument if str_m is zero (as per ISO C99). * * The return value is the number of characters which would be generated * for the given input, excluding the trailing null. If this value * is greater or equal to str_m, not all characters from the result * have been stored in str, output bytes beyond the (str_m-1) -th character * are discarded. If str_m is greater than zero it is guaranteed * the resulting string will be null-terminated. * * NOTE that this matches the ISO C99, OpenBSD, and GNU C library 2.1, * but is different from some older and vendor implementations, * and is also different from XPG, XSH5, SUSv2 specifications. * For historical discussion on changes in the semantics and standards * of snprintf see printf(3) man page in the Linux programmers manual. * * Routines asprintf and vasprintf return a pointer (in the ptr argument) * to a buffer sufficiently large to hold the resulting string. This pointer * should be passed to free(3) to release the allocated storage when it is * no longer needed. If sufficient space cannot be allocated, these functions * will return -1 and set ptr to be a NULL pointer. These two routines are a * GNU C library extensions (glibc). * * Routines asnprintf and vasnprintf are similar to asprintf and vasprintf, * yet, like snprintf and vsnprintf counterparts, will write at most str_m-1 * characters into the allocated output string, the last character in the * allocated buffer then gets the terminating null. If the formatted string * length (the return value) is greater than or equal to the str_m argument, * the resulting string was truncated and some of the formatted characters * were discarded. These routines present a handy way to limit the amount * of allocated memory to some sane value. * * AVAILABILITY * http://www.ijs.si/software/snprintf/ * * REVISION HISTORY * 1999-04 V0.9 Mark Martinec * - initial version, some modifications after comparing printf * man pages for Digital Unix 4.0, Solaris 2.6 and HPUX 10, * and checking how Perl handles sprintf (differently!); * 1999-04-09 V1.0 Mark Martinec * - added main test program, fixed remaining inconsistencies, * added optional (long long int) support; * 1999-04-12 V1.1 Mark Martinec * - support the 'p' conversion (pointer to void); * - if a string precision is specified * make sure the string beyond the specified precision * will not be referenced (e.g. by strlen); * 1999-04-13 V1.2 Mark Martinec * - support synonyms %D=%ld, %U=%lu, %O=%lo; * - speed up the case of long format string with few conversions; * 1999-06-30 V1.3 Mark Martinec * - fixed runaway loop (eventually crashing when str_l wraps * beyond 2^31) while copying format string without * conversion specifiers to a buffer that is too short * (thanks to Edwin Young for * spotting the problem); * - added macros PORTABLE_SNPRINTF_VERSION_(MAJOR|MINOR) * to snprintf.h * 2000-02-14 V2.0 (never released) Mark Martinec * - relaxed license terms: The Artistic License now applies. * You may still apply the GNU GENERAL PUBLIC LICENSE * as was distributed with previous versions, if you prefer; * - changed REVISION HISTORY dates to use ISO 8601 date format; * - added vsnprintf (patch also independently proposed by * Caolan McNamara 2000-05-04, and Keith M Willenson 2000-06-01) * 2000-06-27 V2.1 Mark Martinec * - removed POSIX check for str_m<1; value 0 for str_m is * allowed by ISO C99 (and GNU C library 2.1) - (pointed out * on 2000-05-04 by Caolan McNamara, caolan@ csn dot ul dot ie). * Besides relaxed license this change in standards adherence * is the main reason to bump up the major version number; * - added nonstandard routines asnprintf, vasnprintf, asprintf, * vasprintf that dynamically allocate storage for the * resulting string; these routines are not compiled by default, * see comments where NEED_V?ASN?PRINTF macros are defined; * - autoconf contributed by Caolan McNamara * 2000-10-06 V2.2 Mark Martinec * - BUG FIX: the %c conversion used a temporary variable * that was no longer in scope when referenced, * possibly causing incorrect resulting character; * - BUG FIX: make precision and minimal field width unsigned * to handle huge values (2^31 <= n < 2^32) correctly; * also be more careful in the use of signed/unsigned/size_t * internal variables - probably more careful than many * vendor implementations, but there may still be a case * where huge values of str_m, precision or minimal field * could cause incorrect behaviour; * - use separate variables for signed/unsigned arguments, * and for short/int, long, and long long argument lengths * to avoid possible incompatibilities on certain * computer architectures. Also use separate variable * arg_sign to hold sign of a numeric argument, * to make code more transparent; * - some fiddling with zero padding and "0x" to make it * Linux compatible; * - systematically use macros fast_memcpy and fast_memset * instead of case-by-case hand optimization; determine some * breakeven string lengths for different architectures; * - terminology change: 'format' -> 'conversion specifier', * 'C9x' -> 'ISO/IEC 9899:1999 ("ISO C99")', * 'alternative form' -> 'alternate form', * 'data type modifier' -> 'length modifier'; * - several comments rephrased and new ones added; * - make compiler not complain about 'credits' defined but * not used; */ #include "../src/conf.h" #ifndef HAVE_SNPRINTF # include "snprintf.h" #endif /* Define HAVE_SNPRINTF if your system already has snprintf and vsnprintf. * * If HAVE_SNPRINTF is defined this module will not produce code for * snprintf and vsnprintf, unless PREFER_PORTABLE_SNPRINTF is defined as well, * causing this portable version of snprintf to be called portable_snprintf * (and portable_vsnprintf). */ /* #define HAVE_SNPRINTF */ /* Define PREFER_PORTABLE_SNPRINTF if your system does have snprintf and * vsnprintf but you would prefer to use the portable routine(s) instead. * In this case the portable routine is declared as portable_snprintf * (and portable_vsnprintf) and a macro 'snprintf' (and 'vsnprintf') * is defined to expand to 'portable_v?snprintf' - see file snprintf.h . * Defining this macro is only useful if HAVE_SNPRINTF is also defined, * but does does no harm if defined nevertheless. */ /* #define PREFER_PORTABLE_SNPRINTF */ /* Define SNPRINTF_LONGLONG_SUPPORT if you want to support * data type (long long int) and length modifier 'll' (e.g. %lld). * If undefined, 'll' is recognized but treated as a single 'l'. * * If the system's sprintf does not handle 'll' * the SNPRINTF_LONGLONG_SUPPORT must not be defined! * * This is off by default as (long long int) is a language extension. */ /* #define SNPRINTF_LONGLONG_SUPPORT */ /* Define NEED_SNPRINTF_ONLY if you only need snprintf, and not vsnprintf. * If NEED_SNPRINTF_ONLY is defined, the snprintf will be defined directly, * otherwise both snprintf and vsnprintf routines will be defined * and snprintf will be a simple wrapper around vsnprintf, at the expense * of an extra procedure call. */ /* #define NEED_SNPRINTF_ONLY */ /* Define NEED_V?ASN?PRINTF macros if you need library extension * routines asprintf, vasprintf, asnprintf, vasnprintf respectively, * and your system library does not provide them. They are all small * wrapper routines around portable_vsnprintf. Defining any of the four * NEED_V?ASN?PRINTF macros automatically turns off NEED_SNPRINTF_ONLY * and turns on PREFER_PORTABLE_SNPRINTF. * * Watch for name conflicts with the system library if these routines * are already present there. * * NOTE: vasprintf and vasnprintf routines need va_copy() from stdarg.h, as * specified by C99, to be able to traverse the same list of arguments twice. * I don't know of any other standard and portable way of achieving the same. * With some versions of gcc you may use __va_copy(). You might even get away * with "ap2 = ap", in this case you must not call va_end(ap2) ! * #define va_copy(ap2,ap) ap2 = ap */ /* #define NEED_ASPRINTF */ /* #define NEED_ASNPRINTF */ /* #define NEED_VASPRINTF */ /* #define NEED_VASNPRINTF */ /* Define the following macros if desired: * SOLARIS_COMPATIBLE, SOLARIS_BUG_COMPATIBLE, * HPUX_COMPATIBLE, HPUX_BUG_COMPATIBLE, LINUX_COMPATIBLE, * DIGITAL_UNIX_COMPATIBLE, DIGITAL_UNIX_BUG_COMPATIBLE, * PERL_COMPATIBLE, PERL_BUG_COMPATIBLE, * * - For portable applications it is best not to rely on peculiarities * of a given implementation so it may be best not to define any * of the macros that select compatibility and to avoid features * that vary among the systems. * * - Selecting compatibility with more than one operating system * is not strictly forbidden but is not recommended. * * - 'x'_BUG_COMPATIBLE implies 'x'_COMPATIBLE . * * - 'x'_COMPATIBLE refers to (and enables) a behaviour that is * documented in a sprintf man page on a given operating system * and actually adhered to by the system's sprintf (but not on * most other operating systems). It may also refer to and enable * a behaviour that is declared 'undefined' or 'implementation specific' * in the man page but a given implementation behaves predictably * in a certain way. * * - 'x'_BUG_COMPATIBLE refers to (and enables) a behaviour of system's sprintf * that contradicts the sprintf man page on the same operating system. * * - I do not claim that the 'x'_COMPATIBLE and 'x'_BUG_COMPATIBLE * conditionals take into account all idiosyncrasies of a particular * implementation, there may be other incompatibilities. */ /* ============================================= */ /* NO USER SERVICABLE PARTS FOLLOWING THIS POINT */ /* ============================================= */ #define PORTABLE_SNPRINTF_VERSION_MAJOR 2 #define PORTABLE_SNPRINTF_VERSION_MINOR 2 #if defined(NEED_ASPRINTF) || defined(NEED_ASNPRINTF) || defined(NEED_VASPRINTF) || defined(NEED_VASNPRINTF) # if defined(NEED_SNPRINTF_ONLY) # undef NEED_SNPRINTF_ONLY # endif # if !defined(PREFER_PORTABLE_SNPRINTF) # define PREFER_PORTABLE_SNPRINTF # endif #endif #if defined(SOLARIS_BUG_COMPATIBLE) && !defined(SOLARIS_COMPATIBLE) #define SOLARIS_COMPATIBLE #endif #if defined(HPUX_BUG_COMPATIBLE) && !defined(HPUX_COMPATIBLE) #define HPUX_COMPATIBLE #endif #if defined(DIGITAL_UNIX_BUG_COMPATIBLE) && !defined(DIGITAL_UNIX_COMPATIBLE) #define DIGITAL_UNIX_COMPATIBLE #endif #if defined(PERL_BUG_COMPATIBLE) && !defined(PERL_COMPATIBLE) #define PERL_COMPATIBLE #endif #if defined(LINUX_BUG_COMPATIBLE) && !defined(LINUX_COMPATIBLE) #define LINUX_COMPATIBLE #endif #include #include #include #include #include #include #include #ifdef isdigit #undef isdigit #endif #define isdigit(c) ((c) >= '0' && (c) <= '9') /* For copying strings longer or equal to 'breakeven_point' * it is more efficient to call memcpy() than to do it inline. * The value depends mostly on the processor architecture, * but also on the compiler and its optimization capabilities. * The value is not critical, some small value greater than zero * will be just fine if you don't care to squeeze every drop * of performance out of the code. * * Small values favor memcpy, large values favor inline code. */ #if defined(__alpha__) || defined(__alpha) # define breakeven_point 2 /* AXP (DEC Alpha) - gcc or cc or egcs */ #endif #if defined(__i386__) || defined(__i386) # define breakeven_point 12 /* Intel Pentium/Linux - gcc 2.96 */ #endif #if defined(__hppa) # define breakeven_point 10 /* HP-PA - gcc */ #endif #if defined(__sparc__) || defined(__sparc) # define breakeven_point 33 /* Sun Sparc 5 - gcc 2.8.1 */ #endif /* some other values of possible interest: */ /* #define breakeven_point 8 */ /* VAX 4000 - vaxc */ /* #define breakeven_point 19 */ /* VAX 4000 - gcc 2.7.0 */ #ifndef breakeven_point # define breakeven_point 6 /* some reasonable one-size-fits-all value */ #endif #define fast_memcpy(d,s,n) \ { register size_t nn = (size_t)(n); \ if (nn >= breakeven_point) memcpy((d), (s), nn); \ else if (nn > 0) { /* proc call overhead is worth only for large strings*/\ register char *dd; register const char *ss; \ for (ss=(s), dd=(d); nn>0; nn--) *dd++ = *ss++; } } #define fast_memset(d,c,n) \ { register size_t nn = (size_t)(n); \ if (nn >= breakeven_point) memset((d), (int)(c), nn); \ else if (nn > 0) { /* proc call overhead is worth only for large strings*/\ register char *dd; register const int cc=(int)(c); \ for (dd=(d); nn>0; nn--) *dd++ = cc; } } /* prototypes */ #if defined(NEED_ASPRINTF) int asprintf (char **ptr, const char *fmt, /*args*/ ...); #endif #if defined(NEED_VASPRINTF) int vasprintf (char **ptr, const char *fmt, va_list ap); #endif #if defined(NEED_ASNPRINTF) int asnprintf (char **ptr, size_t str_m, const char *fmt, /*args*/ ...); #endif #if defined(NEED_VASNPRINTF) int vasnprintf (char **ptr, size_t str_m, const char *fmt, va_list ap); #endif #if defined(HAVE_SNPRINTF) /* declare our portable snprintf routine under name portable_snprintf */ /* declare our portable vsnprintf routine under name portable_vsnprintf */ #else /* declare our portable routines under names snprintf and vsnprintf */ #define portable_snprintf snprintf #if !defined(NEED_SNPRINTF_ONLY) #define portable_vsnprintf vsnprintf #endif #endif #if !defined(HAVE_SNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF) int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...); #if !defined(NEED_SNPRINTF_ONLY) int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap); #endif #endif /* declarations */ static char credits[] = "\n\ @(#)snprintf.c, v2.2: Mark Martinec, \n\ @(#)snprintf.c, v2.2: Copyright 1999, Mark Martinec. Frontier Artistic License applies.\n\ @(#)snprintf.c, v2.2: http://www.ijs.si/software/snprintf/\n"; #if defined(NEED_ASPRINTF) int asprintf(char **ptr, const char *fmt, /*args*/ ...) { va_list ap; size_t str_m; int str_l; *ptr = NULL; va_start(ap, fmt); /* measure the required size */ str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap); va_end(ap); assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */ *ptr = (char *) malloc(str_m = (size_t)str_l + 1); if (*ptr == NULL) { errno = ENOMEM; str_l = -1; } else { int str_l2; va_start(ap, fmt); str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap); va_end(ap); assert(str_l2 == str_l); } return str_l; } #endif #if defined(NEED_VASPRINTF) int vasprintf(char **ptr, const char *fmt, va_list ap) { size_t str_m; int str_l; *ptr = NULL; { va_list ap2; va_copy(ap2, ap); /* don't consume the original ap, we'll need it again */ str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap2);/*get required size*/ va_end(ap2); } assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */ *ptr = (char *) malloc(str_m = (size_t)str_l + 1); if (*ptr == NULL) { errno = ENOMEM; str_l = -1; } else { int str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap); assert(str_l2 == str_l); } return str_l; } #endif #if defined(NEED_ASNPRINTF) int asnprintf (char **ptr, size_t str_m, const char *fmt, /*args*/ ...) { va_list ap; int str_l; *ptr = NULL; va_start(ap, fmt); /* measure the required size */ str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap); va_end(ap); assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */ if ((size_t)str_l + 1 < str_m) str_m = (size_t)str_l + 1; /* truncate */ /* if str_m is 0, no buffer is allocated, just set *ptr to NULL */ if (str_m == 0) { /* not interested in resulting string, just return size */ } else { *ptr = (char *) malloc(str_m); if (*ptr == NULL) { errno = ENOMEM; str_l = -1; } else { int str_l2; va_start(ap, fmt); str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap); va_end(ap); assert(str_l2 == str_l); } } return str_l; } #endif #if defined(NEED_VASNPRINTF) int vasnprintf (char **ptr, size_t str_m, const char *fmt, va_list ap) { int str_l; *ptr = NULL; { va_list ap2; va_copy(ap2, ap); /* don't consume the original ap, we'll need it again */ str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap2);/*get required size*/ va_end(ap2); } assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */ if ((size_t)str_l + 1 < str_m) str_m = (size_t)str_l + 1; /* truncate */ /* if str_m is 0, no buffer is allocated, just set *ptr to NULL */ if (str_m == 0) { /* not interested in resulting string, just return size */ } else { *ptr = (char *) malloc(str_m); if (*ptr == NULL) { errno = ENOMEM; str_l = -1; } else { int str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap); assert(str_l2 == str_l); } } return str_l; } #endif /* * If the system does have snprintf and the portable routine is not * specifically required, this module produces no code for snprintf/vsnprintf. */ #if !defined(HAVE_SNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF) #if !defined(NEED_SNPRINTF_ONLY) int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...) { va_list ap; int str_l; va_start(ap, fmt); str_l = portable_vsnprintf(str, str_m, fmt, ap); va_end(ap); return str_l; } #endif #if defined(NEED_SNPRINTF_ONLY) int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...) { #else int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) { #endif #if defined(NEED_SNPRINTF_ONLY) va_list ap; #endif size_t str_l = 0; const char *p = fmt; /* In contrast with POSIX, the ISO C99 now says * that str can be NULL and str_m can be 0. * This is more useful than the old: if (str_m < 1) return -1; */ #if defined(NEED_SNPRINTF_ONLY) va_start(ap, fmt); #endif if (!p) p = ""; while (*p) { if (*p != '%') { /* if (str_l < str_m) str[str_l++] = *p++; -- this would be sufficient */ /* but the following code achieves better performance for cases * where format string is long and contains few conversions */ const char *q = strchr(p+1,'%'); size_t n = !q ? strlen(p) : (q-p); if (str_l < str_m) { size_t avail = str_m-str_l; fast_memcpy(str+str_l, p, (n>avail?avail:n)); } p += n; str_l += n; } else { const char *starting_p; size_t min_field_width = 0, precision = 0; int zero_padding = 0, precision_specified = 0, justify_left = 0; int alternate_form = 0, force_sign = 0; int space_for_positive = 1; /* If both the ' ' and '+' flags appear, the ' ' flag should be ignored. */ char length_modifier = '\0'; /* allowed values: \0, h, l, L */ char tmp[32];/* temporary buffer for simple numeric->string conversion */ const char *str_arg; /* string address in case of string argument */ size_t str_arg_l; /* natural field width of arg without padding and sign */ unsigned char uchar_arg; /* unsigned char argument value - only defined for c conversion. N.B. standard explicitly states the char argument for the c conversion is unsigned */ size_t number_of_zeros_to_pad = 0; /* number of zeros to be inserted for numeric conversions as required by the precision or minimal field width */ size_t zero_padding_insertion_ind = 0; /* index into tmp where zero padding is to be inserted */ char fmt_spec = '\0'; /* current conversion specifier character */ str_arg = credits;/* just to make compiler happy (defined but not used)*/ str_arg = NULL; starting_p = p; p++; /* skip '%' */ /* parse flags */ while (*p == '0' || *p == '-' || *p == '+' || *p == ' ' || *p == '#' || *p == '\'') { switch (*p) { case '0': zero_padding = 1; break; case '-': justify_left = 1; break; case '+': force_sign = 1; space_for_positive = 0; break; case ' ': force_sign = 1; /* If both the ' ' and '+' flags appear, the ' ' flag should be ignored */ #ifdef PERL_COMPATIBLE /* ... but in Perl the last of ' ' and '+' applies */ space_for_positive = 1; #endif break; case '#': alternate_form = 1; break; case '\'': break; } p++; } /* If the '0' and '-' flags both appear, the '0' flag should be ignored. */ /* parse field width */ if (*p == '*') { int j; p++; j = va_arg(ap, int); if (j >= 0) min_field_width = j; else { min_field_width = -j; justify_left = 1; } } else if (isdigit((int)(*p))) { /* size_t could be wider than unsigned int; make sure we treat argument like common implementations do */ unsigned int uj = *p++ - '0'; while (isdigit((int)(*p))) uj = 10*uj + (unsigned int)(*p++ - '0'); min_field_width = uj; } /* parse precision */ if (*p == '.') { p++; precision_specified = 1; if (*p == '*') { int j = va_arg(ap, int); p++; if (j >= 0) precision = j; else { precision_specified = 0; precision = 0; /* NOTE: * Solaris 2.6 man page claims that in this case the precision * should be set to 0. Digital Unix 4.0, HPUX 10 and BSD man page * claim that this case should be treated as unspecified precision, * which is what we do here. */ } } else if (isdigit((int)(*p))) { /* size_t could be wider than unsigned int; make sure we treat argument like common implementations do */ unsigned int uj = *p++ - '0'; while (isdigit((int)(*p))) uj = 10*uj + (unsigned int)(*p++ - '0'); precision = uj; } } /* parse 'h', 'l' and 'll' length modifiers */ if (*p == 'h' || *p == 'l') { length_modifier = *p; p++; if (length_modifier == 'l' && *p == 'l') { /* double l = long long */ #ifdef SNPRINTF_LONGLONG_SUPPORT length_modifier = '2'; /* double l encoded as '2' */ #else length_modifier = 'l'; /* treat it as a single 'l' */ #endif p++; } } fmt_spec = *p; /* common synonyms: */ switch (fmt_spec) { case 'i': fmt_spec = 'd'; break; case 'D': fmt_spec = 'd'; length_modifier = 'l'; break; case 'U': fmt_spec = 'u'; length_modifier = 'l'; break; case 'O': fmt_spec = 'o'; length_modifier = 'l'; break; default: break; } /* get parameter value, do initial processing */ switch (fmt_spec) { case '%': /* % behaves similar to 's' regarding flags and field widths */ case 'c': /* c behaves similar to 's' regarding flags and field widths */ case 's': length_modifier = '\0'; /* wint_t and wchar_t not supported */ /* the result of zero padding flag with non-numeric conversion specifier*/ /* is undefined. Solaris and HPUX 10 does zero padding in this case, */ /* Digital Unix and Linux does not. */ #if !defined(SOLARIS_COMPATIBLE) && !defined(HPUX_COMPATIBLE) zero_padding = 0; /* turn zero padding off for string conversions */ #endif str_arg_l = 1; switch (fmt_spec) { case '%': str_arg = p; break; case 'c': { int j = va_arg(ap, int); uchar_arg = (unsigned char) j; /* standard demands unsigned char */ str_arg = (const char *) &uchar_arg; break; } case 's': str_arg = va_arg(ap, const char *); if (!str_arg) str_arg_l = 0; /* make sure not to address string beyond the specified precision !!! */ else if (!precision_specified) str_arg_l = strlen(str_arg); /* truncate string if necessary as requested by precision */ else if (precision == 0) str_arg_l = 0; else { /* memchr on HP does not like n > 2^31 !!! */ const char *q = memchr(str_arg, '\0', precision <= 0x7fffffff ? precision : 0x7fffffff); str_arg_l = !q ? precision : (q-str_arg); } break; default: break; } break; case 'd': case 'u': case 'o': case 'x': case 'X': case 'p': { /* NOTE: the u, o, x, X and p conversion specifiers imply the value is unsigned; d implies a signed value */ int arg_sign = 0; /* 0 if numeric argument is zero (or if pointer is NULL for 'p'), +1 if greater than zero (or nonzero for unsigned arguments), -1 if negative (unsigned argument is never negative) */ int int_arg = 0; unsigned int uint_arg = 0; /* only defined for length modifier h, or for no length modifiers */ long int long_arg = 0; unsigned long int ulong_arg = 0; /* only defined for length modifier l */ void *ptr_arg = NULL; /* pointer argument value -only defined for p conversion */ #ifdef SNPRINTF_LONGLONG_SUPPORT long long int long_long_arg = 0; unsigned long long int ulong_long_arg = 0; /* only defined for length modifier ll */ #endif if (fmt_spec == 'p') { /* HPUX 10: An l, h, ll or L before any other conversion character * (other than d, i, u, o, x, or X) is ignored. * Digital Unix: * not specified, but seems to behave as HPUX does. * Solaris: If an h, l, or L appears before any other conversion * specifier (other than d, i, u, o, x, or X), the behavior * is undefined. (Actually %hp converts only 16-bits of address * and %llp treats address as 64-bit data which is incompatible * with (void *) argument on a 32-bit system). */ #ifdef SOLARIS_COMPATIBLE # ifdef SOLARIS_BUG_COMPATIBLE /* keep length modifiers even if it represents 'll' */ # else if (length_modifier == '2') length_modifier = '\0'; # endif #else length_modifier = '\0'; #endif ptr_arg = va_arg(ap, void *); if (ptr_arg != NULL) arg_sign = 1; } else if (fmt_spec == 'd') { /* signed */ switch (length_modifier) { case '\0': case 'h': /* It is non-portable to specify a second argument of char or short * to va_arg, because arguments seen by the called function * are not char or short. C converts char and short arguments * to int before passing them to a function. */ int_arg = va_arg(ap, int); if (int_arg > 0) arg_sign = 1; else if (int_arg < 0) arg_sign = -1; break; case 'l': long_arg = va_arg(ap, long int); if (long_arg > 0) arg_sign = 1; else if (long_arg < 0) arg_sign = -1; break; #ifdef SNPRINTF_LONGLONG_SUPPORT case '2': long_long_arg = va_arg(ap, long long int); if (long_long_arg > 0) arg_sign = 1; else if (long_long_arg < 0) arg_sign = -1; break; #endif } } else { /* unsigned */ switch (length_modifier) { case '\0': case 'h': uint_arg = va_arg(ap, unsigned int); if (uint_arg) arg_sign = 1; break; case 'l': ulong_arg = va_arg(ap, unsigned long int); if (ulong_arg) arg_sign = 1; break; #ifdef SNPRINTF_LONGLONG_SUPPORT case '2': ulong_long_arg = va_arg(ap, unsigned long long int); if (ulong_long_arg) arg_sign = 1; break; #endif } } str_arg = tmp; str_arg_l = 0; /* NOTE: * For d, i, u, o, x, and X conversions, if precision is specified, * the '0' flag should be ignored. This is so with Solaris 2.6, * Digital UNIX 4.0, HPUX 10, Linux, FreeBSD, NetBSD; but not with Perl. */ #ifndef PERL_COMPATIBLE if (precision_specified) zero_padding = 0; #endif if (fmt_spec == 'd') { if (force_sign && arg_sign >= 0) tmp[str_arg_l++] = space_for_positive ? ' ' : '+'; /* leave negative numbers for sprintf to handle, to avoid handling tricky cases like (short int)(-32768) */ #ifdef LINUX_COMPATIBLE } else if (fmt_spec == 'p' && force_sign && arg_sign > 0) { tmp[str_arg_l++] = space_for_positive ? ' ' : '+'; #endif } else if (alternate_form) { if (arg_sign != 0 && (fmt_spec == 'x' || fmt_spec == 'X') ) { tmp[str_arg_l++] = '0'; tmp[str_arg_l++] = fmt_spec; } /* alternate form should have no effect for p conversion, but ... */ #ifdef HPUX_COMPATIBLE else if (fmt_spec == 'p' /* HPUX 10: for an alternate form of p conversion, * a nonzero result is prefixed by 0x. */ #ifndef HPUX_BUG_COMPATIBLE /* Actually it uses 0x prefix even for a zero value. */ && arg_sign != 0 #endif ) { tmp[str_arg_l++] = '0'; tmp[str_arg_l++] = 'x'; } #endif } zero_padding_insertion_ind = str_arg_l; if (!precision_specified) precision = 1; /* default precision is 1 */ if (precision == 0 && arg_sign == 0 #if defined(HPUX_BUG_COMPATIBLE) || defined(LINUX_COMPATIBLE) && fmt_spec != 'p' /* HPUX 10 man page claims: With conversion character p the result of * converting a zero value with a precision of zero is a null string. * Actually HP returns all zeroes, and Linux returns "(nil)". */ #endif ) { /* converted to null string */ /* When zero value is formatted with an explicit precision 0, the resulting formatted string is empty (d, i, u, o, x, X, p). */ } else { char f[5]; int f_l = 0; f[f_l++] = '%'; /* construct a simple format string for sprintf */ if (!length_modifier) { } else if (length_modifier=='2') { f[f_l++] = 'l'; f[f_l++] = 'l'; } else f[f_l++] = length_modifier; f[f_l++] = fmt_spec; f[f_l++] = '\0'; if (fmt_spec == 'p') str_arg_l += sprintf(tmp+str_arg_l, f, ptr_arg); else if (fmt_spec == 'd') { /* signed */ switch (length_modifier) { case '\0': case 'h': str_arg_l+=sprintf(tmp+str_arg_l, f, int_arg); break; case 'l': str_arg_l+=sprintf(tmp+str_arg_l, f, long_arg); break; #ifdef SNPRINTF_LONGLONG_SUPPORT case '2': str_arg_l+=sprintf(tmp+str_arg_l,f,long_long_arg); break; #endif } } else { /* unsigned */ switch (length_modifier) { case '\0': case 'h': str_arg_l+=sprintf(tmp+str_arg_l, f, uint_arg); break; case 'l': str_arg_l+=sprintf(tmp+str_arg_l, f, ulong_arg); break; #ifdef SNPRINTF_LONGLONG_SUPPORT case '2': str_arg_l+=sprintf(tmp+str_arg_l,f,ulong_long_arg);break; #endif } } /* include the optional minus sign and possible "0x" in the region before the zero padding insertion point */ if (zero_padding_insertion_ind < str_arg_l && tmp[zero_padding_insertion_ind] == '-') { zero_padding_insertion_ind++; } if (zero_padding_insertion_ind+1 < str_arg_l && tmp[zero_padding_insertion_ind] == '0' && (tmp[zero_padding_insertion_ind+1] == 'x' || tmp[zero_padding_insertion_ind+1] == 'X') ) { zero_padding_insertion_ind += 2; } } { size_t num_of_digits = str_arg_l - zero_padding_insertion_ind; if (alternate_form && fmt_spec == 'o' #ifdef HPUX_COMPATIBLE /* ("%#.o",0) -> "" */ && (str_arg_l > 0) #endif #ifdef DIGITAL_UNIX_BUG_COMPATIBLE /* ("%#o",0) -> "00" */ #else /* unless zero is already the first character */ && !(zero_padding_insertion_ind < str_arg_l && tmp[zero_padding_insertion_ind] == '0') #endif ) { /* assure leading zero for alternate-form octal numbers */ if (!precision_specified || precision < num_of_digits+1) { /* precision is increased to force the first character to be zero, except if a zero value is formatted with an explicit precision of zero */ precision = num_of_digits+1; precision_specified = 1; } } /* zero padding to specified precision? */ if (num_of_digits < precision) number_of_zeros_to_pad = precision - num_of_digits; } /* zero padding to specified minimal field width? */ if (!justify_left && zero_padding) { int n = min_field_width - (str_arg_l+number_of_zeros_to_pad); if (n > 0) number_of_zeros_to_pad += n; } break; } default: /* unrecognized conversion specifier, keep format string as-is*/ zero_padding = 0; /* turn zero padding off for non-numeric convers. */ #ifndef DIGITAL_UNIX_COMPATIBLE justify_left = 1; min_field_width = 0; /* reset flags */ #endif #if defined(PERL_COMPATIBLE) || defined(LINUX_COMPATIBLE) /* keep the entire format string unchanged */ str_arg = starting_p; str_arg_l = p - starting_p; /* well, not exactly so for Linux, which does something inbetween, * and I don't feel an urge to imitate it: "%+++++hy" -> "%+y" */ #else /* discard the unrecognized conversion, just keep * * the unrecognized conversion character */ str_arg = p; str_arg_l = 0; #endif if (*p) str_arg_l++; /* include invalid conversion specifier unchanged if not at end-of-string */ break; } if (*p) p++; /* step over the just processed conversion specifier */ /* insert padding to the left as requested by min_field_width; this does not include the zero padding in case of numerical conversions*/ if (!justify_left) { /* left padding with blank or zero */ int n = min_field_width - (str_arg_l+number_of_zeros_to_pad); if (n > 0) { if (str_l < str_m) { size_t avail = str_m-str_l; fast_memset(str+str_l, (zero_padding?'0':' '), (n>avail?avail:n)); } str_l += n; } } /* zero padding as requested by the precision or by the minimal field width * for numeric conversions required? */ if (number_of_zeros_to_pad <= 0) { /* will not copy first part of numeric right now, * * force it to be copied later in its entirety */ zero_padding_insertion_ind = 0; } else { /* insert first part of numerics (sign or '0x') before zero padding */ int n = zero_padding_insertion_ind; if (n > 0) { if (str_l < str_m) { size_t avail = str_m-str_l; fast_memcpy(str+str_l, str_arg, (n>avail?avail:n)); } str_l += n; } /* insert zero padding as requested by the precision or min field width */ n = number_of_zeros_to_pad; if (n > 0) { if (str_l < str_m) { size_t avail = str_m-str_l; fast_memset(str+str_l, '0', (n>avail?avail:n)); } str_l += n; } } /* insert formatted string * (or as-is conversion specifier for unknown conversions) */ { int n = str_arg_l - zero_padding_insertion_ind; if (n > 0) { if (str_l < str_m) { size_t avail = str_m-str_l; fast_memcpy(str+str_l, str_arg+zero_padding_insertion_ind, (n>avail?avail:n)); } str_l += n; } } /* insert right padding */ if (justify_left) { /* right blank padding to the field width */ int n = min_field_width - (str_arg_l+number_of_zeros_to_pad); if (n > 0) { if (str_l < str_m) { size_t avail = str_m-str_l; fast_memset(str+str_l, ' ', (n>avail?avail:n)); } str_l += n; } } } } #if defined(NEED_SNPRINTF_ONLY) va_end(ap); #endif if (str_m > 0) { /* make sure the string is null-terminated even at the expense of overwriting the last character (shouldn't happen, but just in case) */ str[str_l <= str_m-1 ? str_l : str_m-1] = '\0'; } /* Return the number of characters formatted (excluding trailing null * character), that is, the number of characters that would have been * written to the buffer if it were large enough. * * The value of str_l should be returned, but str_l is of unsigned type * size_t, and snprintf is int, possibly leading to an undetected * integer overflow, resulting in a negative return value, which is illegal. * Both XSH5 and ISO C99 (at least the draft) are silent on this issue. * Should errno be set to EOVERFLOW and EOF returned in this case??? */ return (int) str_l; } #endif cfengine-3.2.4/pub/Makefile.in0000644000175000017500000004467011715232775013077 00000000000000# Makefile.in generated by automake 1.11.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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@ target_triplet = @target@ subdir = pub DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ clock_gettime.c dirfd.c getloadavg.c nanosleep.c round.c \ setlinebuf.c strdup.c strlcat.c strlcpy.c strndup.c strnlen.c \ unsetenv.c ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \ $(top_srcdir)/m4/cf3_with_library.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)/src/conf.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libcfpub_la_DEPENDENCIES = $(LTLIBOBJS) am_libcfpub_la_OBJECTS = getopt.lo getopt1.lo snprintf.lo libcfpub_la_OBJECTS = $(am_libcfpub_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src 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 " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libcfpub_la_SOURCES) DIST_SOURCES = $(libcfpub_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@ BERKELEYDB_CFLAGS = @BERKELEYDB_CFLAGS@ BERKELEYDB_LDFLAGS = @BERKELEYDB_LDFLAGS@ BERKELEYDB_LIBS = @BERKELEYDB_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EIGHTBIT = @EIGHTBIT@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GCC_CFLAG = @GCC_CFLAG@ GETCONF = @GETCONF@ GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ GREP = @GREP@ HOSTNAME = @HOSTNAME@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ KMEM_GROUP = @KMEM_GROUP@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_SELINUX = @LIB_SELINUX@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MYSQL_CFLAGS = @MYSQL_CFLAGS@ MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@ MYSQL_LDFLAGS = @MYSQL_LDFLAGS@ MYSQL_LIBS = @MYSQL_LIBS@ MYSQL_PATH = @MYSQL_PATH@ NEED_SETGID = @NEED_SETGID@ NM = @NM@ NMEDIT = @NMEDIT@ NOWRAP = @NOWRAP@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_CPPFLAGS = @OPENSSL_CPPFLAGS@ OPENSSL_LDFLAGS = @OPENSSL_LDFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OPENSSL_PATH = @OPENSSL_PATH@ 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@ PCRE_CFLAGS = @PCRE_CFLAGS@ PCRE_CPPFLAGS = @PCRE_CPPFLAGS@ PCRE_LDFLAGS = @PCRE_LDFLAGS@ PCRE_LIBS = @PCRE_LIBS@ PCRE_PATH = @PCRE_PATH@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_CPPFLAGS = @POSTGRESQL_CPPFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_LIBS = @POSTGRESQL_LIBS@ POSTGRESQL_PATH = @POSTGRESQL_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ TOKYOCABINET_CFLAGS = @TOKYOCABINET_CFLAGS@ TOKYOCABINET_CPPFLAGS = @TOKYOCABINET_CPPFLAGS@ TOKYOCABINET_LDFLAGS = @TOKYOCABINET_LDFLAGS@ TOKYOCABINET_LIBS = @TOKYOCABINET_LIBS@ TOKYOCABINET_PATH = @TOKYOCABINET_PATH@ 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_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ workdir = @workdir@ AM_CFLAGS = @CFLAGS@ @GCC_CFLAG@ -fPIC -DPIC AM_CPPFLAGS = $(NOVA_CFLAGS) $(CONSTELLATION_CFLAGS) noinst_LTLIBRARIES = libcfpub.la libcfpub_la_SOURCES = \ getopt.c \ getopt1.c \ snprintf.c libcfpub_la_LIBADD = $(LTLIBOBJS) EXTRA_DIST = \ getopt.h \ snprintf.h # # Some basic clean ups # MOSTLYCLEANFILES = *~ # # Get everything removed down to where rebuilding requires: # "make; make install" # CLEANFILES = # # Get everything removed down to where rebuilding requires: # "configure; make; make install" # DISTCLEANFILES = # # Get everything removed down to where rebuilding requires: # "aclocal; autoconf; autoheader; automake --add-missing" # "configure; make; make install" # MAINTAINERCLEANFILES = Makefile.in all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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) --gnu pub/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu pub/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(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 libcfpub.la: $(libcfpub_la_OBJECTS) $(libcfpub_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libcfpub_la_OBJECTS) $(libcfpub_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/clock_gettime.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/dirfd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getloadavg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/nanosleep.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/round.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/setlinebuf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strdup.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcpy.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strndup.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strnlen.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/unsetenv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snprintf.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 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(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 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -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: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) 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) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) 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 "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf $(DEPDIR) ./$(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-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) ./$(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: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean 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-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 # 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: cfengine-3.2.4/pub/getopt.c0000644000175000017500000005263111707771422012472 00000000000000/* Getopt for GNU. NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu before changing it! Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This tells Alpha OSF/1 not to define a getopt prototype in . Ditto for AIX 3.2 and . */ #ifndef _NO_PROTO #define _NO_PROTO #endif #if !defined (__STDC__) || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #if defined (_LIBC) || !defined (__GNU_LIBRARY__) /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ #include #endif /* GNU C library. */ /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg = NULL; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns EOF, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* XXX 1003.2 says this must be 1 before any call. */ int optind = 0; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ int optopt = '?'; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return EOF with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Value of POSIXLY_CORRECT environment variable. */ static char *posixly_correct; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ #include #define my_index strchr #else /* Avoid depending on library functions or files whose names are inconsistent. */ char *getenv (); static char * my_index (str, chr) const char *str; int chr; { while (*str) { if (*str == chr) return (char *) str; str++; } return 0; } /* If using GCC, we can safely declare strlen this way. If not using GCC, it is ok not to declare it. */ #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ #if !defined (__STDC__) || !__STDC__ /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen (const char *); #endif /* not __STDC__ */ #endif /* __GNUC__ */ #endif /* not __GNU_LIBRARY__ */ /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ static void exchange (argv) char **argv; { int bottom = first_nonopt; int middle = last_nonopt; int top = optind; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } /* Initialize the internal data when the first call is made. */ static const char * _getopt_initialize (optstring) const char *optstring; { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ first_nonopt = last_nonopt = optind = 1; nextchar = NULL; posixly_correct = getenv ("POSIXLY_CORRECT"); /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; return optstring; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns `EOF'. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { optarg = NULL; if (optind == 0) optstring = _getopt_initialize (optstring); if (nextchar == NULL || *nextchar == '\0') { /* Advance to the next ARGV-element. */ if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && (argv[optind][0] != '-' || argv[optind][1] == '\0')) optind++; last_nonopt = optind; } /* The special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp (argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return EOF; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if ((argv[optind][0] != '-' || argv[optind][1] == '\0')) { if (ordering == REQUIRE_ORDER) return EOF; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Skip the initial punctuation. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } /* Decode the current option-ARGV-element. */ /* Check whether the ARGV-element is a long option. If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = 0; int option_index; for (nameend = nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if (nameend - nextchar == strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) fprintf (stderr, "%s: option `%s' is ambiguous\n", argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; return '?'; } if (pfound != NULL) { option_index = indfound; optind++; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (opterr) { if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, "%s: option `--%s' doesn't allow an argument\n", argv[0], pfound->name); else /* +option or -option */ fprintf (stderr, "%s: option `%c%s' doesn't allow an argument\n", argv[0], argv[optind - 1][0], pfound->name); } nextchar += strlen (nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) fprintf (stderr, "%s: option `%s' requires an argument\n", argv[0], argv[optind - 1]); nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' || my_index (optstring, *nextchar) == NULL) { if (opterr) { if (argv[optind][1] == '-') /* --option */ fprintf (stderr, "%s: unrecognized option `--%s'\n", argv[0], nextchar); else /* +option or -option */ fprintf (stderr, "%s: unrecognized option `%c%s'\n", argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; optind++; return '?'; } } /* Look at and handle the next short option-character. */ { char c = *nextchar++; char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (opterr) { if (posixly_correct) /* 1003.2 specifies the format of this message. */ fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); else fprintf (stderr, "%s: invalid option -- %c\n", argv[0], c); } optopt = c; return '?'; } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = NULL; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, "%s: option requires an argument -- %c\n", argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } int getopt (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } #endif /* _LIBC or not __GNU_LIBRARY__. */ #ifdef TEST /* Compile with -DTEST to make an executable for use in testing the above definition of `getopt'. */ int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; c = getopt (argc, argv, "abc:d:0123456789"); if (c == EOF) break; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ cfengine-3.2.4/pub/getloadavg.c0000644000175000017500000006241111707771422013302 00000000000000/* Get the system load averages. Copyright (C) 1985, 86, 87, 88, 89, 91, 92, 93, 1994, 1995, 1997 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. */ /* Compile-time symbols that this file uses: HAVE_PSTAT_GETDYNAMIC Define this if your system has the pstat_getdynamic function. I think it is unique to HPUX9. The best way to get the definition is through the AC_FUNC_GETLOADAVG macro that comes with autoconf 2.13 or newer. If that isn't an option, then just put AC_CHECK_FUNCS(pstat_getdynamic) in your configure.in file. FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist. KERNEL_FILE Pathname of the kernel to nlist. LDAV_CVT() Scale the load average from the kernel. Returns a double. LDAV_SYMBOL Name of kernel symbol giving load average. LOAD_AVE_TYPE Type of the load average array in the kernel. Must be defined unless one of apollo, DGUX, NeXT, or UMAX is defined; or we have libkstat; otherwise, no load average is available. NLIST_STRUCT Include nlist.h, not a.out.h, and the nlist n_name element is a pointer, not an array. NLIST_NAME_UNION struct nlist has an n_un member, not n_name. LINUX_LDAV_FILE [__linux__]: File containing load averages. Specific system predefines this file uses, aside from setting default values if not emacs: apollo BSD Real BSD, not just BSD-like. convex DGUX eunice UNIX emulator under VMS. hpux __MSDOS__ No-op for MSDOS. NeXT sgi sequent Sequent Dynix 3.x.x (BSD) _SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV) sony_news NEWS-OS (works at least for 4.1C) UMAX UMAX4_3 VMS WINDOWS32 No-op for Windows95/NT. __linux__ Linux: assumes /proc filesystem mounted. Support from Michael K. Johnson. __NetBSD__ NetBSD: assumes /kern filesystem mounted. In addition, to avoid nesting many #ifdefs, we internally set LDAV_DONE to indicate that the load average has been computed. We also #define LDAV_PRIVILEGED if a program will require special installation to be able to call getloadavg. */ /* This should always be first. */ #include "../src/conf.h" #ifdef HAVE_NLIST_H /* What autoconf defines. */ # undef NLIST_STRUCT # define NLIST_STRUCT #endif #include /* Both the Emacs and non-Emacs sections want this. Some configuration files' definitions for the LOAD_AVE_CVT macro (like sparc.h's) use macros like FSCALE, defined here. */ #if defined (unix) || defined (__unix) # include #endif /* Exclude all the code except the test program at the end if the system has its own `getloadavg' function. The declaration of `errno' is needed by the test program as well as the function itself, so it comes first. */ #include #ifndef errno extern int errno; #endif #ifndef HAVE_GETLOADAVG /* The existing Emacs configuration files define a macro called LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and returns the load average multiplied by 100. What we actually want is a macro called LDAV_CVT, which returns the load average as an unmultiplied double. For backwards compatibility, we'll define LDAV_CVT in terms of LOAD_AVE_CVT, but future machine config files should just define LDAV_CVT directly. */ # if !defined(LDAV_CVT) && defined(LOAD_AVE_CVT) # define LDAV_CVT(n) (LOAD_AVE_CVT (n) / 100.0) # endif # if !defined (BSD) && defined (ultrix) /* Ultrix behaves like BSD on Vaxen. */ # define BSD # endif # ifdef NeXT /* NeXT in the 2.{0,1,2} releases defines BSD in , which conflicts with the definition understood in this file, that this really is BSD. */ # undef BSD /* NeXT defines FSCALE in . However, we take FSCALE being defined to mean that the nlist method should be used, which is not true. */ # undef FSCALE # endif /* Same issues as for NeXT apply to the HURD-based GNU system. */ # ifdef __GNU__ # undef BSD # undef FSCALE # endif /* __GNU__ */ /* Set values that are different from the defaults, which are set a little farther down with #ifndef. */ /* Some shorthands. */ # if defined (HPUX) && !defined (hpux) # define hpux # endif # if defined (__hpux) && !defined (hpux) # define hpux # endif # if defined (__sun) && !defined (sun) # define sun # endif # if defined(hp300) && !defined(hpux) # define MORE_BSD # endif # if defined(ultrix) && defined(mips) # define decstation # endif # if defined (__SVR4) && !defined (SVR4) # define SVR4 # endif # if (defined(sun) && defined(SVR4)) || defined (SOLARIS2) # define SUNOS_5 # endif # if defined (__osf__) && (defined (__alpha) || defined (__alpha__)) # define OSF_ALPHA # include # include # include # include # endif # if defined (__osf__) && (defined (mips) || defined (__mips__)) # define OSF_MIPS # include # endif /* UTek's /bin/cc on the 4300 has no architecture specific cpp define by default, but _MACH_IND_SYS_TYPES is defined in . Combine that with a couple of other things and we'll have a unique match. */ # if !defined (tek4300) && defined (unix) && defined (m68k) && defined (mc68000) && defined (mc68020) && defined (_MACH_IND_SYS_TYPES) # define tek4300 /* Define by emacs, but not by other users. */ # endif /* VAX C can't handle multi-line #ifs, or lines longer than 256 chars. */ # ifndef LOAD_AVE_TYPE # ifdef MORE_BSD # define LOAD_AVE_TYPE long # endif # ifdef sun # define LOAD_AVE_TYPE long # endif # ifdef decstation # define LOAD_AVE_TYPE long # endif # ifdef _SEQUENT_ # define LOAD_AVE_TYPE long # endif # ifdef sgi # define LOAD_AVE_TYPE long # endif # ifdef SVR4 # define LOAD_AVE_TYPE long # endif # ifdef sony_news # define LOAD_AVE_TYPE long # endif # ifdef sequent # define LOAD_AVE_TYPE long # endif # ifdef OSF_ALPHA # define LOAD_AVE_TYPE long # endif # if defined (ardent) && defined (titan) # define LOAD_AVE_TYPE long # endif # ifdef tek4300 # define LOAD_AVE_TYPE long # endif # if defined(alliant) && defined(i860) /* Alliant FX/2800 */ # define LOAD_AVE_TYPE long # endif # ifdef _AIX # define LOAD_AVE_TYPE long # endif # ifdef convex # define LOAD_AVE_TYPE double # ifndef LDAV_CVT # define LDAV_CVT(n) (n) # endif # endif # endif /* No LOAD_AVE_TYPE. */ # ifdef OSF_ALPHA /* defines an incorrect value for FSCALE on Alpha OSF/1, according to ghazi@noc.rutgers.edu. */ # undef FSCALE # define FSCALE 1024.0 # endif # if defined(alliant) && defined(i860) /* Alliant FX/2800 */ /* defines an incorrect value for FSCALE on an Alliant FX/2800 Concentrix 2.2, according to ghazi@noc.rutgers.edu. */ # undef FSCALE # define FSCALE 100.0 # endif # ifndef FSCALE /* SunOS and some others define FSCALE in sys/param.h. */ # ifdef MORE_BSD # define FSCALE 2048.0 # endif # if defined(MIPS) || defined(SVR4) || defined(decstation) # define FSCALE 256 # endif # if defined (sgi) || defined (sequent) /* Sometimes both MIPS and sgi are defined, so FSCALE was just defined above under #ifdef MIPS. But we want the sgi value. */ # undef FSCALE # define FSCALE 1000.0 # endif # if defined (ardent) && defined (titan) # define FSCALE 65536.0 # endif # ifdef tek4300 # define FSCALE 100.0 # endif # ifdef _AIX # define FSCALE 65536.0 # endif # endif /* Not FSCALE. */ # if !defined (LDAV_CVT) && defined (FSCALE) # define LDAV_CVT(n) (((double) (n)) / FSCALE) # endif # if defined(sgi) || (defined(mips) && !defined(BSD)) # define FIXUP_KERNEL_SYMBOL_ADDR(nl) ((nl)[0].n_value &= ~(1 << 31)) # endif # if !defined (KERNEL_FILE) && defined (sequent) # define KERNEL_FILE "/dynix" # endif # if !defined (KERNEL_FILE) && defined (hpux) # define KERNEL_FILE "/hp-ux" # endif # if !defined(KERNEL_FILE) && (defined(_SEQUENT_) || defined(MIPS) || defined(SVR4) || defined(ISC) || defined (sgi) || (defined (ardent) && defined (titan))) # define KERNEL_FILE "/unix" # endif # if !defined (LDAV_SYMBOL) && defined (alliant) # define LDAV_SYMBOL "_Loadavg" # endif # if !defined(LDAV_SYMBOL) && ((defined(hpux) && !defined(hp9000s300)) || defined(_SEQUENT_) || defined(SVR4) || defined(ISC) || defined(sgi) || (defined (ardent) && defined (titan)) || defined (_AIX)) # define LDAV_SYMBOL "avenrun" # endif # ifdef HAVE_UNISTD_H # include # endif # include /* LOAD_AVE_TYPE should only get defined if we're going to use the nlist method. */ # if !defined(LOAD_AVE_TYPE) && (defined(BSD) || defined(LDAV_CVT) || defined(KERNEL_FILE) || defined(LDAV_SYMBOL)) # define LOAD_AVE_TYPE double # endif # ifdef LOAD_AVE_TYPE # ifndef VMS # ifndef __linux__ # ifndef NLIST_STRUCT # include # else /* NLIST_STRUCT */ # include # endif /* NLIST_STRUCT */ # ifdef SUNOS_5 # include //# include # include # endif # if defined (hpux) && defined (HAVE_PSTAT_GETDYNAMIC) # include # endif # ifndef KERNEL_FILE # define KERNEL_FILE "/vmunix" # endif /* KERNEL_FILE */ # ifndef LDAV_SYMBOL # define LDAV_SYMBOL "_avenrun" # endif /* LDAV_SYMBOL */ # endif /* __linux__ */ # else /* VMS */ # ifndef eunice # include # include # else /* eunice */ # include # endif /* eunice */ # endif /* VMS */ # ifndef LDAV_CVT # define LDAV_CVT(n) ((double) (n)) # endif /* !LDAV_CVT */ # endif /* LOAD_AVE_TYPE */ # if defined(__GNU__) && !defined (NeXT) /* Note that NeXT Openstep defines __GNU__ even though it should not. */ /* GNU system acts much like NeXT, for load average purposes, but not exactly. */ # define NeXT # define host_self mach_host_self # endif # ifdef NeXT # ifdef HAVE_MACH_MACH_H # include # else # include # endif # endif /* NeXT */ # ifdef sgi # include # endif /* sgi */ # ifdef UMAX # include # include # include # include # include # ifdef UMAX_43 # include # include # include # include # include # else /* Not UMAX_43. */ # include # include # include # include # include # include # endif /* Not UMAX_43. */ # endif /* UMAX */ # ifdef DGUX # include # endif # if defined(HAVE_FCNTL_H) || defined(_POSIX_VERSION) # include # else # include # endif /* Avoid static vars inside a function since in HPUX they dump as pure. */ # ifdef NeXT static processor_set_t default_set; static int getloadavg_initialized; # endif /* NeXT */ # ifdef UMAX static unsigned int cpus = 0; static unsigned int samples; # endif /* UMAX */ # ifdef DGUX static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */ # endif /* DGUX */ #if !defined(HAVE_LIBKSTAT) && defined(LOAD_AVE_TYPE) /* File descriptor open to /dev/kmem or VMS load ave driver. */ static int channel; /* Nonzero iff channel is valid. */ static int getloadavg_initialized; /* Offset in kmem to seek to read load average, or 0 means invalid. */ static long offset; #if !defined(VMS) && !defined(sgi) && !defined(__linux__) static struct nlist nl[2]; #endif /* Not VMS or sgi */ #ifdef SUNOS_5 static kvm_t *kd; #endif /* SUNOS_5 */ #endif /* LOAD_AVE_TYPE && !HAVE_LIBKSTAT */ /* Put the 1 minute, 5 minute and 15 minute load averages into the first NELEM elements of LOADAVG. Return the number written (never more than 3, but may be less than NELEM), or -1 if an error occurred. */ int getloadavg (loadavg, nelem) double loadavg[]; int nelem; { int elem = 0; /* Return value. */ # ifdef NO_GET_LOAD_AVG # define LDAV_DONE /* Set errno to zero to indicate that there was no particular error; this function just can't work at all on this system. */ errno = 0; elem = -1; # endif # if !defined (LDAV_DONE) && defined (HAVE_LIBKSTAT) /* Use libkstat because we don't have to be root. */ # define LDAV_DONE kstat_ctl_t *kc; kstat_t *ksp; kstat_named_t *kn; kc = kstat_open (); if (kc == 0) return -1; ksp = kstat_lookup (kc, "unix", 0, "system_misc"); if (ksp == 0 ) return -1; if (kstat_read (kc, ksp, 0) == -1) return -1; kn = kstat_data_lookup (ksp, "avenrun_1min"); if (kn == 0) { /* Return -1 if no load average information is available. */ nelem = 0; elem = -1; } if (nelem >= 1) loadavg[elem++] = (double) kn->value.ul/FSCALE; if (nelem >= 2) { kn = kstat_data_lookup (ksp, "avenrun_5min"); if (kn != 0) { loadavg[elem++] = (double) kn->value.ul/FSCALE; if (nelem >= 3) { kn = kstat_data_lookup (ksp, "avenrun_15min"); if (kn != 0) loadavg[elem++] = (double) kn->value.ul/FSCALE; } } } kstat_close (kc); # endif /* HAVE_LIBKSTAT */ # if !defined (LDAV_DONE) && defined (hpux) && defined (HAVE_PSTAT_GETDYNAMIC) /* Use pstat_getdynamic() because we don't have to be root. */ # define LDAV_DONE # undef LOAD_AVE_TYPE struct pst_dynamic dyn_info; if (pstat_getdynamic (&dyn_info, sizeof (dyn_info), 0, 0) < 0) return -1; if (nelem > 0) loadavg[elem++] = dyn_info.psd_avg_1_min; if (nelem > 1) loadavg[elem++] = dyn_info.psd_avg_5_min; if (nelem > 2) loadavg[elem++] = dyn_info.psd_avg_15_min; # endif /* hpux && HAVE_PSTAT_GETDYNAMIC */ # if !defined (LDAV_DONE) && defined (__linux__) # define LDAV_DONE # undef LOAD_AVE_TYPE # ifndef LINUX_LDAV_FILE # define LINUX_LDAV_FILE "/proc/loadavg" # endif char ldavgbuf[40]; double load_ave[3]; int fd, count; fd = open (LINUX_LDAV_FILE, O_RDONLY); if (fd == -1) return -1; count = read (fd, ldavgbuf, 40); (void) close (fd); if (count <= 0) return -1; count = sscanf (ldavgbuf, "%lf %lf %lf", &load_ave[0], &load_ave[1], &load_ave[2]); if (count < 1) return -1; for (elem = 0; elem < nelem && elem < count; elem++) loadavg[elem] = load_ave[elem]; return elem; # endif /* __linux__ */ # if !defined (LDAV_DONE) && defined (__NetBSD__) # define LDAV_DONE # undef LOAD_AVE_TYPE # ifndef NETBSD_LDAV_FILE # define NETBSD_LDAV_FILE "/kern/loadavg" # endif unsigned long int load_ave[3], scale; int count; FILE *fp; fp = fopen (NETBSD_LDAV_FILE, "r"); if (fp == NULL) return -1; count = fscanf (fp, "%lu %lu %lu %lu\n", &load_ave[0], &load_ave[1], &load_ave[2], &scale); (void) fclose (fp); if (count != 4) return -1; for (elem = 0; elem < nelem; elem++) loadavg[elem] = (double) load_ave[elem] / (double) scale; return elem; # endif /* __NetBSD__ */ # if !defined (LDAV_DONE) && defined (NeXT) # define LDAV_DONE /* The NeXT code was adapted from iscreen 3.2. */ host_t host; struct processor_set_basic_info info; unsigned info_count; /* We only know how to get the 1-minute average for this system, so even if the caller asks for more than 1, we only return 1. */ if (!getloadavg_initialized) { if (processor_set_default (host_self (), &default_set) == KERN_SUCCESS) getloadavg_initialized = 1; } if (getloadavg_initialized) { info_count = PROCESSOR_SET_BASIC_INFO_COUNT; if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host, (processor_set_info_t) &info, &info_count) != KERN_SUCCESS) getloadavg_initialized = 0; else { if (nelem > 0) loadavg[elem++] = (double) info.load_average / LOAD_SCALE; } } if (!getloadavg_initialized) return -1; # endif /* NeXT */ # if !defined (LDAV_DONE) && defined (UMAX) # define LDAV_DONE /* UMAX 4.2, which runs on the Encore Multimax multiprocessor, does not have a /dev/kmem. Information about the workings of the running kernel can be gathered with inq_stats system calls. We only know how to get the 1-minute average for this system. */ struct proc_summary proc_sum_data; struct stat_descr proc_info; double load; register unsigned int i, j; if (cpus == 0) { register unsigned int c, i; struct cpu_config conf; struct stat_descr desc; desc.sd_next = 0; desc.sd_subsys = SUBSYS_CPU; desc.sd_type = CPUTYPE_CONFIG; desc.sd_addr = (char *) &conf; desc.sd_size = sizeof conf; if (inq_stats (1, &desc)) return -1; c = 0; for (i = 0; i < conf.config_maxclass; ++i) { struct class_stats stats; bzero ((char *) &stats, sizeof stats); desc.sd_type = CPUTYPE_CLASS; desc.sd_objid = i; desc.sd_addr = (char *) &stats; desc.sd_size = sizeof stats; if (inq_stats (1, &desc)) return -1; c += stats.class_numcpus; } cpus = c; samples = cpus < 2 ? 3 : (2 * cpus / 3); } proc_info.sd_next = 0; proc_info.sd_subsys = SUBSYS_PROC; proc_info.sd_type = PROCTYPE_SUMMARY; proc_info.sd_addr = (char *) &proc_sum_data; proc_info.sd_size = sizeof (struct proc_summary); proc_info.sd_sizeused = 0; if (inq_stats (1, &proc_info) != 0) return -1; load = proc_sum_data.ps_nrunnable; j = 0; for (i = samples - 1; i > 0; --i) { load += proc_sum_data.ps_nrun[j]; if (j++ == PS_NRUNSIZE) j = 0; } if (nelem > 0) loadavg[elem++] = load / samples / cpus; # endif /* UMAX */ # if !defined (LDAV_DONE) && defined (DGUX) # define LDAV_DONE /* This call can return -1 for an error, but with good args it's not supposed to fail. The first argument is for no apparent reason of type `long int *'. */ dg_sys_info ((long int *) &load_info, DG_SYS_INFO_LOAD_INFO_TYPE, DG_SYS_INFO_LOAD_VERSION_0); if (nelem > 0) loadavg[elem++] = load_info.one_minute; if (nelem > 1) loadavg[elem++] = load_info.five_minute; if (nelem > 2) loadavg[elem++] = load_info.fifteen_minute; # endif /* DGUX */ # if !defined (LDAV_DONE) && defined (apollo) # define LDAV_DONE /* Apollo code from lisch@mentorg.com (Ray Lischner). This system call is not documented. The load average is obtained as three long integers, for the load average over the past minute, five minutes, and fifteen minutes. Each value is a scaled integer, with 16 bits of integer part and 16 bits of fraction part. I'm not sure which operating system first supported this system call, but I know that SR10.2 supports it. */ extern void proc1_$get_loadav (); unsigned long load_ave[3]; proc1_$get_loadav (load_ave); if (nelem > 0) loadavg[elem++] = load_ave[0] / 65536.0; if (nelem > 1) loadavg[elem++] = load_ave[1] / 65536.0; if (nelem > 2) loadavg[elem++] = load_ave[2] / 65536.0; # endif /* apollo */ # if !defined (LDAV_DONE) && defined (OSF_MIPS) # define LDAV_DONE struct tbl_loadavg load_ave; table (TBL_LOADAVG, 0, &load_ave, 1, sizeof (load_ave)); loadavg[elem++] = (load_ave.tl_lscale == 0 ? load_ave.tl_avenrun.d[0] : (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale)); # endif /* OSF_MIPS */ # if !defined (LDAV_DONE) && (defined (__MSDOS__) || defined (WINDOWS32)) # define LDAV_DONE /* A faithful emulation is going to have to be saved for a rainy day. */ for ( ; elem < nelem; elem++) { loadavg[elem] = 0.0; } # endif /* __MSDOS__ || WINDOWS32 */ # if !defined (LDAV_DONE) && defined (OSF_ALPHA) # define LDAV_DONE struct tbl_loadavg load_ave; table (TBL_LOADAVG, 0, &load_ave, 1, sizeof (load_ave)); for (elem = 0; elem < nelem; elem++) loadavg[elem] = (load_ave.tl_lscale == 0 ? load_ave.tl_avenrun.d[elem] : (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale)); # endif /* OSF_ALPHA */ # if !defined (LDAV_DONE) && defined (VMS) /* VMS specific code -- read from the Load Ave driver. */ LOAD_AVE_TYPE load_ave[3]; static int getloadavg_initialized = 0; # ifdef eunice struct { int dsc$w_length; char *dsc$a_pointer; } descriptor; # endif /* Ensure that there is a channel open to the load ave device. */ if (!getloadavg_initialized) { /* Attempt to open the channel. */ # ifdef eunice descriptor.dsc$w_length = 18; descriptor.dsc$a_pointer = "$$VMS_LOAD_AVERAGE"; # else $DESCRIPTOR (descriptor, "LAV0:"); # endif if (sys$assign (&descriptor, &channel, 0, 0) & 1) getloadavg_initialized = 1; } /* Read the load average vector. */ if (getloadavg_initialized && !(sys$qiow (0, channel, IO$_READVBLK, 0, 0, 0, load_ave, 12, 0, 0, 0, 0) & 1)) { sys$dassgn (channel); getloadavg_initialized = 0; } if (!getloadavg_initialized) return -1; # endif /* VMS */ # if !defined (LDAV_DONE) && defined(LOAD_AVE_TYPE) && !defined(VMS) /* UNIX-specific code -- read the average from /dev/kmem. */ # define LDAV_PRIVILEGED /* This code requires special installation. */ LOAD_AVE_TYPE load_ave[3]; /* Get the address of LDAV_SYMBOL. */ if (offset == 0) { # ifndef sgi # ifndef NLIST_STRUCT strcpy (nl[0].n_name, LDAV_SYMBOL); strcpy (nl[1].n_name, ""); # else /* NLIST_STRUCT */ # ifdef NLIST_NAME_UNION nl[0].n_un.n_name = LDAV_SYMBOL; nl[1].n_un.n_name = 0; # else /* not NLIST_NAME_UNION */ nl[0].n_name = LDAV_SYMBOL; nl[1].n_name = 0; # endif /* not NLIST_NAME_UNION */ # endif /* NLIST_STRUCT */ # ifndef SUNOS_5 if ( # if !(defined (_AIX) && !defined (ps2)) nlist (KERNEL_FILE, nl) # else /* _AIX */ knlist (nl, 1, sizeof (nl[0])) # endif >= 0) /* Omit "&& nl[0].n_type != 0 " -- it breaks on Sun386i. */ { # ifdef FIXUP_KERNEL_SYMBOL_ADDR FIXUP_KERNEL_SYMBOL_ADDR (nl); # endif offset = nl[0].n_value; } # endif /* !SUNOS_5 */ # else /* sgi */ int ldav_off; ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN); if (ldav_off != -1) offset = (long) ldav_off & 0x7fffffff; # endif /* sgi */ } /* Make sure we have /dev/kmem open. */ if (!getloadavg_initialized) { # ifndef SUNOS_5 channel = open ("/dev/kmem", 0); if (channel >= 0) { /* Set the channel to close on exec, so it does not litter any child's descriptor table. */ # ifdef F_SETFD # ifndef FD_CLOEXEC # define FD_CLOEXEC 1 # endif (void) fcntl (channel, F_SETFD, FD_CLOEXEC); # endif getloadavg_initialized = 1; } # else /* SUNOS_5 */ /* We pass 0 for the kernel, corefile, and swapfile names to use the currently running kernel. */ kd = kvm_open (0, 0, 0, O_RDONLY, 0); if (kd != 0) { /* nlist the currently running kernel. */ kvm_nlist (kd, nl); offset = nl[0].n_value; getloadavg_initialized = 1; } # endif /* SUNOS_5 */ } /* If we can, get the load average values. */ if (offset && getloadavg_initialized) { /* Try to read the load. */ # ifndef SUNOS_5 if (lseek (channel, offset, 0) == -1L || read (channel, (char *) load_ave, sizeof (load_ave)) != sizeof (load_ave)) { close (channel); getloadavg_initialized = 0; } # else /* SUNOS_5 */ if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave)) != sizeof (load_ave)) { kvm_close (kd); getloadavg_initialized = 0; } # endif /* SUNOS_5 */ } if (offset == 0 || !getloadavg_initialized) return -1; # endif /* LOAD_AVE_TYPE and not VMS */ # if !defined (LDAV_DONE) && defined (LOAD_AVE_TYPE) /* Including VMS. */ if (nelem > 0) loadavg[elem++] = LDAV_CVT (load_ave[0]); if (nelem > 1) loadavg[elem++] = LDAV_CVT (load_ave[1]); if (nelem > 2) loadavg[elem++] = LDAV_CVT (load_ave[2]); # define LDAV_DONE # endif /* !LDAV_DONE && LOAD_AVE_TYPE */ # ifdef LDAV_DONE return elem; # else /* Set errno to zero to indicate that there was no particular error; this function just can't work at all on this system. */ errno = 0; return -1; # endif } #endif /* ! HAVE_GETLOADAVG */ #ifdef TEST int main (argc, argv) int argc; char **argv; { int naptime = 0; if (argc > 1) naptime = atoi (argv[1]); while (1) { double avg[3]; int loads; errno = 0; /* Don't be misled if it doesn't set errno. */ loads = getloadavg (avg, 3); if (loads == -1) { perror ("Error getting load average"); exit (1); } if (loads > 0) printf ("1-minute: %f ", avg[0]); if (loads > 1) printf ("5-minute: %f ", avg[1]); if (loads > 2) printf ("15-minute: %f ", avg[2]); if (loads > 0) putchar ('\n'); if (naptime == 0) break; sleep (naptime); } exit (0); } #endif /* TEST */ cfengine-3.2.4/pub/clock_gettime.c0000644000175000017500000000246111707771422013775 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #include #ifdef HAVE_CONFIG_H #include "../src/conf.h" #endif #ifndef HAVE_CLOCKID_T typedef int clockid_t; #endif #if !HAVE_DECL_CLOCK_GETTIME int clock_gettime(clockid_t clock_id,struct timespec *tp); #endif int clock_gettime(clockid_t clock_id, struct timespec *tp) { tp->tv_sec = time(NULL); tp->tv_nsec = 0; return 0; } cfengine-3.2.4/pub/strlcpy.c0000644000175000017500000000312011707771422012655 00000000000000/* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */ /* * Copyright (c) 1998 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include size_t strlcpy(char *dst, const char *src, size_t siz); /* * Copy src to string dst of size siz. At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0). * Returns strlen(src); if retval >= siz, truncation occurred. */ size_t strlcpy(char *dst, const char *src, size_t siz) { char *d = dst; const char *s = src; size_t n = siz; /* Copy as many bytes as will fit */ if (n != 0) { while (--n != 0) { if ((*d++ = *s++) == '\0') break; } } /* Not enough room in dst, add NUL and traverse rest of src */ if (n == 0) { if (siz != 0) *d = '\0'; /* NUL-terminate dst */ while (*s++) ; } return(s - src - 1); /* count does not include NUL */ } cfengine-3.2.4/pub/strnlen.c0000644000175000017500000000220411707771422012644 00000000000000/* $OpenBSD: strnlen.c,v 1.3 2010/06/02 12:58:12 millert Exp $ */ /* * Copyright (c) 2010 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #if !HAVE_DECL_STRNLEN size_t strnlen(const char *str, size_t maxlen); #endif size_t strnlen(const char *str, size_t maxlen) { const char *cp; for (cp = str; maxlen != 0 && *cp != '\0'; cp++, maxlen--) ; return (size_t)(cp - str); } cfengine-3.2.4/pub/strdup.c0000644000175000017500000000241011715232734012474 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifdef HAVE_CONFIG_H #include "../src/conf.h" #endif #include #include #if !HAVE_DECL_STRDUP char *strdup(const char *str); #endif char *strdup(const char *str) { char *sp = malloc(strlen(str) + 1); if (str == NULL) { return NULL; } strcpy(sp, str); return sp; } cfengine-3.2.4/pub/getopt1.c0000644000175000017500000001046111707771422012546 00000000000000/* getopt_long and getopt_long_only entry points for GNU getopt. Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "getopt.h" #if !defined (__STDC__) || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #if defined (_LIBC) || !defined (__GNU_LIBRARY__) /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ #include #else char *getenv (); #endif #ifndef NULL #define NULL 0 #endif int getopt_long (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. If an option that starts with '-' (not '--') doesn't match a long option, but does match a short option, it is parsed as a short option instead. */ int getopt_long_only (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 1); } #endif /* _LIBC or not __GNU_LIBRARY__. */ #ifdef TEST #include int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; int option_index = 0; static struct option long_options[] = { {"add", 1, 0, 0}, {"append", 0, 0, 0}, {"delete", 1, 0, 0}, {"verbose", 0, 0, 0}, {"create", 0, 0, 0}, {"file", 1, 0, 0}, {0, 0, 0, 0} }; c = getopt_long (argc, argv, "abc:d:0123456789", long_options, &option_index); if (c == EOF) break; switch (c) { case 0: printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case 'd': printf ("option d with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ cfengine-3.2.4/pub/round.c0000644000175000017500000000262411707771422012314 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifdef HAVE_CONFIG_H #include "../src/conf.h" #endif #include #if !HAVE_DECL_ROUND double round(double x); #endif double round(double x) { if (x >= 0.0) { double y = floor(x); if (x - y >= 0.5) { return y + 1.0; } else { return y; } } else { double y = ceil(x); if (y - x >= 0.5) { return y - 1.0; } else { return y; } } } cfengine-3.2.4/pub/nanosleep.c0000644000175000017500000000275011707771422013151 00000000000000/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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 To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ /* * Emulating nanosleep(2) with select(3). * * NB! Does not calculate "remaining time" */ #ifdef HAVE_CONFIG_H #include "../src/conf.h" #endif #ifdef __MINGW32__ #include #include int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); int nanosleep(const struct timespec *rqtp, struct timespec *rmtp) { if (rmtp) { rmtp->tv_sec = 0; rmtp->tv_nsec = 0; } DWORD timeout = rqtp->tv_sec * 1000L + (rqtp->tv_nsec + 999999) / 1000000; Sleep(timeout); return 0; } #endif