1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

Changeset 105

Show
Ignore:
Timestamp:
11/19/08 21:09:07 (5 years ago)
Author:
wimpunk
Message:

Added better password handling sended by Ingo Schwarze

Location:
trunk
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ddclient

    r103 r105  
    938938    local $lineno       = 0; 
    939939    my    $continuation = ''; 
     940    my    %passwords    = (); 
    940941    while (<FD>) { 
    941942        s/[\r\n]//g; 
     
    953954 
    954955    $content .= "$_\n" unless /^#/; 
    955     # lines contain passwords are a special case, we don't want to 
    956     # arbitrarily strip out '#' 
    957     if (/^(\S*password\S*)\s*=\s*(\S+)/i) { $_ = "$1=$2"; } 
    958     if (/^#/ || !(/password/i) || /#.*password/i) { s/#.*//; } # remove comments 
     956 
     957        ## parsing passwords is special 
     958        if (/^([^#]*\s)?([^#]*?password\S*?)\s*=\s*('.*'|[^']\S*)(.*)/) { 
     959            my ($head, $key, $value, $tail) = ($1 || '', $2, $3, $4); 
     960            $value = $1 if $value =~ /^'(.*)'$/; 
     961            $passwords{$key} = $value; 
     962            $_ = "${head}${key}=dummy${tail}"; 
     963        } 
     964 
     965        ## remove comments 
     966        s/#.*//; 
    959967 
    960968        ## handle continuation lines 
     
    981989        ## verify that keywords are valid...and check the value 
    982990        foreach my $k (keys %locals) { 
     991            $locals{$k} = $passwords{$k} if defined $passwords{$k}; 
    983992            if (!exists $variables{'merged'}{$k}) { 
    984993            warning("unrecognized keyword '%s' (ignored)", $k); 
     
    10191028            } 
    10201029        } 
     1030        %passwords = (); 
    10211031    } 
    10221032    close(FD);