Apache-Htpasswd-1.8/ 40755 0 1750 0 10432616672 13150 5ustar rootperlguyApache-Htpasswd-1.8/MANIFEST100644 0 1750 177 10340442644 14355 0ustar rootperlguyHtpasswd.pm Makefile.PL test.pl README MANIFEST META.yml Module meta-data (added by MakeMaker) Apache-Htpasswd-1.8/META.yml100644 0 1750 635 10432616672 14502 0ustar rootperlguy# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Apache-Htpasswd version: 1.8 version_from: Htpasswd.pm installdirs: site requires: Crypt::PasswdMD5: 0 Digest::SHA1: 2 MIME::Base64: 0 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.30 Apache-Htpasswd-1.8/Htpasswd.pm100644 0 1750 46517 10432615756 15437 0ustar rootperlguypackage Apache::Htpasswd; use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION); use warnings; use strict; # Restrict unsafe variables, references, barewords use Carp; use POSIX qw ( SEEK_SET SEEK_END ); use Fcntl qw ( LOCK_EX LOCK_UN ); @ISA = qw(Exporter); @EXPORT = qw(); @EXPORT_OK = qw(htpasswd htDelete fetchPass fetchInfo writeInfo htCheckPassword error Version); %EXPORT_TAGS = ( all => [@EXPORT_OK] ); $VERSION = '1.8'; sub Version { return $VERSION; } #-----------------------------------------------------------# # Public Methods #-----------------------------------------------------------# sub new { my $proto = shift; my $args = shift; my $passwdFile; if ( ref $args eq 'HASH' ) { $passwdFile = $args->{'passwdFile'}; } else { $passwdFile = $args; } my $class = ref($proto) || $proto; my ($self) = {}; bless( $self, $class ); $self->{'PASSWD'} = $passwdFile; $self->{'ERROR'} = ""; $self->{'LOCK'} = 0; $self->{'OPEN'} = 0; $self->{'READONLY'} = $args->{'ReadOnly'} if ref $args eq 'HASH'; $self->{'USEMD5'} = $args->{'UseMD5'} if ref $args eq 'HASH'; $self->{'USEPLAIN'} = $args->{'UsePlain'} if ref $args eq 'HASH'; return $self; } #-----------------------------------------------------------# sub error { my $self = shift; return $self->{'ERROR'}; } #-----------------------------------------------------------# sub htCheckPassword { my $self = shift; my $Id = shift; my $pass = shift; my $MD5Magic = '$apr1$'; my $SHA1Magic = '{SHA}'; my $cryptPass = $self->fetchPass($Id); if ( !$cryptPass ) { return undef; } if (index($cryptPass, $MD5Magic) == 0) { # This is an MD5 password require Crypt::PasswdMD5; my $salt = $cryptPass; $salt =~ s/^\Q$MD5Magic//; # Take care of the magic string if present $salt =~ s/^(.*)\$/$1/; # Salt can have up to 8 chars... $salt = substr( $salt, 0, 8 ); # That means no more than 8 chars too. return 1 if Crypt::PasswdMD5::apache_md5_crypt( $pass, $salt ) eq $cryptPass; } elsif (index($cryptPass, $SHA1Magic) == 0) { # This is an SHA1 password require Digest::SHA1; require MIME::Base64; return 1 if '{SHA}'.MIME::Base64::encode_base64( Digest::SHA1::sha1( $pass ), '' ) eq $cryptPass; } # See if it is encrypted using crypt return 1 if crypt($pass, $cryptPass) eq $cryptPass; # See if it is a plain, unencrypted password return 1 if $self->{USEPLAIN} && $pass eq $cryptPass; $self->{'ERROR'} = __PACKAGE__ . "::htCheckPassword - Passwords do not match."; carp $self->error() unless caller ne $self; return 0; } #-----------------------------------------------------------# sub htpasswd { my $self = shift; my $Id = shift; my $newPass = shift; my $oldPass = shift; my $noOld = 0; if ( $self->{READONLY} ) { $self->{'ERROR'} = __PACKAGE__ . "::htpasswd - Can't change passwords in ReadOnly mode"; carp $self->error(); return undef; } if ( !defined($oldPass) ) { $noOld = 1; } if ( defined($oldPass) && ref $oldPass eq 'HASH' ) { if ($oldPass->{'overwrite'}) { $newPass = $Id unless $newPass; my $newEncrypted = $self->CryptPasswd($newPass); return $self->writePassword( $Id, $newEncrypted ); } } # New Entry if ($noOld) { my $passwdFile = $self->{'PASSWD'}; # Encrypt new password string my $passwordCrypted = $self->CryptPasswd($newPass); $self->_open(); if ( $self->fetchPass($Id) ) { # User already has a password in the file. $self->{'ERROR'} = __PACKAGE__ . "::htpasswd - $Id already exists in $passwdFile"; carp $self->error(); $self->_close(); return undef; } else { # If we can add the user. seek( FH, 0, SEEK_END ); print FH "$Id\:$passwordCrypted\n"; $self->_close(); return 1; } $self->_close(); } else { $self->_open(); my $exists = $self->htCheckPassword( $Id, $oldPass ); if ($exists) { my ($newCrypted) = $self->CryptPasswd($newPass); return $self->writePassword( $Id, $newCrypted ); } else { # ERROR returned from htCheckPass $self->{'ERROR'} = __PACKAGE__ . "::htpasswd - Password not changed."; carp $self->error(); return undef; } $self->_close(); } } # end htpasswd #-----------------------------------------------------------# sub htDelete { my $self = shift; my $Id = shift; my $passwdFile = $self->{'PASSWD'}; my @cache; my $return; # Loop through the file, building a cache of exising records # which don't match the Id. $self->_open(); seek( FH, 0, SEEK_SET ); while () { if (/^$Id\:/) { $return = 1; } else { push ( @cache, $_ ); } } # Write out the @cache if needed. if ($return) { # Return to beginning of file seek( FH, 0, SEEK_SET ); while (@cache) { print FH shift (@cache); } # Cut everything beyond current position truncate( FH, tell(FH) ); } else { $self->{'ERROR'} = __PACKAGE__ . "::htDelete - User $Id not found in $passwdFile: $!"; carp $self->error(); } $self->_close(); return $return; } #-----------------------------------------------------------# sub fetchPass { my $self = shift; my $Id = shift; my $passwdFile = $self->{'PASSWD'}; my $passwd = 0; $self->_open(); while () { chop; my @tmp = split ( /:/, $_, 3 ); if ( $tmp[0] eq $Id ) { $passwd = $tmp[1]; last; } } $self->_close(); return $passwd; } #-----------------------------------------------------------# sub writePassword { my $self = shift; my $Id = shift; my $newPass = shift; my $passwdFile = $self->{'PASSWD'}; my @cache; my $return; $self->_open(); seek( FH, 0, SEEK_SET ); while () { my @tmp = split ( /:/, $_, 3 ); if ( $tmp[0] eq $Id ) { my $info = $tmp[2] ? $tmp[2] : ""; chomp $info; push ( @cache, "$Id\:$newPass\:$info\n" ); $return = 1; } else { push ( @cache, $_ ); } } # Write out the @cache, if needed. if ($return) { # Return to beginning of file seek( FH, 0, SEEK_SET ); while (@cache) { print FH shift (@cache); } # Cut everything beyond current position truncate( FH, tell(FH) ); } else { $self->{'ERROR'} = __PACKAGE__ . "::writePassword - User $Id not found in $passwdFile: $!"; carp $self->error() . "\n"; } $self->_close(); return $return; } #-----------------------------------------------------------# sub fetchInfo { my $self = shift; my $Id = shift; my $passwdFile = $self->{'PASSWD'}; my $info = 0; $self->_open(); while () { chop; my @tmp = split ( /:/, $_, 3 ); if ( $tmp[0] eq $Id ) { $info = $tmp[2]; last; } } $self->_close(); return $info; } #-----------------------------------------------------------# sub fetchUsers { my $self = shift; my $passwdFile = $self->{'PASSWD'}; my $count = 0; my @users; $self->_open(); while () { chop; my @tmp = split ( /:/, $_, 3 ); push ( @users, $tmp[0] ) unless !$tmp[0]; } $self->_close(); return wantarray() ? @users : scalar @users; } #-----------------------------------------------------------# sub writeInfo { my $self = shift; my $Id = shift; my $newInfo = shift; my ($passwdFile) = $self->{'PASSWD'}; my (@cache); my ($return); $self->_open(); seek( FH, 0, SEEK_SET ); while () { my @tmp = split ( /:/, $_, 3 ); if ( $tmp[0] eq $Id ) { chomp $tmp[1] if ( @tmp == 2 ); # Cut out EOL if there was no info push ( @cache, "$Id\:$tmp[1]\:$newInfo\n" ); $return = 1; } else { push ( @cache, $_ ); } } # Write out the @cache, if needed. if ($return) { # Return to beginning of file seek( FH, 0, SEEK_SET ); while (@cache) { print FH shift (@cache); } # Cut everything beyond current position truncate( FH, tell(FH) ); } else { $self->{'ERROR'} = __PACKAGE__ . "::writeInfo - User $Id not found in $passwdFile: $!"; carp $self->error() . "\n"; } $self->_close(); return $return; } #-----------------------------------------------------------# sub CryptPasswd { my $self = shift; my $passwd = shift; my $salt = shift; my @chars = ( '.', '/', 0 .. 9, 'A' .. 'Z', 'a' .. 'z' ); my $Magic = '$apr1$'; # Apache specific Magic chars my $cryptType = ( $^O =~ /^MSWin/i || $self->{'USEMD5'} ) ? "MD5" : "crypt"; if ( $salt && $cryptType =~ /MD5/i && $salt =~ /^\Q$Magic/ ) { # Borrowed from Crypt::PasswdMD5 $salt =~ s/^\Q$Magic//; # Take care of the magic string if present $salt =~ s/^(.*)\$.*$/$1/; # Salt can have up to 8 chars... $salt = substr( $salt, 0, 8 ); # That means no more than 8 chars too. # For old crypt only } elsif ( $salt && $cryptType =~ /crypt/i ) { if ($salt =~ /\$2a\$\d+\$(.{23})/) { $salt = $1; } else { # Make sure only use 2 chars $salt = substr( $salt, 0, 2 ); } } else { # If we use MD5, create apache MD5 with 8 char salt: 3 randoms, 5 dots if ( $cryptType =~ /MD5/i ) { $salt = join ( '', map { $chars[ int rand @chars ] } ( 0 .. 2 ) ) . "." x 5; # Otherwise fallback to standard archaic crypt } else { $salt = join ( '', map { $chars[ int rand @chars ] } ( 0 .. 1 ) ); } } if ( $cryptType =~ /MD5/i ) { require Crypt::PasswdMD5; return Crypt::PasswdMD5::apache_md5_crypt( $passwd, $salt ); } else { return crypt( $passwd, $salt ); } } #-----------------------------------------------------------# sub DESTROY { close(FH); }; #-----------------------------------------------------------# sub _lock { my $self = shift; # Lock if we don't have the lock flock( FH, LOCK_EX ) if ( $self->{'LOCK'} == 0 ); # We have the lock $self->{'LOCK'} = 1; # Seek to head seek( FH, 0, SEEK_SET ); } #-----------------------------------------------------------# sub _unlock { my $self = shift; flock( FH, LOCK_UN ); $self->{'LOCK'} = 0; } #-----------------------------------------------------------# sub _open { my $self = shift; if ( $self->{'OPEN'} > 0 ) { $self->{'OPEN'}++; $self->_lock(); return; } my $passwdFile = $self->{'PASSWD'}; if ( $self->{READONLY} ) { if ( !open( FH, $passwdFile ) ) { $self->{'ERROR'} = __PACKAGE__ . "::fetchPass - Cannot open $passwdFile: $!"; croak $self->error(); } } else { if ( !open( FH, "+<$passwdFile" ) ) { $self->{'ERROR'} = __PACKAGE__ . "::fetchPass - Cannot open $passwdFile: $!"; croak $self->error(); } } binmode(FH); $self->{'OPEN'}++; $self->_lock() unless $self->{READONLY}; # No lock on r/o } #-----------------------------------------------------------# sub _close { my $self = shift; $self->_unlock() unless $self->{READONLY}; $self->{'OPEN'}--; if ( $self->{'OPEN'} > 0 ) { return; } if ( !close(FH) ) { my $passwdFile = $self->{'PASSWD'}; $self->{'ERROR'} = __PACKAGE__ . "::htDelete - Cannot close $passwdFile: $!"; carp $self->error(); return undef; } } #-----------------------------------------------------------# 1; __END__ =head1 NAME Apache::Htpasswd - Manage Unix crypt-style password file. =head1 SYNOPSIS use Apache::Htpasswd; $foo = new Apache::Htpasswd("path-to-file"); $foo = new Apache::Htpasswd({passwdFile => "path-to-file", ReadOnly => 1} ); # Add an entry $foo->htpasswd("zog", "password"); # Change a password $foo->htpasswd("zog", "new-password", "old-password"); # Change a password without checking against old password $foo->htpasswd("zog", "new-password", {'overwrite' => 1}); # Check that a password is correct $foo->htCheckPassword("zog", "password"); # Fetch an encrypted password $foo->fetchPass("foo"); # Delete entry $foo->htDelete("foo"); # If something fails, check error $foo->error; # Write in the extra info field $foo->writeInfo("login", "info"); # Get extra info field for a user $foo->fetchInfo("login"); =head1 DESCRIPTION This module comes with a set of methods to use with htaccess password files. These files (and htaccess) are used to do Basic Authentication on a web server. The passwords file is a flat-file with login name and their associated crypted password. You can use this for non-Apache files if you wish, but it was written specifically for .htaccess style files. =head2 FUNCTIONS =over 4 =item Apache::Htpasswd->new(...); As of version 1.5.4 named params have been added, and it is suggested that you use them from here on out. Apache::Htpasswd->new("path-to-file"); "path-to-file" should be the path and name of the file containing the login/password information. Apache::Htpasswd->new({passwdFile => "path-to-file", ReadOnly => 1, UseMD5 => 1, }); This is the prefered way to instantiate an object. The 'ReadOnly' param is optional, and will open the file in read-only mode if used. The 'UseMD5' is also optional: it will force MD5 password under Unix. If you want to support plain un-encrypted passwords, then you need to set the UsePlain option (this is NOT recommended, but might be necesary in some situations) =item error; If a method returns an error, or a method fails, the error can be retrieved by calling error() =item htCheckPassword("login", "password"); Finds if the password is valid for the given login. Returns 1 if passes. Returns 0 if fails. =item htpasswd("login", "password"); This will add a new user to the password file. Returns 1 if succeeds. Returns undef on failure. =item htDelete("login") Delete users entry in password file. Returns 1 on success Returns undef on failure. =item htpasswd("login", "new-password", "old-password"); If the I matches the I password, then it will replace it with I. If the I is not correct, will return 0. =item htpasswd("login", "new-password", {'overwrite' => 1}); Will replace the password for the login. This will force the password to be changed. It does no verification of old-passwords. Returns 1 if succeeds Returns undef if fails =item fetchPass("login"); Returns I password if succeeds. Returns 0 if login is invalid. Returns undef otherwise. =item fetchInfo("login"); Returns additional information if succeeds. Returns 0 if login is invalid. Returns undef otherwise. =item fetchUsers(); Will return either a list of all the user names, or a count of all the users. The following will return a list: my @users = $Htpasswd->fetchUsers(); The following will return the count: my $user_count = $Htpasswd->fetchUsers(); =item writeInfo("login", "info"); Will replace the additional information for the login. Returns 0 if login is invalid. Returns undef otherwise. =item CryptPasswd("password", "salt"); Will return an encrypted password using 'crypt'. If I is ommitted, a salt will be created. =back =head1 INSTALLATION You install Apache::Htpasswd, as you would install any perl module library, by running these commands: perl Makefile.PL make make test make install make clean If you are going to use MD5 encrypted passwords, you need to install L. If you need to support SHA1 encrypted passwords, you need to install L and L. =head1 DOCUMENTATION POD style documentation is included in the module. These are normally converted to manual pages and installed as part of the "make install" process. You should also be able to use the 'perldoc' utility to extract and read documentation from the module files directly. =head1 AVAILABILITY The latest version of Apache::Htpasswd should always be available from: $CPAN/modules/by-authors/id/K/KM/KMELTZ/ Visit to find a CPAN site near you. =head1 CHANGES Revision 1.8.0 Added proper PREREQ_PM Revision 1.7.0 Handle SHA1 and plaintext. Also change the interface for allowing change of password without first checking old password. IF YOU DON'T READ THE DOCS AND SEE I DID THIS DON'T EMAIL ME! Revision 1.6.0 Handle Blowfish hashes when that's the mechanism crypt() uses. Revision 1.5.9 MD5 for *nix with new UseMD5 arg for new() Revision 1.5.8 Bugfix to htpasswd(). Revision 1.5.7 MD5 for Windows, and other minor changes. Revision 1.5.6 Minor enhancements. Revision 1.5.5 2002/08/14 11:27:05 Newline issue fixed for certain conditions. Revision 1.5.4 2002/07/26 12:17:43 kevin doc fixes, new fetchUsers method, new ReadOnly option, named params for new(), various others Revision 1.5.3 2001/05/02 08:21:18 kevin Minor bugfix Revision 1.5.2 2001/04/03 09:14:57 kevin Really fixed newline problem :) Revision 1.5.1 2001/03/26 08:25:38 kevin Fixed another newline problem Revision 1.5 2001/03/15 01:50:12 kevin Fixed bug to remove newlines Revision 1.4 2001/02/23 08:23:46 kevin Added support for extra info fields Revision 1.3 2000/04/04 15:00:15 meltzek Made file locking safer to avoid race conditions. Fixed typo in docs. Revision 1.2 1999/01/28 22:43:45 meltzek Added slightly more verbose error croaks. Made sure error from htCheckPassword is only called when called directly, and not by $self. Revision 1.1 1998/10/22 03:12:08 meltzek Slightly changed how files lock. Made more use out of carp and croak. Made sure there were no ^M's as per Randal Schwartz's request. =head1 BUGS None known at time of writting. =head1 AUTHOR INFORMATION Copyright 1998..2005, Kevin Meltzer. All rights reserved. It may be used and modified freely, but I do request that this copyright notice remain attached to the file. You may modify this module as you wish, but if you redistribute a modified version, please attach a note listing the modifications you have made. This is released under the same terms as Perl itself. Address bug reports and comments to: kmeltz@cpan.org The author makes no warranties, promises, or gaurentees of this software. As with all software, use at your own risk. =head1 SEE ALSO L, L, L, L =cut Apache-Htpasswd-1.8/test.pl100755 0 1750 7007 10340452064 14557 0ustar rootperlguy# $Id: test.pl,v 1.1.1.1 2002/07/26 18:58:46 root Exp $ # $Log: test.pl,v $ # Revision 1.1.1.1 2002/07/26 18:58:46 root # initial # # Revision 0.3 1998/10/22 02:49:53 meltzek # Added verbose begining and ending of test. # # Revision 0.2 1998/10/22 02:46:56 meltzek # Added new checks. # BEGIN { $| = 1; print "Tests 1..20 begining\n"; } END {print "not ok 1\n" unless $loaded;} use Apache::Htpasswd; $loaded = 1; print "ok 1\n"; ######################### End of black magic. sub report_result { my $ok = shift; $TEST_NUM ||= 2; print "not " unless $ok; print "ok $TEST_NUM\n"; print "@_\n" if (not $ok and $ENV{TEST_VERBOSE}); $TEST_NUM++; } sub report_skip { my $why = shift; print "not ok $TEST_NUM # SKIP $why\n"; $TEST_NUM++; } # Create a test password file my $File = "testpasswords.test"; open(TEST,">$File") || die "Can't run tests because I can't create $File [$!]"; print TEST "kevin:kjDqW.pgNIz3Ufoo:suvPq./X7Q8nk\n"; close TEST; { # 2: Get file &report_result($pwdFile = new Apache::Htpasswd ($File), $! ); # 3: store a value &report_result($pwdFile->htpasswd("foo","foobar") , $! ); # 4: change value &report_result(!$pwdFile->htpasswd("fooo", "goo","foobar" ) , $! ); &report_result($pwdFile->htpasswd("foo", "goo","foobar" ) , $! ); # 5: force change value &report_result($pwdFile->htpasswd("foo","ummm",{'overwrite' => 1}), $! ); # 6: check the stored value &report_result($pwdFile->fetchPass("foo") , $!); # 7: check whether the empty key exists() &report_result($pwdFile->htCheckPassword("foo","ummm"),$!); # 8: add extra info &report_result($pwdFile->writeInfo("kevin", "Test info"),$!); # 9: fetch extra info &report_result($pwdFile->fetchInfo("kevin"),$!); # 10: Delete user &report_result($pwdFile->htDelete("kevin"),$!); # 11: get list my @list = $pwdFile->fetchUsers(); &report_result($list[0] eq 'foo', $!); # 12: get number of users my $num = $pwdFile->fetchUsers(); &report_result($num == 1, $!); undef $pwdFile; # 13: Create in read-only mode &report_result($pwdFile = new Apache::Htpasswd({passwdFile => $File, ReadOnly => 1}), $! ); # 14: store a value (should fail) # Should carp, but don't want to display it sub Apache::Htpasswd::carp {}; &report_result(!$pwdFile->htpasswd("kevin","zog") , $! ); } open(TEST,">>$File"); print TEST "cryptuser:Iao36C/TVmCRc\n"; print TEST "MD5user:\$apr1\$Yy.pS/..\$4bwpMUiVq/95BDr4kZ2lK.\n"; print TEST "SHA1user:{SHA}QL0AFWMIX8NRZTKeof9cXsvbvu8=\n"; print TEST "plainuser:123\n"; close TEST; { # 16: Create in read-only mode with UsePlain &report_result($pwdFile = new Apache::Htpasswd({passwdFile => $File, ReadOnly => 1, UsePlain => 1}), $! ); # 17: check whether crypt passwords work &report_result($pwdFile->htCheckPassword("cryptuser","123"),$!); # 18: check whether MD5 passwords work eval { require Crypt::PasswdMD5 }; if ($@) { &report_skip('Crypt::PasswdMD5 required for this test'); } else { &report_result($pwdFile->htCheckPassword("MD5user","123"),$!); } # 19: check whether SHA1 passwords work eval { require Digest::MD5; require MIME::Base64 }; if ($@) { &report_skip('Digest::MD5 and MIME::Base64 required for this test'); } else { &report_result($pwdFile->htCheckPassword("SHA1user","123"),$!); } # 20: check whether plain passwords work &report_result($pwdFile->htCheckPassword("plainuser","123"),$!); } print "Test complete.\n"; Apache-Htpasswd-1.8/README100644 1750 1750 13356 10112512151 14734 0ustar perlguyperlguyNAME Apache::Htpasswd - Manage Unix crypt-style password file. SYNOPSIS use Apache::Htpasswd; $foo = new Apache::Htpasswd("path-to-file"); # Add an entry $foo->htpasswd("zog", "password"); # Change a password $foo->htpasswd("zog", "new-password", "old-password"); # Change a password without checking against old password # The 1 signals that the change is being forced. $foo->htpasswd("zog", "new-password", 1); # Check that a password is correct $pwdFile->htCheckPassword("zog", "password"); # Fetch an encrypted password $foo->fetchPass("foo"); # Delete entry $foo->htDelete("foo"); # If something fails, check error $foo->error; # Write in the extra info field $foo->writeInfo("login", "info"); # Get extra info field for a user $foo->fetchInfo("login"); DESCRIPTION This module comes with a set of methods to use with htaccess password files. These files (and htaccess) are used to do Basic Authentication on a web server. The passwords file is a flat-file with login name and their associated crypted password. You can use this for non-Apache files if you wish, but it was written specifically for .htaccess style files. FUNCTIONS htaccess->new("path-to-file"); "path-to-file" should be the path and name of the file containing the login/password information. error; If a method returns an error, or a method fails, the error can be retrived by calling error() htCheckPassword("login", "password"); Finds if the password is valid for the given login. Returns 1 if passes. Returns 0 if fails. htpasswd("login", "password"); This will add a new user to the password file. Returns 1 if succeeds. Returns undef on failure. htDelete("login") Delete users entry in password file. Returns 1 on success Returns undef on failure. htpasswd("login", "new-password", "old-password"); If the *old-password* matches the *login's* password, then it will replace it with *new-password*. If the *old-password* is not correct, will return 0. htpasswd("login", "new-password", 1); Will replace the password for the login. This will force the password to be changed. It does no verification of old-passwords. Returns 1 if succeeds Returns undef if fails fetchPass("login"); Returns *encrypted* password if succeeds. Returns 0 if login is invalid. Returns undef otherwise. fetchInfo("login"); Returns additional information if succeeds. Returns 0 if login is invalid. Returns undef otherwise. writeInfo("login", "info"); Will replace the additional information for the login. Returns 0 if login is invalid. Returns undef otherwise. CryptPasswd("password", "salt"); Will return an encrypted password using 'crypt'. If *salt* is ommitted, a salt will be generated. INSTALLATION You install Apache::Htpasswd, as you would install any perl module library, by running these commands: perl Makefile.PL make make test make install make clean DOCUMENTATION POD style documentation is included in the module. These are normally converted to manual pages and installed as part of the "make install" process. You should also be able to use the 'perldoc' utility to extract and read documentation from the module files directly. AVAILABILITY The latest version of Apache::Htpasswd should always be available from: $CPAN/modules/by-authors/id/K/KM/KMELTZ/ Visit to find a CPAN site near you. CHANGES Revision 1.5.7 2004/08/23 09:05:12 Made generated salt more random. Tidied up the code a bit. Also added use of Crypt::PasswdMD5 for Apache on MSWin for use of (modified) MD5 passwords on that platform. Revision 1.5.5 2002/08/14 11:27:05 Newline issue fixed for certain conditions. Revision 1.5.4 2002/07/26 12:17:43 kevin doc fixes, new fetchUsers method, new ReadOnly option, named params for new(), various others Revision 1.5.3 2001/05/02 08:21:18 kevin Minor bugfix Revision 1.5.2 2001/04/03 09:14:57 kevin Really fixed newline problem :) Revision 1.5.1 2001/03/26 08:25:38 kevin Fixed newline problem Revision 1.5 2001/03/15 01:50:12 kevin Fixed small bug for newlines Revision 1.4 2001/02/23 08:23:46 kevin Added support for extra info fields Revision 1.3 2000/04/04 15:00:15 meltzek Made file locking safer to avoid race conditions. Fixed typo in docs. Revision 1.2 1999/01/28 22:43:45 meltzek Added slightly more verbose error croaks. Made sure error from htCheckPassword is only called when called directly, and not by $self. Revision 1.1 1998/10/22 03:12:08 meltzek Slightly changed how files lock. Made more use out of carp and croak. Made sure there were no ^M's as per Randal Schwartz's request. BUGS None knows at time of writting. AUTHOR INFORMATION Copyright 1998..2004, Kevin Meltzer. All rights reserved. It may be used and modified freely, but I do request that this copyright notice remain attached to the file. You may modify this module as you wish, but if you redistribute a modified version, please attach a note listing the modifications you have made. This is released under the same terms as Perl itself. Address bug reports and comments to: perlguy@perlguy.com The author makes no warranties, promises, or gaurentees of this software. As with all software, use at your own risk. SEE ALSO the Apache::Htgroup manpage Apache-Htpasswd-1.8/Makefile.PL100755 1750 1750 1366 10432616636 16031 0ustar perlguyperlguy# -*- perl -*- # $Id: Makefile.PL,v 1.1.1.1 2002/07/26 18:58:46 root Exp $ use ExtUtils::MakeMaker; if ($^O !~ /MSWIN/i) { WriteMakefile( NAME => 'Apache::Htpasswd', VERSION_FROM => 'Htpasswd.pm', 'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, 'clean' => { FILES => q[*% *.bak *.old *.test]}, 'PREREQ_PM' => { 'Digest::SHA1' => 2.0, 'MIME::Base64' => 0, 'Crypt::PasswdMD5' => 0, }, ); } else { WriteMakefile( NAME => 'Apache::Htpasswd', VERSION_FROM => 'Htpasswd.pm', 'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, 'clean' => { FILES => q[*% *.bak *.old *.test]}, 'PREREQ_PM' => { 'Crypt::PasswdMD5' => 0, }, ); }