Skip to content

Commit

Permalink
Fixes #18722: Accept port in policy_server.dat for agent commands
Browse files Browse the repository at this point in the history
  • Loading branch information
peckpeck committed Jan 27, 2021
1 parent ca997bb commit 16e139a
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions share/commands/agent-health
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ fi
# test policy server value if it's not an ip
if ! egrep "^[0-9.]+$|^[0-9a-fA-F:]+$" "${CFE_DIR}/policy_server.dat">/dev/null; then
if type getent >/dev/null 2>/dev/null; then
cat "${CFE_DIR}/policy_server.dat" | xargs getent hosts > /dev/null
cut -d: -f1 "${CFE_DIR}/policy_server.dat" | xargs getent hosts > /dev/null
else
cat "${CFE_DIR}/policy_server.dat" | xargs host > /dev/null 2> /dev/null
cut -d: -f1 "${CFE_DIR}/policy_server.dat" | xargs host > /dev/null 2> /dev/null
fi
if [ $? -ne 0 ]
then
Expand Down
3 changes: 2 additions & 1 deletion share/commands/remote-run
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
. "${BASEDIR}/../lib/cfengine_parsing.sh"
. "${BASEDIR}/../lib/api_call.sh"

PORT=5309
PORT=$(cut -d: -s -f2 "${RUDDER_VAR}/cfengine-community/policy_server.dat")
PORT=${PORT:-5309}
LOOP="xargs -I{}"
DELIM=""
MULTIHOST=1
Expand Down
3 changes: 2 additions & 1 deletion share/commands/server-debug
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
. "${BASEDIR}/../lib/common.sh"

DEBUG_PORT=5310
SERVER_PORT=5309
SERVER_PORT=$(cut -d: -s -f2 "${RUDDER_VAR}/cfengine-community/policy_server.dat")
SERVER_PORT=${SERVER_PORT:-5309}

set -e

Expand Down
2 changes: 1 addition & 1 deletion share/lib/api_call.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ full_api_call() {
url=`_get_conf "${conf}" "url"`
if [ -z "${url}" ]
then
host=`cat /var/rudder/cfengine-community/policy_server.dat 2>/dev/null`
host=`cut -d: -f1 /var/rudder/cfengine-community/policy_server.dat 2>/dev/null`
[ -z "${host}" ] && host="localhost"
url="https://${host}/rudder"
fi
Expand Down
3 changes: 0 additions & 3 deletions share/lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ DEBUG_CLASS="-D trace"
VERBOSE_CLASS="-D debug"
INFO_CLASS="-D info"

# Default port for bootstrap
BOOTSTRAP_PORT=5309

# Reset colors
clear_colors() {
COLOR=""
Expand Down
2 changes: 1 addition & 1 deletion share/lib/report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [ -f "${RUDDER_JSON}" ]; then
DAVPW=$(rudder_json_value 'DAVPASSWORD')
fi

SERVER=$(cat "${RUDDER_VAR}/cfengine-community/policy_server.dat")
SERVER=$(cut -d: -f1 "${RUDDER_VAR}/cfengine-community/policy_server.dat")
TMP_REPORTS_DIR="/var/rudder/tmp/reports/"
REPORTS_DIR="/var/rudder/reports/ready/"

Expand Down

0 comments on commit 16e139a

Please sign in to comment.