Changeset 13796
- Timestamp:
- 01/23/12 19:00:19 (4 weeks ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
UnitTestContrib/test/unit/FoswikiFnTestCase.pm (modified) (1 diff)
-
UnitTestContrib/test/unit/RegisterTests.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/Htpasswd/FileName.pm (modified) (1 diff)
-
core/lib/Foswiki/Contrib/core/MANIFEST (modified) (1 diff)
-
core/lib/Foswiki/UI/Register.pm (modified) (4 diffs)
-
core/lib/Foswiki/Users/ApacheHtpasswdUser.pm (modified) (1 diff)
-
core/lib/Foswiki/Users/HtPasswdUser.pm (modified) (1 diff)
-
core/lib/Foswiki/Users/Password.pm (modified) (1 diff)
-
core/templates/messages.tmpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/UnitTestContrib/test/unit/FoswikiFnTestCase.pm
r13752 r13796 66 66 $Foswiki::cfg{RCS}{AutoAttachPubFiles} = 0; 67 67 $Foswiki::cfg{Register}{AllowLoginName} = 1; 68 $Foswiki::cfg{Htpasswd}{FileName} = "$Foswiki::cfg{WorkingDir}/htpasswd"; 69 $Foswiki::cfg{PasswordManager} = 'Foswiki::Users::HtPasswdUser'; 68 $Foswiki::cfg{Htpasswd}{FileName} = "$Foswiki::cfg{WorkingDir}/htpasswd"; 69 unless (-e $Foswiki::cfg{Htpasswd}{FileName} ) { 70 my $fh; 71 open($fh, ">", $Foswiki::cfg{Htpasswd}{FileName}) || die $!; 72 close($fh) || die $!; 73 } 74 $Foswiki::cfg{PasswordManager} = 'Foswiki::Users::HtPasswdUser'; 70 75 $Foswiki::cfg{Htpasswd}{GlobalCache} = 0; 71 $Foswiki::cfg{UserMappingManager} = 'Foswiki::Users::TopicUserMapping';72 $Foswiki::cfg{LoginManager} = 'Foswiki::LoginManager::TemplateLogin';76 $Foswiki::cfg{UserMappingManager} = 'Foswiki::Users::TopicUserMapping'; 77 $Foswiki::cfg{LoginManager} = 'Foswiki::LoginManager::TemplateLogin'; 73 78 $Foswiki::cfg{Register}{EnableNewUserRegistration} = 1; 74 79 $Foswiki::cfg{RenderLoggedInButUnknownUsers} = 0; -
trunk/UnitTestContrib/test/unit/RegisterTests.pm
r13791 r13796 1246 1246 1247 1247 $query->path_info( '/' . $this->{users_web} . '/WebHome' ); 1248 unlink $Foswiki::cfg{Htpasswd}{FileName}; 1248 my $fh; 1249 open($fh, ">", $Foswiki::cfg{Htpasswd}{FileName}) || die $!; 1250 close($fh) || die $!; 1249 1251 1250 1252 $this->createNewFoswikiSession( $Foswiki::cfg{DefaultUserLogin}, $query ); -
trunk/core/lib/Foswiki/Configure/Checkers/Htpasswd/FileName.pm
r13286 r13796 24 24 Foswiki::Configure::Load::expandValue($f); 25 25 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 } 35 44 36 45 return $e; -
trunk/core/lib/Foswiki/Contrib/core/MANIFEST
r13524 r13796 483 483 lib/Foswiki/Configure/Checkers/Htpasswd/Encoding.pm 0444 484 484 lib/Foswiki/Configure/Checkers/Htpasswd/FileName.pm 0444 485 lib/Foswiki/Configure/Checkers/Htpasswd/LockFileName.pm 0444 485 486 lib/Foswiki/Configure/Checkers/HttpCompress.pm 0444 486 487 lib/Foswiki/Configure/Checkers/Introduction.pm 0444 -
trunk/core/lib/Foswiki/UI/Register.pm
r13643 r13796 101 101 } 102 102 elsif ( $action eq 'resetPassword' ) { 103 if ( !$session->inContext("passwords_modifyable") ) { 104 throw Foswiki::OopsException( 105 'attention', 106 web => $session->{webName}, 107 topic => $session->{topicName}, 108 def => 'passwords_disabled' 109 ); 110 } 103 111 require Foswiki::UI::Passwords; 104 112 Foswiki::UI::Passwords::resetpasswd($session); … … 287 295 my $cUID = $users->addUser( 288 296 $row->{LoginName}, $row->{WikiName}, 289 $row->{Password}, $row->{Email} 297 $session->inContext("passwords_modifyable") ? $row->{Password} : undef, 298 $row->{Email} 290 299 ); 291 300 $log .= … … 837 846 my $users = $session->{users}; 838 847 try { 839 unless ( defined( $data->{Password} ) ) { 848 unless ( !$session->inContext("passwords_modifyable") || 849 defined( $data->{Password} ) ) { 840 850 841 851 # SMELL: should give consideration to disabling … … 855 865 my $cUID = $users->addUser( 856 866 $data->{LoginName}, $data->{WikiName}, 857 $data->{Password}, $data->{Email} 867 $session->inContext("passwords_modifyable") ? $data->{Password} : undef, 868 $data->{Email} 858 869 ); 859 870 my $log = _createUserTopic( $session, $data ); -
trunk/core/lib/Foswiki/Users/ApacheHtpasswdUser.pm
r12236 r13796 121 121 my $path = $Foswiki::cfg{Htpasswd}{FileName}; 122 122 123 #TODO: what if the data dir is also read only? 124 if ( ( !-e $path ) || ( -e $path && -r $path && !-d $path && -w $path ) ) { 125 $this->{session}->enterContext('passwords_modifyable'); 126 return 0; 127 } 123 # We expect the path to exist and be writable. 124 return 0 if ( -e $path && -f $path && -w $path ); 125 126 # Otherwise, log a problem. 127 $this->{session}->logger->log( 128 'warning', 129 'The password file does not exist or cannot be written.' . 130 'Run =configure= and check the setting of {Htpasswd}{FileName}.' . 131 ' New user registration has been disabled until this is corrected.'); 132 # And disable registration (and password changes) 133 $Foswiki::cfg{Register}{EnableNewUserRegistration} = 0; 128 134 return 1; 129 135 } -
trunk/core/lib/Foswiki/Users/HtPasswdUser.pm
r13756 r13796 162 162 my $path = $Foswiki::cfg{Htpasswd}{FileName}; 163 163 164 #TODO: what if the data dir is also read only? 165 if ( ( !-e $path ) || ( -e $path && -r $path && !-d $path && -w $path ) ) { 166 $this->{session}->enterContext('passwords_modifyable'); 167 return 0; 168 } 164 # We expect the path to exist and be writable. 165 return 0 if ( -e $path && -f $path && -w $path ); 166 167 # Otherwise, log a problem. 168 $this->{session}->logger->log( 169 'warning', 170 'The password file does not exist or cannot be written.' . 171 'Run =configure= and check the setting of {Htpasswd}{FileName}.' . 172 ' New user registration has been disabled until this is corrected.'); 173 # And disable registration (which will also disable password changes) 174 $Foswiki::cfg{Register}{EnableNewUserRegistration} = 0; 175 169 176 return 1; 170 177 } -
trunk/core/lib/Foswiki/Users/Password.pm
r7452 r13796 57 57 58 58 returns true if the password database is not currently modifyable 59 also needs to call 60 $this->{session}->enter_context('passwords_modifyable'); 59 also needs to set $this->{session}->enter_context('passwords_modifyable'); 61 60 if you want to be able to use the existing TopicUserMappingContrib ChangePassword topics 62 61 -
trunk/core/templates/messages.tmpl
r13655 r13796 170 170 171 171 %MAKETEXT{"You have *not* been registered."}% 172 %TMPL:END% 173 %TMPL:DEF{"passwords_disabled"}% 174 ---+++ %MAKETEXT{"Passwords disabled"}% 175 176 %MAKETEXT{"The Administrator has disabled password changes."}% 177 178 %MAKETEXT{"Please contact [_1]." args="%WIKIWEBMASTER%"}% 179 180 %MAKETEXT{"Your password has not been changed."}% 172 181 %TMPL:END% 173 182 %TMPL:DEF{"thanks"}%
Note: See TracChangeset
for help on using the changeset viewer.
