# # Patch to improve password handling in ddclient-3.7.3 # Copyright (C) 2008 Astaro AG www.astaro.com # Author: Ingo Schwarze 30.09.2008 # # Originally posted on the ddclient-user mailing list # see http://permalink.gmane.org/gmane.network.dns.ddclient.user/18 # # This patch is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This patch is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with the ddclient program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, # or look up http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt . # Index: ddclient =================================================================== RCS file: /home/cvs/sources/d/ddclient/ddclient,v retrieving revision 1.1.1.2 diff -u -p -r1.1.1.2 ddclient --- ddclient 15 Sep 2008 11:13:55 -0000 1.1.1.2 +++ ddclient 30 Sep 2008 18:55:52 -0000 @@ -888,6 +888,7 @@ sub _read_config { local $lineno = 0; my $continuation = ''; + my %passwords = (); while () { s/[\r\n]//g; @@ -903,10 +904,17 @@ sub _read_config { } $content .= "$_\n" unless /^#/; - # lines contain passwords are a special case, we don't want to - # arbitrarily strip out '#' - if (/^(\S*password\S*)\s*=\s*(\S+)/i) { $_ = "$1=$2"; } - if (/^#/ || !(/password/i) || /#.*password/i) { s/#.*//; } # remove comments + + ## parsing passwords is special + if (/^([^#]*\s)?([^#]*?password\S*?)\s*=\s*('.*'|[^']\S*)(.*)/) { + my ($head, $key, $value, $tail) = ($1 || '', $2, $3, $4); + $value = $1 if $value =~ /^'(.*)'$/; + $passwords{$key} = $value; + $_ = "${head}${key}=dummy${tail}"; + } + + ## remove comments + s/#.*//; ## handle continuation lines $_ = "$continuation$_"; @@ -931,6 +939,7 @@ sub _read_config { ## verify that keywords are valid...and check the value foreach my $k (keys %locals) { + $locals{$k} = $passwords{$k} if defined $passwords{$k}; if (!exists $variables{'merged'}{$k}) { warning("unrecognized keyword '%s' (ignored)", $k); delete $locals{$k}; @@ -969,6 +978,7 @@ sub _read_config { $config{$h}{'host'} = $h; } } + %passwords = (); } close(FD);