r56838 - in /branches/upstream/libcrypt-mysql-perl: ./ current/ current/lib/ current/lib/Crypt/ current/t/

ivan at users.alioth.debian.org ivan at users.alioth.debian.org
Sun Apr 25 05:53:46 UTC 2010


Author: ivan
Date: Sun Apr 25 05:53:31 2010
New Revision: 56838

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=56838
Log:
[svn-inject] Installing original source of libcrypt-mysql-perl

Added:
    branches/upstream/libcrypt-mysql-perl/
    branches/upstream/libcrypt-mysql-perl/current/
    branches/upstream/libcrypt-mysql-perl/current/Build.PL
    branches/upstream/libcrypt-mysql-perl/current/Changes
    branches/upstream/libcrypt-mysql-perl/current/MANIFEST
    branches/upstream/libcrypt-mysql-perl/current/META.yml
    branches/upstream/libcrypt-mysql-perl/current/Makefile.PL
    branches/upstream/libcrypt-mysql-perl/current/README
    branches/upstream/libcrypt-mysql-perl/current/lib/
    branches/upstream/libcrypt-mysql-perl/current/lib/Crypt/
    branches/upstream/libcrypt-mysql-perl/current/lib/Crypt/MySQL.pm
    branches/upstream/libcrypt-mysql-perl/current/lib/Crypt/MySQL.xs
    branches/upstream/libcrypt-mysql-perl/current/t/
    branches/upstream/libcrypt-mysql-perl/current/t/00_compile.t
    branches/upstream/libcrypt-mysql-perl/current/t/01_password.t
    branches/upstream/libcrypt-mysql-perl/current/t/02_export.t
    branches/upstream/libcrypt-mysql-perl/current/t/03_dbi.t

Added: branches/upstream/libcrypt-mysql-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-mysql-perl/current/Build.PL?rev=56838&op=file
==============================================================================
--- branches/upstream/libcrypt-mysql-perl/current/Build.PL (added)
+++ branches/upstream/libcrypt-mysql-perl/current/Build.PL Sun Apr 25 05:53:31 2010
@@ -1,0 +1,17 @@
+use strict;
+use warnings;
+use Module::Build;
+
+my $builder = Module::Build->new(
+    module_name         => 'Crypt::MySQL',
+    license             => 'perl',
+    dist_author         => 'Tomohiro IKEBE <ikebe at shebang.jp>',
+    dist_version_from   => 'lib/Crypt/MySQL.pm',
+    requires => {
+        'Test::More' => 0,
+        'Digest::SHA1' => 0,
+    },
+    add_to_cleanup      => [ 'Crypt-MySQL-*' ],
+);
+
+$builder->create_build_script();

Added: branches/upstream/libcrypt-mysql-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-mysql-perl/current/Changes?rev=56838&op=file
==============================================================================
--- branches/upstream/libcrypt-mysql-perl/current/Changes (added)
+++ branches/upstream/libcrypt-mysql-perl/current/Changes Sun Apr 25 05:53:31 2010
@@ -1,0 +1,14 @@
+2006-08-14  IKEBE Tomohiro  <ikebe at shebang.jp>
+
+	* added password41() to @EXPORT_OK list.
+	* support MySQL 4.1's PASSWORD() function.
+        * allow the string which contain Null characters. 
+        Apply the patch from Zefram.
+
+2004-02-24  IKEBE Tomohiro  <ikebe at shebang.jp>
+
+	* fixed array overrun problem.
+
+2003-04-24  IKEBE Tomohiro  <ikebe at shebang.jp>
+
+	* original version

Added: branches/upstream/libcrypt-mysql-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-mysql-perl/current/MANIFEST?rev=56838&op=file
==============================================================================
--- branches/upstream/libcrypt-mysql-perl/current/MANIFEST (added)
+++ branches/upstream/libcrypt-mysql-perl/current/MANIFEST Sun Apr 25 05:53:31 2010
@@ -1,0 +1,12 @@
+Build.PL
+Changes
+lib/Crypt/MySQL.pm
+lib/Crypt/MySQL.xs
+Makefile.PL
+MANIFEST			This list of files
+README
+t/00_compile.t
+t/01_password.t
+t/02_export.t
+t/03_dbi.t
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/libcrypt-mysql-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-mysql-perl/current/META.yml?rev=56838&op=file
==============================================================================
--- branches/upstream/libcrypt-mysql-perl/current/META.yml (added)
+++ branches/upstream/libcrypt-mysql-perl/current/META.yml Sun Apr 25 05:53:31 2010
@@ -1,0 +1,12 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
+name:         Crypt-MySQL
+version:      0.04
+version_from: lib/Crypt/MySQL.pm
+installdirs:  site
+requires:
+    Digest::SHA1:                  0
+    Test::More:                    0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.30

