From 163c70bab212b1a0cbc3d6e0a0c96bcfc0545088 Mon Sep 17 00:00:00 2001 From: Mark Burgess Date: Thu, 18 Jun 2009 17:16:52 +0000 Subject: [PATCH] Fix linker weirdness --- config.status | 5 +- docs/cf-agent.8 | 32 +++++----- docs/cf-execd.8 | 6 +- docs/cf-key.8 | 2 +- docs/cf-know.8 | 2 +- docs/cf-monitord.8 | 2 +- docs/cf-promises.8 | 2 +- docs/cf-report.8 | 2 +- docs/cf-runagent.8 | 2 +- docs/cf-serverd.8 | 2 +- inputs/Makefile | 2 +- src/agent.c | 1 - src/cf3.defs.h | 2 +- src/cf3.extern.h | 1 + src/cf3globals.c | 2 + src/conf.h | 2 +- src/enterprise_stubs.c | 12 ++++ src/generic_agent.c | 6 +- src/pipes.c | 4 +- src/prototypes3.h | 1 + tests/Makefile | 2 +- tests/file_masters/Makefile | 2 +- tests/file_operands/Makefile | 2 +- tests/units/Makefile | 2 +- tests/units/unit_update.cf | 116 ++++++++++++++++++++++++++++++----- 25 files changed, 159 insertions(+), 55 deletions(-) diff --git a/config.status b/config.status index 8761100349..ede2e587eb 100755 --- a/config.status +++ b/config.status @@ -489,7 +489,7 @@ FGREP='/usr/bin/grep -F' LD='/usr/x86_64-suse-linux/bin/ld -m elf_x86_64' NM='/usr/bin/nm -B' LN_S='ln -s' -max_cmd_len='3458764513820540925' +max_cmd_len='1572864' ac_objext='o' exeext='' lt_unset='unset' @@ -826,7 +826,7 @@ S["build"]="x86_64-unknown-linux-gnu" S["target_alias"]="" S["host_alias"]="" S["build_alias"]="" -S["LIBS"]="-lacl -lnss_nis -lpthread -lgvc -lpq -lmysqlclient -lrt -lpcre -lldap -lcfnova -lm -L../pub -lcfpub" +S["LIBS"]="-lacl -lnss_nis -lpthread -lgvc -lpq -lmysqlclient -lrt -lpcre -lldap -lm -L../pub -lcfpub" S["ECHO_T"]="" S["ECHO_N"]="-n" S["ECHO_C"]="" @@ -926,7 +926,6 @@ D["HAVE_DLFCN_H"]=" 1" D["LT_OBJDIR"]=" \".libs/\"" D["HAVE_GETLOADAVG"]=" 1" D["HAVE_LIBM"]=" 1" -D["HAVE_LIBCFNOVA"]=" 1" D["HAVE_LIBLDAP"]=" 1" D["USE_BERKELEY_DB"]=" 1" D["HAVE_LIBDB"]=" 1" diff --git a/docs/cf-agent.8 b/docs/cf-agent.8 index 0663c8c9cb..aedf6e2090 100644 --- a/docs/cf-agent.8 +++ b/docs/cf-agent.8 @@ -17,30 +17,32 @@ is a self-healing configuration and change management based system. You can thin 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 "--bootstrap, -B" +Bootstrap/repair a cfengine configuration from failsafe file in the current directory .IP "--debug, -d" value Set debugging level 0,1,2 -.IP "--verbose, -v" -Output verbose information about the behaviour of the agent +.IP "--define, -D" value +Define a list of comma separated classes to be defined at the start of execution +.IP "--diagnostic, -x" +Activate internal diagnostics (developers only) .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 "--bootstrap, -B" -Bootstrap/repair a cfengine configuration from failsafe file in the current directory .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 "--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 "--inform, -I" -Print basic information about changes made to the system, i.e. promises repaired -.IP "--diagnostic, -x" -Activate internal diagnostics (developers only) +.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 @@ -53,4 +55,4 @@ Community info: http://www.cfengine.org .pp Support services: http://www.cfengine.com .pp -This software is (C) 2008 Cfengine AS. +This software is (C) 2008- Cfengine AS. diff --git a/docs/cf-execd.8 b/docs/cf-execd.8 index 5e7c8319a3..d3e5b0543e 100644 --- a/docs/cf-execd.8 +++ b/docs/cf-execd.8 @@ -42,8 +42,10 @@ Print basic information about changes made to the system, i.e. promises repaired Activate internal diagnostics (developers only) .IP "--no-fork, -F" Run as a foreground processes (do not fork) -.IP "--ld-library-path, -L" value +.IP "--self-monitor, -s" Set the internal value of LD_LIBRARY_PATH for child processes +.IP "--ld-library-path, -L" value +(null) .SH AUTHOR Mark Burgess and Cfengine AS .SH INFORMATION @@ -56,4 +58,4 @@ Community info: http://www.cfengine.org .pp Support services: http://www.cfengine.com .pp -This software is (C) 2008 Cfengine AS. +This software is (C) 2008- Cfengine AS. diff --git a/docs/cf-key.8 b/docs/cf-key.8 index e41b2f8776..ab6585d87b 100644 --- a/docs/cf-key.8 +++ b/docs/cf-key.8 @@ -37,4 +37,4 @@ Community info: http://www.cfengine.org .pp Support services: http://www.cfengine.com .pp -This software is (C) 2008 Cfengine AS. +This software is (C) 2008- Cfengine AS. diff --git a/docs/cf-know.8 b/docs/cf-know.8 index f317df9370..658a22be91 100644 --- a/docs/cf-know.8 +++ b/docs/cf-know.8 @@ -57,4 +57,4 @@ Community info: http://www.cfengine.org .pp Support services: http://www.cfengine.com .pp -This software is (C) 2008 Cfengine AS. +This software is (C) 2008- Cfengine AS. diff --git a/docs/cf-monitord.8 b/docs/cf-monitord.8 index 6d13f42502..c5cb1f7579 100644 --- a/docs/cf-monitord.8 +++ b/docs/cf-monitord.8 @@ -55,4 +55,4 @@ Community info: http://www.cfengine.org .pp Support services: http://www.cfengine.com .pp -This software is (C) 2008 Cfengine AS. +This software is (C) 2008- Cfengine AS. diff --git a/docs/cf-promises.8 b/docs/cf-promises.8 index 76720b8ed1..98b5cc47b3 100644 --- a/docs/cf-promises.8 +++ b/docs/cf-promises.8 @@ -53,4 +53,4 @@ Community info: http://www.cfengine.org .pp Support services: http://www.cfengine.com .pp -This software is (C) 2008 Cfengine AS. +This software is (C) 2008- Cfengine AS. diff --git a/docs/cf-report.8 b/docs/cf-report.8 index 911f5805a9..6ddadf88b6 100644 --- a/docs/cf-report.8 +++ b/docs/cf-report.8 @@ -67,4 +67,4 @@ Community info: http://www.cfengine.org .pp Support services: http://www.cfengine.com .pp -This software is (C) 2008 Cfengine AS. +This software is (C) 2008- Cfengine AS. diff --git a/docs/cf-runagent.8 b/docs/cf-runagent.8 index 01abfc8ca0..ac553585c0 100644 --- a/docs/cf-runagent.8 +++ b/docs/cf-runagent.8 @@ -56,4 +56,4 @@ Community info: http://www.cfengine.org .pp Support services: http://www.cfengine.com .pp -This software is (C) 2008 Cfengine AS. +This software is (C) 2008- Cfengine AS. diff --git a/docs/cf-serverd.8 b/docs/cf-serverd.8 index 52856bd400..4c698a60a5 100644 --- a/docs/cf-serverd.8 +++ b/docs/cf-serverd.8 @@ -57,4 +57,4 @@ Community info: http://www.cfengine.org .pp Support services: http://www.cfengine.com .pp -This software is (C) 2008 Cfengine AS. +This software is (C) 2008- Cfengine AS. diff --git a/inputs/Makefile b/inputs/Makefile index 464f626ecb..a3842a620d 100644 --- a/inputs/Makefile +++ b/inputs/Makefile @@ -93,7 +93,7 @@ LEX = flex LEXLIB = -lfl LEX_OUTPUT_ROOT = lex.yy LIBOBJS = -LIBS = -lacl -lnss_nis -lpthread -lgvc -lpq -lmysqlclient -lrt -lpcre -lldap -lcfnova -lm -L../pub -lcfpub +LIBS = -lacl -lnss_nis -lpthread -lgvc -lpq -lmysqlclient -lrt -lpcre -lldap -lm -L../pub -lcfpub LIBTOOL = $(SHELL) $(top_builddir)/libtool LIB_SELINUX = LIPO = diff --git a/src/agent.c b/src/agent.c index bacf4907de..d7c5750983 100644 --- a/src/agent.c +++ b/src/agent.c @@ -79,7 +79,6 @@ void SetEnvironment(char *s); extern struct BodySyntax CFA_CONTROLBODY[]; extern struct Rlist *SERVERLIST; -char POLICY_SERVER[CF_BUFSIZE]; /*******************************************************************/ /* Command line options */ diff --git a/src/cf3.defs.h b/src/cf3.defs.h index 2724b9f7f3..6924fde1f4 100644 --- a/src/cf3.defs.h +++ b/src/cf3.defs.h @@ -72,7 +72,7 @@ #define CF_INBUNDLE 2 #define CF_MAX_NESTING 3 -#define CF_DONEPASSES 3 +#define CF_DONEPASSES 4 #define CF_TIME_SIZE 32 diff --git a/src/cf3.extern.h b/src/cf3.extern.h index 10e2c71b93..d535f9d961 100644 --- a/src/cf3.extern.h +++ b/src/cf3.extern.h @@ -30,6 +30,7 @@ extern struct PromiseParser P; extern int REQUIRE_COMMENTS; +extern char POLICY_SERVER[CF_BUFSIZE]; extern struct Bundle *BUNDLES; extern struct Body *BODIES; diff --git a/src/cf3globals.c b/src/cf3globals.c index 85e0c5d601..4a13a18918 100644 --- a/src/cf3globals.c +++ b/src/cf3globals.c @@ -113,6 +113,8 @@ int LASTSEEN = true; struct Topic *TOPIC_MAP = NULL; +char POLICY_SERVER[CF_BUFSIZE]; + /*****************************************************************************/ /* Constants */ /*****************************************************************************/ diff --git a/src/conf.h b/src/conf.h index 2e0e55a727..3415ae37a0 100644 --- a/src/conf.h +++ b/src/conf.h @@ -177,7 +177,7 @@ /* #undef HAVE_LIBCFGALAXY */ /* Define to 1 if you have the `cfnova' library (-lcfnova). */ -#define HAVE_LIBCFNOVA 1 +/* #undef HAVE_LIBCFNOVA */ /* Define to 1 if you have the `crypto' library (-lcrypto). */ #define HAVE_LIBCRYPTO 1 diff --git a/src/enterprise_stubs.c b/src/enterprise_stubs.c index fae1fd779b..6b7873ebec 100644 --- a/src/enterprise_stubs.c +++ b/src/enterprise_stubs.c @@ -101,6 +101,18 @@ void CheckAutoBootstrap() /*****************************************************************************/ +char *GetConsolePrefix() + +{ +#ifdef HAVE_LIBCFNOVA + return "nova>"; +#else + return "cf3"; +#endif +} + +/*****************************************************************************/ + void StartTwin(int argc,char **argv) /* Self-monitor in case of crash or binary change */ diff --git a/src/generic_agent.c b/src/generic_agent.c index 7c82dd4b3b..bbc5e42410 100644 --- a/src/generic_agent.c +++ b/src/generic_agent.c @@ -35,7 +35,6 @@ extern FILE *yyin; extern char *CFH[][2]; extern void CheckOpts(int argc,char **argv); -extern char POLICY_SERVER[CF_BUFSIZE]; /*****************************************************************************/ @@ -267,7 +266,8 @@ strcpy(FILE_SEPARATOR_STR,"/"); #endif NewClass("any"); -strcpy(VPREFIX,"cf3"); + +strcpy(VPREFIX,GetConsolePrefix()); if (VERBOSE) { @@ -1556,7 +1556,7 @@ printf(".pp\nThis software is (C) 2008- Cfengine AS.\n"); void Version(char *component) { -printf("This is %s version %s - Free software %s%s\n",component,VERSION,CF3COPYRIGHT,VYEAR); +printf("This is %s core community version %s - %s%s\n",component,VERSION,CF3COPYRIGHT,VYEAR); EnterpriseVersion(); } diff --git a/src/pipes.c b/src/pipes.c index 60b994c195..db2c95d40d 100644 --- a/src/pipes.c +++ b/src/pipes.c @@ -781,6 +781,7 @@ while(waitpid(pid,&status,0) < 0) if (status == 0) { Debug(" -> Finished script %s ok\n",pp->promiser); + cfPS(cf_verbose,CF_CHG,"",pp,a," !! Finished script - succeeded %s\n",pp->promiser); } else { @@ -800,7 +801,6 @@ while ((wait_result = wait(&status)) != pid) } } - if (WIFSIGNALED(status)) { cfPS(cf_inform,CF_INTERPT,"",pp,a," -> Finished script - interrupted %s\n",pp->promiser); @@ -815,7 +815,7 @@ if (!WIFEXITED(status)) if (WEXITSTATUS(status) == 0) { - Debug(" -> Finished script %s ok\n",pp->promiser); + cfPS(cf_verbose,CF_CHG,"",pp,a," !! Finished script - succeeded %s\n",pp->promiser); } else { diff --git a/src/prototypes3.h b/src/prototypes3.h index 79cca69cd6..23006fd4cd 100644 --- a/src/prototypes3.h +++ b/src/prototypes3.h @@ -284,6 +284,7 @@ int IsProcessType(char *s); int IsEnterprise(void); void EnterpriseVersion(void); int EnterpriseExpiry(char *day,char *month,char *year); +char *GetConsolePrefix(void); char *MailSubject(void); void CheckAutoBootstrap(void); void StartTwin(int argc,char **argv); diff --git a/tests/Makefile b/tests/Makefile index 3f84848953..75b59b1f05 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -101,7 +101,7 @@ LEX = flex LEXLIB = -lfl LEX_OUTPUT_ROOT = lex.yy LIBOBJS = -LIBS = -lacl -lnss_nis -lpthread -lgvc -lpq -lmysqlclient -lrt -lpcre -lldap -lcfnova -lm -L../pub -lcfpub +LIBS = -lacl -lnss_nis -lpthread -lgvc -lpq -lmysqlclient -lrt -lpcre -lldap -lm -L../pub -lcfpub LIBTOOL = $(SHELL) $(top_builddir)/libtool LIB_SELINUX = LIPO = diff --git a/tests/file_masters/Makefile b/tests/file_masters/Makefile index 48eb8ef73f..ca6be13cfe 100644 --- a/tests/file_masters/Makefile +++ b/tests/file_masters/Makefile @@ -99,7 +99,7 @@ LEX = flex LEXLIB = -lfl LEX_OUTPUT_ROOT = lex.yy LIBOBJS = -LIBS = -lacl -lnss_nis -lpthread -lgvc -lpq -lmysqlclient -lrt -lpcre -lldap -lcfnova -lm -L../pub -lcfpub +LIBS = -lacl -lnss_nis -lpthread -lgvc -lpq -lmysqlclient -lrt -lpcre -lldap -lm -L../pub -lcfpub LIBTOOL = $(SHELL) $(top_builddir)/libtool LIB_SELINUX = LIPO = diff --git a/tests/file_operands/Makefile b/tests/file_operands/Makefile index d72b74c624..23409cbeb0 100644 --- a/tests/file_operands/Makefile +++ b/tests/file_operands/Makefile @@ -99,7 +99,7 @@ LEX = flex LEXLIB = -lfl LEX_OUTPUT_ROOT = lex.yy LIBOBJS = -LIBS = -lacl -lnss_nis -lpthread -lgvc -lpq -lmysqlclient -lrt -lpcre -lldap -lcfnova -lm -L../pub -lcfpub +LIBS = -lacl -lnss_nis -lpthread -lgvc -lpq -lmysqlclient -lrt -lpcre -lldap -lm -L../pub -lcfpub LIBTOOL = $(SHELL) $(top_builddir)/libtool LIB_SELINUX = LIPO = diff --git a/tests/units/Makefile b/tests/units/Makefile index 49389c1208..bbe41377f1 100644 --- a/tests/units/Makefile +++ b/tests/units/Makefile @@ -99,7 +99,7 @@ LEX = flex LEXLIB = -lfl LEX_OUTPUT_ROOT = lex.yy LIBOBJS = -LIBS = -lacl -lnss_nis -lpthread -lgvc -lpq -lmysqlclient -lrt -lpcre -lldap -lcfnova -lm -L../pub -lcfpub +LIBS = -lacl -lnss_nis -lpthread -lgvc -lpq -lmysqlclient -lrt -lpcre -lldap -lm -L../pub -lcfpub LIBTOOL = $(SHELL) $(top_builddir)/libtool LIB_SELINUX = LIPO = diff --git a/tests/units/unit_update.cf b/tests/units/unit_update.cf index 98ed44f1b3..19d94f0435 100644 --- a/tests/units/unit_update.cf +++ b/tests/units/unit_update.cf @@ -1,41 +1,127 @@ +#cop update,example +#cop What should a failsafe and update file contain?,example -bundle agent update +# 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" - perms => system, - copy_from => mycopy("/masterfiles/cfengine_inputs","gold_source.domain.tld"), - depth_search => recurse("inf"); + 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 perms system +body action logme(x) +{ +log_repaired => "stdout"; +logstring => " -> Started the $(x) (success)"; +} + +############################################ + +body perms u_p(p) { -mode => "0600"; +mode => "$(p)"; } -######################################################### +############################################# -body depth_search recurse(d) +body copy_from u_scp(from) { -depth => "$(d)"; +source => "$(from)"; +compare => "digest"; +trustkey => "true"; + +!policy_host:: + +servers => { "$(policy_server)" }; } ######################################################### -body copyfrom mycopy(from,server) +body action immediate +{ +ifelapsed => "1"; +} + +############################################ + +body depth_search u_recurse(d) { -source => "$(from)"; -servers => { "$(server)" , "failover.domain.tld" }; -#backup => "true"; -#trustkey => "true"; -encrypt => "true"; +depth => "$(d)"; }