Ignore:
Timestamp:
01/23/12 19:00:19 (4 months ago)
Author:
CrawfordCurrie
Message:

Item11458: simplify and streamline handling of password file; it now must exist for Foswiki to run, and will be created by =configure= if not. This lets us do enhanced checking in =configure= while reducing the runtime burden.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/lib/Foswiki/Configure/Checkers/Htpasswd/FileName.pm

    r13286 r13796  
    2424    Foswiki::Configure::Load::expandValue($f); 
    2525 
    26     return $e 
    27       . $this->WARN( 
    28 "file $f is not found.  This may be normal for a new installation.  it will be created when the first user registers to the site" 
    29       ) unless ( -f $f ); 
    30  
    31     return $e 
    32       . $this->ERROR( 
    33 "$f is not writable.  User registration will be disabled until this is corrected." 
    34       ) unless ( -w $f ); 
     26    unless ( -e $f ) { 
     27        # password file does not exist; check it can be created 
     28        my $fh; 
     29        if (!open($fh, ">", $f) || !close($fh)) { 
     30            return $e . $this->ERROR("Password file $f does not exist and could not be created: $!"); 
     31        } else { 
     32            $e .= $this->NOTE("A new password file $f has been created."); 
     33            unless (chmod(0600, $f)) { 
     34                $e .= $this->WARN("Permissions could not be changed on the new password file $f") 
     35            } 
     36        } 
     37    } elsif ( !( -f $f && -w $f )) { 
     38        # password file exists but is not writable 
     39        return $e 
     40            . $this->ERROR( 
     41            "$f is not a writable plain file. " 
     42            . "User registration will be disabled until this is corrected.") 
     43    } 
    3544 
    3645    return $e; 
Note: See TracChangeset for help on using the changeset viewer.