Commit ab6eaae1 authored by Yuanle Song's avatar Yuanle Song
Browse files

bugfix: fatal_err wrap printf with double quotes. use echo -e to translate \n

parent 57bb3db2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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.
+6 −6
Original line number Diff line number Diff line
@@ -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