From ab6eaae1e5da28ca0f9da50ede4914090d575273 Mon Sep 17 00:00:00 2001 From: Yuanle Song Date: Sun, 27 May 2012 16:07:31 +0800 Subject: [PATCH] bugfix: fatal_err wrap printf with double quotes. use echo -e to translate \n --- changelog | 1 + src/bin/ddclient-http | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/changelog b/changelog index 74d060d..ef8ad1f 100644 --- a/changelog +++ b/changelog @@ -11,5 +11,6 @@ Time-stamp: <2012-05-27> - only update when IP is different from last successful update. - send email to EMAIL and FATAL_ERROR_EMAIL. - check IP is a valid public IP. + - check config is valid. * v0.1.0 - init version. was used to update sylecn01.dnsd.me. diff --git a/src/bin/ddclient-http b/src/bin/ddclient-http index 26ff4bc..2443dfd 100755 --- a/src/bin/ddclient-http +++ b/src/bin/ddclient-http @@ -40,7 +40,7 @@ log() { # Usage: err [MESSAGE..] err() { logger -t ddclient_http -p user.err "$@" - echo "$@" | mail -s "ddclient-http Error" ${EMAIL:-root@localhost} + echo -e "$@" | mail -s "ddclient-http Error" ${EMAIL:-root@localhost} } # Usage: fatal_err [MESSAGE..] @@ -48,7 +48,7 @@ err() { # it's set in config file. fatal_err() { err "$@" - test -z "$FATAL_ERROR_EMAIL" || echo "$@" | mail -s "ddclient-http FATAL Error" "$FATAL_ERROR_EMAIL" + test -z "$FATAL_ERROR_EMAIL" || echo -e "$@" | mail -s "ddclient-http FATAL Error" "$FATAL_ERROR_EMAIL" } # which host to update and it's credentials. @@ -58,16 +58,16 @@ if [ -f "$CONFIG_FILE" ]; then # check that config file is valid. msgs="" if [ -z "$HOSTNAME" -o -z "$USERNAME" -o -z "$PASSWORD" ]; then - msg=$msg"Error: HOSTNAME, USERNAME, or PASSWORD is not set.\n" + msg=$msg"HOSTNAME, USERNAME, or PASSWORD is not set.\n" fi if [ `echo -n "$USERNAME" | wc -m` -gt 24 ]; then - msg=$msg"Error: USERNAME should be less than 24 characters.\n" + msg=$msg"USERNAME should be less than 24 characters.\n" fi if [ `echo -n "$PASSWORD" | wc -m` -gt 24 ]; then - msg=$msg"Error: PASSWORD should be less than 24 characters.\n" + msg=$msg"PASSWORD should be less than 24 characters.\n" fi if [ -n "$msg" ]; then - fatal_err `printf "Error: Bad config file. $msg"` + fatal_err "`printf "Error: Bad config file.\n$msg"`" exit $BAD_CONF fi else -- GitLab