Added: branches/upstream/libcrypt-mysql-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-mysql-perl/current/Makefile.PL?rev=56838&op=file
==============================================================================
--- branches/upstream/libcrypt-mysql-perl/current/Makefile.PL (added)
+++ branches/upstream/libcrypt-mysql-perl/current/Makefile.PL Sun Apr 25 05:53:31 2010
@@ -1,0 +1,18 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+link("lib/Crypt/MySQL.xs", "MySQL.xs");
+WriteMakefile(
+    NAME                => 'Crypt::MySQL',
+    AUTHOR              => 'Tomohiro IKEBE <ikebe at shebang.jp>',
+    VERSION_FROM        => 'lib/Crypt/MySQL.pm',
+    ABSTRACT_FROM       => 'lib/Crypt/MySQL.pm',
+    PL_FILES            => {},
+    PREREQ_PM => {
+        'Test::More' => 0,
+        'Digest::SHA1' => 0,
+    },
+    dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+    clean               => { FILES => 'Crypt-MySQL-*' },
+);

Added: branches/upstream/libcrypt-mysql-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-mysql-perl/current/README?rev=56838&op=file
==============================================================================
--- branches/upstream/libcrypt-mysql-perl/current/README (added)
+++ branches/upstream/libcrypt-mysql-perl/current/README Sun Apr 25 05:53:31 2010
@@ -1,0 +1,37 @@
+Crypt-MySQL
+
+The README is used to introduce the module and provide instructions on
+how to install the module, any machine dependencies it may have (for
+example C compilers and installed libraries) and any other information
+that should be provided before the module is installed.
+
+A README file is required for CPAN modules since CPAN extracts the README
+file from a module distribution so that people browsing the archive
+can use it get an idea of the modules uses. It is usually a good idea
+to provide version information here so that people can decide whether
+fixes for the module are worth downloading.
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+    perl Makefile.PL
+    make
+    make test
+    make install
+
+
+Alternatively, to install with Module::Build, you can use the following commands:
+
+    perl Build.PL
+    ./Build
+    ./Build test
+    ./Build install
+
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2006 Tomohiro IKEBE
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.

Added: branches/upstream/libcrypt-mysql-perl/current/lib/Crypt/MySQL.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-mysql-perl/current/lib/Crypt/MySQL.pm?rev=56838&op=file
==============================================================================
--- branches/upstream/libcrypt-mysql-perl/current/lib/Crypt/MySQL.pm (added)
+++ branches/upstream/libcrypt-mysql-perl/current/lib/Crypt/MySQL.pm Sun Apr 25 05:53:31 2010
@@ -1,0 +1,55 @@
+package Crypt::MySQL;
+
+use strict;
+use vars qw($VERSION @ISA @EXPORT_OK);
+use Digest::SHA1 qw(sha1 sha1_hex);
+
+BEGIN {
+    $VERSION = '0.04';
+    if ($] > 5.006) {
+        require XSLoader;
+        XSLoader::load(__PACKAGE__, $VERSION);
+    } else {
+        require DynaLoader;
+        @ISA = qw(DynaLoader);
+        __PACKAGE__->bootstrap;
+    }
+    require Exporter;
+    push @ISA, 'Exporter';
+    @EXPORT_OK = qw(password password41);
+}
+
+sub password41($) { "*".uc(sha1_hex(sha1($_[0]))); }
+
+1;
+__END__
+
+=head1 NAME
+
+Crypt::MySQL - emulate MySQL PASSWORD() function.
+
+=head1 SYNOPSIS
+
+  use Crypt::MySQL qw(password password41);
+
+  my $encrypted = password("foobar"); # for MySQL 3.23, 4.0
+
+  my $encrypted = password41("foobar"); # for MySQL 4.1 or later.
+
+=head1 DESCRIPTION
+
+Crypt::MySQL emulates MySQL PASSWORD() SQL function, without libmysqlclient.
+You can compare encrypted passwords, without real MySQL environment.
+
+=head1 AUTHOR
+
+IKEBE Tomohiro E<lt>ikebe at shebang.jpE<gt>
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+L<DBD::mysql> L<Digest::SHA1>
+
+=cut

