Skip to content

Commit

Permalink
Item9164: Item10999: Works on OSX now
Browse files Browse the repository at this point in the history
Also Apache::Htpasswd v1.8 appears to not actually support plain text
passwords - so removing that feature.

git-svn-id: http://svn.foswiki.org/branches/Release01x01@12227 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Jul 25, 2011
1 parent 236264d commit ec6fe4d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
13 changes: 7 additions & 6 deletions UnitTestContrib/test/unit/PasswordTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,6 @@ sub dumpFile {
sub test_htpasswd_crypt_md5 {
my $this = shift;

if ( $Foswiki::cfg{DetailedOS} eq 'darwin' ) {
$this->expect_failure();
$this->annotate("CANNOT RUN crypt-md5 TESTS on OSX");
}

$Foswiki::cfg{Htpasswd}{Encoding} = 'crypt-md5';
my $impl = new Foswiki::Users::HtPasswdUser( $this->{session} );
$this->assert($impl);
Expand Down Expand Up @@ -451,6 +446,7 @@ sub test_htpasswd_apache_md5 {
sub test_ApacheHtpasswdUser_md5 {
my $this = shift;

$Foswiki::cfg{Htpasswd}{AutoDetect} = 0;
$Foswiki::cfg{Htpasswd}{Encoding} = 'apache-md5';
eval "use Foswiki::Users::ApacheHtpasswdUser";
if ($@) {
Expand Down Expand Up @@ -483,6 +479,7 @@ sub test_ApacheHtpasswdUser_crypt {
$this->annotate("CANNOT RUN ApacheHtpasswdUser_crypt TESTS on Windows");
}

$Foswiki::cfg{Htpasswd}{AutoDetect} = 0;
$Foswiki::cfg{Htpasswd}{Encoding} = 'crypt';
eval "use Foswiki::Users::ApacheHtpasswdUser";
if ($@) {
Expand All @@ -506,9 +503,13 @@ sub test_ApacheHtpasswdUser_crypt {
}
}

sub test_ApacheHtpasswdUser_plain {
# SMELL: Apache;:Htpasswd Version 1.8 doesn't appear to actually support writing
# plain text passwords. So this test will fail. The htpasswd file has
# encrypted passwords regardless of 'plain' setting.
sub DISABLE_test_ApacheHtpasswdUser_plain {
my $this = shift;

$Foswiki::cfg{Htpasswd}{AutoDetect} = 0;
$Foswiki::cfg{Htpasswd}{Encoding} = 'plain';
eval "use Foswiki::Users::ApacheHtpasswdUser";
if ($@) {
Expand Down
8 changes: 2 additions & 6 deletions core/lib/Foswiki/Configure/Checkers/Htpasswd/Encoding.pm
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ sub check {
}

if ( $Foswiki::cfg{Htpasswd}{AutoDetect} || $enc eq 'crypt-md5' ) {
if ( $Foswiki::cfg{DetailedOS} eq 'darwin' ) {
$e .=
$this->ERROR("ERROR: crypt-md5 FAILS on OSX (no fix in 2008)");
}
use Config;
if ( $Config{myuname} =~ /strawberry/i ) {
my $n = $this->checkPerlModule(
Expand All @@ -109,12 +105,12 @@ sub check {
}
}

if ( $enc ne 'crypt'
if ( $enc ne 'crypt' && $enc ne 'apache-md5'
&& $Foswiki::cfg{PasswordManager} eq
'Foswiki::Users::ApacheHtpasswdUser' )
{
$e .= $this->ERROR(
"PasswordManager ApacheHtpasswdUser only supports crypt encryption. Use HtPasswdUser for other Encoding types."
"PasswordManager ApacheHtpasswdUser only supports crypt and apache-md5 encryption. Use HtPasswdUser for other Encoding types."
);
}

Expand Down
12 changes: 7 additions & 5 deletions core/lib/Foswiki/Users/ApacheHtpasswdUser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ provided mainly as an example of how to write a new password manager.
sub new {
my ( $class, $session ) = @_;
my $UseMD5;
my $UsePlain;
#my $UsePlain;

if ( $Foswiki::cfg{Htpasswd}{Encoding} eq 'crypt' ) {
if ( $^O =~ /^MSWin/i ) {
Expand All @@ -45,9 +45,11 @@ sub new {
require Crypt::PasswdMD5;
$UseMD5 = 1;
}
elsif ( $Foswiki::cfg{Htpasswd}{Encoding} eq 'plain' ) {
$UsePlain = 1;
}
# SMELL: Apache::Htpasswd doesn't really write out plain passwords
# so no sense enabling support for this.
#elsif ( $Foswiki::cfg{Htpasswd}{Encoding} eq 'plain' ) {
# $UsePlain = 1;
#}
else {
print STDERR "ERROR: {Htpasswd}{Encoding} setting : "
. $Foswiki::cfg{Htpasswd}{Encoding}
Expand All @@ -63,7 +65,7 @@ sub new {
{
passwdFile => $Foswiki::cfg{Htpasswd}{FileName},
UseMD5 => $UseMD5,
UsePlain => $UsePlain,
#UsePlain => $UsePlain,
}
);
unless ( -e $Foswiki::cfg{Htpasswd}{FileName} ) {
Expand Down
8 changes: 0 additions & 8 deletions core/lib/Foswiki/Users/HtPasswdUser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ sub new {
elsif ( $Foswiki::cfg{Htpasswd}{Encoding} eq 'crypt-md5' ) {
eval 'use Crypt::PasswdMD5';
$this->{APR} = 1 unless ($@);

if ( $Foswiki::cfg{DetailedOS} eq 'darwin' ) {
print STDERR "ERROR: crypt-md5 FAILS on OSX (no fix in 2008)\n";
throw Error::Simple(
"ERROR: crypt-md5 FAILS on OSX (no fix in 2008)");
}
}
else {
print STDERR "ERROR: unknown {Htpasswd}{Encoding} setting : "
Expand Down Expand Up @@ -377,7 +371,6 @@ sub encrypt {

# generate a salt not only from rand() but also mixing
# in the users login name: unecessary
# SMELL - see PasswordTests.pm for failure on OSX
$salt .= $saltchars[
(
int( rand( $#saltchars + 1 ) ) +
Expand All @@ -400,7 +393,6 @@ sub encrypt {

# generate a salt not only from rand() but also mixing
# in the users login name: unecessary
# SMELL - see PasswordTests.pm for failure on OSX
$salt .= $saltchars[
(
int( rand( $#saltchars + 1 ) ) +
Expand Down

0 comments on commit ec6fe4d

Please sign in to comment.