From 6afec722329c296eeb772dc96a1b2ed8d018fce9 Mon Sep 17 00:00:00 2001 From: Jake Guffey Date: Fri, 21 Sep 2012 10:06:16 -0400 Subject: [PATCH] Implement Nico's suggestions Modified behavior of cksum explorer to print nothing if the file doesn't exist Modified gencode-local to reflect cksum's new behavior Modified gencode-remote to check states explicitly and error on invalid state. --- conf/type/__pf_ruleset/explorer/cksum | 2 -- conf/type/__pf_ruleset/gencode-local | 2 +- conf/type/__pf_ruleset/gencode-remote | 28 ++++++++++++++------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/conf/type/__pf_ruleset/explorer/cksum b/conf/type/__pf_ruleset/explorer/cksum index ce188ba0..f8679836 100755 --- a/conf/type/__pf_ruleset/explorer/cksum +++ b/conf/type/__pf_ruleset/explorer/cksum @@ -34,8 +34,6 @@ PFCONF="${TMP:-"/etc/pf.conf"}" if [ -f "${PFCONF}" ]; then # The pf config file exists, find its cksum. cksum -o 1 ${PFCONF} | cut -d= -f2 | awk '{print $1}' -else # the pf config file doesn't exist - echo NOTEXIST fi # Debug diff --git a/conf/type/__pf_ruleset/gencode-local b/conf/type/__pf_ruleset/gencode-local index b1ee6a14..c2495509 100644 --- a/conf/type/__pf_ruleset/gencode-local +++ b/conf/type/__pf_ruleset/gencode-local @@ -59,7 +59,7 @@ case $uname in ;; esac -if [ ! "${cksum}" = "NOTEXIST" ]; then +if [ -n "${cksum}" ]; then if [ ! "\${currentSum}" = "${cksum}" ]; then $__remote_copy "${source}" "$__target_host:${rcvar}.new" fi diff --git a/conf/type/__pf_ruleset/gencode-remote b/conf/type/__pf_ruleset/gencode-remote index e5eece64..6e9030ea 100644 --- a/conf/type/__pf_ruleset/gencode-remote +++ b/conf/type/__pf_ruleset/gencode-remote @@ -28,20 +28,22 @@ # Remove ${rcvar} in the case of --state absent state=$(cat "$__object/parameter/state") - -if [ ! "$state" = "absent" ]; then # There is nothing more for a *remote* script to do - exit 0 -fi - rcvar=$(cat "$__object/explorer/rcvar") -# --state absent, so ensure that .new doesn't exist and that conf is renamed to .old -cat <&2 + exit 1 +fi