Added: branches/upstream/libcrypt-mysql-perl/current/lib/Crypt/MySQL.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-mysql-perl/current/lib/Crypt/MySQL.xs?rev=56838&op=file
==============================================================================
--- branches/upstream/libcrypt-mysql-perl/current/lib/Crypt/MySQL.xs (added)
+++ branches/upstream/libcrypt-mysql-perl/current/lib/Crypt/MySQL.xs Sun Apr 25 05:53:31 2010
@@ -1,0 +1,56 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+
+
+#include <sys/types.h>
+
+typedef unsigned long ulong;
+typedef unsigned char uchar;
+
+void __crypt_mysql_hash_password(ulong *result,
+  const char *password, size_t password_len)
+{
+  const char *password_end = password + password_len;
+  register ulong nr=1345345333L, add=7, nr2=0x12345671L;
+  ulong tmp;
+  for (; password != password_end ; password++)
+  {
+    if (*password == ' ' || *password == '\t')
+      continue;			/* skipp space in password */
+    tmp= (ulong) (uchar) *password;
+    nr^= (((nr & 63)+add)*tmp)+ (nr << 8);
+    nr2+=(nr2 << 8) ^ nr;
+    add+=tmp;
+  }
+  result[0]=nr & (((ulong) 1L << 31) -1L); /* Don't use sign bit (str2int) */;
+  result[1]=nr2 & (((ulong) 1L << 31) -1L);
+  return;
+}
+
+void __crypt_mysql_make_scrambled_password(char *to,
+  const char *password, size_t password_len)
+{
+  ulong hash_res[2];
+  __crypt_mysql_hash_password(hash_res,password,password_len);
+  sprintf(to,"%08lx%08lx",hash_res[0],hash_res[1]);
+}
+
+MODULE = Crypt::MySQL		PACKAGE = Crypt::MySQL		
+
+SV *
+password(str)
+	SV *str;
+	CODE:
+	{
+	char to[17];
+	STRLEN size;
+	char *src = SvPV(str, size);
+	__crypt_mysql_make_scrambled_password(to, src, size);
+	RETVAL = newSVpv(to, 0);
+	}
+	OUTPUT:
+	RETVAL
+
+

Added: branches/upstream/libcrypt-mysql-perl/current/t/00_compile.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-mysql-perl/current/t/00_compile.t?rev=56838&op=file
==============================================================================
--- branches/upstream/libcrypt-mysql-perl/current/t/00_compile.t (added)
+++ branches/upstream/libcrypt-mysql-perl/current/t/00_compile.t Sun Apr 25 05:53:31 2010
@@ -1,0 +1,4 @@
+use strict;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'Crypt::MySQL' }

Added: branches/upstream/libcrypt-mysql-perl/current/t/01_password.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-mysql-perl/current/t/01_password.t?rev=56838&op=file
==============================================================================
--- branches/upstream/libcrypt-mysql-perl/current/t/01_password.t (added)
+++ branches/upstream/libcrypt-mysql-perl/current/t/01_password.t Sun Apr 25 05:53:31 2010
@@ -1,0 +1,7 @@
+use strict;
+use Test::More tests => 2;
+
+use Crypt::MySQL ();
+
+is(Crypt::MySQL::password("foobar"), "4655c05b05f11fab");
+is(Crypt::MySQL::password41("foobar"), "*9B500343BC52E2911172EB52AE5CF4847604C6E5");

Added: branches/upstream/libcrypt-mysql-perl/current/t/02_export.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-mysql-perl/current/t/02_export.t?rev=56838&op=file
==============================================================================
--- branches/upstream/libcrypt-mysql-perl/current/t/02_export.t (added)
+++ branches/upstream/libcrypt-mysql-perl/current/t/02_export.t Sun Apr 25 05:53:31 2010
@@ -1,0 +1,7 @@
+use strict;
+use Test::More tests => 2;
+
+use Crypt::MySQL qw(password password41);
+
+is(password("barbaz"), "5256847878f9978f");
+is(password41("barbaz"), "*096C6A6F0E3B0A35BFF7794D732F2269D6BBE164");

Added: branches/upstream/libcrypt-mysql-perl/current/t/03_dbi.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-mysql-perl/current/t/03_dbi.t?rev=56838&op=file
==============================================================================
--- branches/upstream/libcrypt-mysql-perl/current/t/03_dbi.t (added)
+++ branches/upstream/libcrypt-mysql-perl/current/t/03_dbi.t Sun Apr 25 05:53:31 2010
@@ -1,0 +1,43 @@
+use strict;
+use Test::More;
+
+use Crypt::MySQL ();
+
+unless (eval { require DBD::mysql } && eval { require DBI }) {
+    plan skip_all => "no DBD::mysql";
+}
+else {
+    plan tests => 1;
+}
+
+SKIP: {
+    my $dbh = eval { 
+        DBI->connect("dbi:mysql:test", "root", "", {
+            RaiseError => 1, PrintError => 1
+        });
+    };
+    skip "could not connect to MySQL", 1 unless $dbh;
+
+    my $tm = time. "";
+    
+    my $sth = $dbh->prepare("SELECT PASSWORD(?)");
+    $sth->execute($tm);
+    my($real_mysql) = $sth->fetchrow_array;
+    $sth->finish;
+    
+    my $sth2 = $dbh->prepare('SELECT VERSION()');
+    $sth2->execute;
+    my($verstr) = $sth2->fetchrow_array;
+    $sth2->finish;
+    
+    $dbh->disconnect;
+
+    my($ver) = $verstr =~ m/^([0-9]+\.[0-9]+)/;
+    
+    if ($ver >= 4.1) {
+        is($real_mysql, Crypt::MySQL::password41($tm));
+    }
+    else {
+        is($real_mysql, Crypt::MySQL::password($tm));  
+    } 
+}




More information about the Pkg-perl-cvs-commits mailing list