r15870 - in /trunk/libauthen-krb5-simple-perl: CONFIG Changes MANIFEST MANIFEST.SKIP META.yml Makefile.PL README Simple.xs debian/changelog debian/rules inc/ inc/Devel/ inc/Devel/CheckLib.pm lib/Authen/Krb5/Simple.pm t/01-compile.t t/02-ops.t
xaviero-guest at users.alioth.debian.org
xaviero-guest at users.alioth.debian.org
Thu Feb 28 13:54:10 UTC 2008
Author: xaviero-guest
Date: Thu Feb 28 13:54:09 2008
New Revision: 15870
URL: http://svn.debian.org/wsvn/?sc=1&rev=15870
Log:
* New upstream release
* debian/rules: install upstream changelog
Added:
trunk/libauthen-krb5-simple-perl/Simple.xs
trunk/libauthen-krb5-simple-perl/inc/
trunk/libauthen-krb5-simple-perl/inc/Devel/
trunk/libauthen-krb5-simple-perl/inc/Devel/CheckLib.pm
Modified:
trunk/libauthen-krb5-simple-perl/CONFIG
trunk/libauthen-krb5-simple-perl/Changes
trunk/libauthen-krb5-simple-perl/MANIFEST
trunk/libauthen-krb5-simple-perl/MANIFEST.SKIP
trunk/libauthen-krb5-simple-perl/META.yml
trunk/libauthen-krb5-simple-perl/Makefile.PL
trunk/libauthen-krb5-simple-perl/README
trunk/libauthen-krb5-simple-perl/debian/changelog
trunk/libauthen-krb5-simple-perl/debian/rules
trunk/libauthen-krb5-simple-perl/lib/Authen/Krb5/Simple.pm
trunk/libauthen-krb5-simple-perl/t/01-compile.t
trunk/libauthen-krb5-simple-perl/t/02-ops.t
Modified: trunk/libauthen-krb5-simple-perl/CONFIG
URL: http://svn.debian.org/wsvn/trunk/libauthen-krb5-simple-perl/CONFIG?rev=15870&op=diff
==============================================================================
--- trunk/libauthen-krb5-simple-perl/CONFIG (original)
+++ trunk/libauthen-krb5-simple-perl/CONFIG Thu Feb 28 13:54:09 2008
@@ -1,4 +1,4 @@
-# $Id: CONFIG,v 1.1.1.1 2003/01/19 20:33:34 dstuart Exp $
+# $Id: CONFIG,v 1.1.1.1 2003-01-19 20:33:34 dstuart Exp $
###############################################################################
#
# File: CONFIG
@@ -9,11 +9,18 @@
###############################################################################
#
-# Uncomment and specify the test username and password if you want to run a
-# more complete authentication test. Leave them commented out to skip the user
-# authentication test.
+# Uncomment and specify the test realm, username, and password if you want
+# to run a more complete authentication test. Leave them commented out to
+# skip the user authentication test.
#
-#TEST_USER some_user
-#TEST_PASS some_pw
+# Note: TEST_REALM is optional. If omitted, the default realm for the
+# local system will be used.
+#
+# ** If you use these amek sure the realm and user exist and the password
+# is correct. Otherwise, the test will fail.
+#
+#TEST_REALM TESTREALM.COM
+#TEST_USER testuser
+#TEST_PASS testpass
###EOF###
Modified: trunk/libauthen-krb5-simple-perl/Changes
URL: http://svn.debian.org/wsvn/trunk/libauthen-krb5-simple-perl/Changes?rev=15870&op=diff
==============================================================================
--- trunk/libauthen-krb5-simple-perl/Changes (original)
+++ trunk/libauthen-krb5-simple-perl/Changes Thu Feb 28 13:54:09 2008
@@ -1,4 +1,13 @@
Revision history for Perl extension Authen::Krb5::Simple.
+
+0.40 Sun Feb 24 18:35:42 2008
+ - Added the Devel::CheckLib.
+ - Changes to Makefile.PL and the way it tries to determine whether or
+ not the Kerberos libs are available using Devel::CheckLib.
+ - Documentation and test tweaks.
+
+0.32 Mon Feb 21 23:50:37 2005
+ - Documentation updates for clarification.
0.31 Fri Mar 14 07:14:33 2003
- Fixed bug where realm was not properly set by the constructor (Thanks
Modified: trunk/libauthen-krb5-simple-perl/MANIFEST
URL: http://svn.debian.org/wsvn/trunk/libauthen-krb5-simple-perl/MANIFEST?rev=15870&op=diff
==============================================================================
--- trunk/libauthen-krb5-simple-perl/MANIFEST (original)
+++ trunk/libauthen-krb5-simple-perl/MANIFEST Thu Feb 28 13:54:09 2008
@@ -5,6 +5,7 @@
MANIFEST.SKIP
README
Simple.xs
+inc/Devel/CheckLib.pm
lib/Authen/Krb5/Simple.pm
t/01-compile.t
t/02-ops.t
Modified: trunk/libauthen-krb5-simple-perl/MANIFEST.SKIP
URL: http://svn.debian.org/wsvn/trunk/libauthen-krb5-simple-perl/MANIFEST.SKIP?rev=15870&op=diff
==============================================================================
--- trunk/libauthen-krb5-simple-perl/MANIFEST.SKIP (original)
+++ trunk/libauthen-krb5-simple-perl/MANIFEST.SKIP Thu Feb 28 13:54:09 2008
@@ -1,3 +1,4 @@
\bCVS\b
.cvsignore
+.svn
Authen-
Modified: trunk/libauthen-krb5-simple-perl/META.yml
URL: http://svn.debian.org/wsvn/trunk/libauthen-krb5-simple-perl/META.yml?rev=15870&op=diff
==============================================================================
--- trunk/libauthen-krb5-simple-perl/META.yml (original)
+++ trunk/libauthen-krb5-simple-perl/META.yml Thu Feb 28 13:54:09 2008
@@ -1,10 +1,10 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Authen-Krb5-Simple
-version: 0.32
+version: 0.40
version_from: lib/Authen/Krb5/Simple.pm
installdirs: site
requires:
distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.20
+generated_by: ExtUtils::MakeMaker version 6.30
Modified: trunk/libauthen-krb5-simple-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/trunk/libauthen-krb5-simple-perl/Makefile.PL?rev=15870&op=diff
==============================================================================
--- trunk/libauthen-krb5-simple-perl/Makefile.PL (original)
+++ trunk/libauthen-krb5-simple-perl/Makefile.PL Thu Feb 28 13:54:09 2008
@@ -1,4 +1,4 @@
-# $Id: Makefile.PL,v 1.2 2005/02/21 23:49:42 dstuart Exp $
+# $Id: Makefile.PL,v 1.2 2005-02-21 23:49:42 dstuart Exp $
###############################################################################
#
# File: Makefile.PL
@@ -9,11 +9,56 @@
#
###############################################################################
#
+use lib 'inc';
+use Devel::CheckLib;
use ExtUtils::MakeMaker;
-# Get krb5 info
+my ($krb5_inc, $krb5_lib);
+
+# Places we might find Kerberos5 libs.
#
-my ($krb5_inc, $krb5_lib) = get_krb5_info();
+my @krb_lib_dirs = qw(
+ /usr/lib64
+ /usr/lib
+ /usr/local/lib64
+ /usr/local/lib
+ /usr/lib64/krb5
+ /usr/lib/krb5
+ /usr/local/lib64/krb5
+ /usr/local/lib/krb5
+ /usr/lib64/krb
+ /usr/lib/krb
+ /usr/local/lib64/krb
+ /usr/local/lib/krb
+ /opt/krb5/lib64
+ /opt/krb5/lib
+ /opt/krb/lib64
+ /opt/krb/lib
+ /usr/heimdal/lib64
+ /usr/heimdal/lib
+ /usr/local/heimdal/lib64
+ /usr/local/heimdal/lib
+ /opt/heimdal/lib64
+ /opt/heimdal/lib
+);
+
+# If the ENV vars are specified, use them.
+#
+if(exists($ENV{KRB5_INCLUDE})) {
+ $krb5_inc = "-I$ENV{KRB5_INCLUDE}";
+}
+if(exists($ENV{KRB5_LIB})) {
+ $krb5_lib = "-L$ENV{KRB5_LIB}";
+ unshift(@krb_lib_dirs, $ENV{KRB5_LIB});
+}
+
+# See if the needed libs are available. Take a shot at several "possible"
+# locations for these libs.
+#
+check_lib_or_exit(
+ lib => [qw( krb5 k5crypto com_err )],
+ libpath => \@kr_lib_dirs
+);
# Write out the Makefile
#
@@ -21,96 +66,16 @@
'NAME' => 'Authen::Krb5::Simple',
'VERSION_FROM' => 'lib/Authen/Krb5/Simple.pm',
'PREREQ_PM' => {},
- ($] >= 5.005
+ ($] >= 5.006
? (
ABSTRACT => 'Perl module that performs Kerberos 5 authentication',
- AUTHOR => 'Damien S. Stuart <damien.stuart at usi.net>')
+ AUTHOR => 'Damien S. Stuart <dstuart at dstuart.org>')
: ()
),
- 'LIBS' => ["-L$krb5_lib -lkrb5 -lk5crypto -lcom_err"],
+ 'LIBS' => ["$krb5_lib -lkrb5 -lk5crypto"],
'DEFINE' => '',
- 'INC' => "-I$krb5_inc",
+ 'INC' => $krb5_inc,
);
-###############################################################################
-
-sub get_krb5_info {
- # TODO: smarter code to figure out reasonable defaults for krb libs.
- # Figure out where the kerberos libs and include files are by staring with
- # a list of candidate directories. Iterate through them hoping to find a
- # match. Display the match as a default for the prompts.
- #
-
- # If the ENV vars are specified, use them.
- #
- if($ENV{KRB5_INCLUDE} and $ENV{KRB5_LIB}) {
- return($ENV{KRB5_INCLUDE}, $ENV{KRB5_LIB});
- }
-
- # Search the following directories in the following order
- # (first match wins).
- my @krb_dirs = qw(
- /usr
- /usr/kerberos
- /usr/kerberos5
- /usr/krb
- /usr/krb5
- /opt/kerberos
- /opt/kerberos5
- /opt/krb
- /opt/krb5
- /usr/local
- /usr/local/kerberos
- /usr/local/kerberos5
- /usr/local/krb
- /usr/local/krb5
- );
-
- my $lflag = 0;
- my $iflag = 0;
- my ($krb_inc, $krb_lib);
-
- foreach my $kdir (@krb_dirs) {
- my $klib = "$kdir/lib";
- my $kinc = "$kdir/include";
-
- if(glob "$klib/libkrb5.*") {
- $lflag = 1;
- $krb_lib = $klib;
- }
-
- if(-f "$kinc/krb5.h") {
- $iflag = 1;
- $krb_inc = $kinc;
- }
-
- last if($lflag and $iflag);
- }
-
- # Prompt for the location of key Kerberos files.
- #
- if($ENV{KRB5_PROMPT} or $ARGV[0] =~ '-krb5_prompt') {
- print "\nPlease enter information about your Kerberos5 installation.\n";
- print " - (Press <Enter> to keep the default value):\n\n";
-
- $krb_inc = get_resp('Enter Kerboros5 include directory', $krb_inc);
- $krb_lib = get_resp('Enter Kerberos5 lib directory', $krb_lib);
- }
-
- return($krb_inc, $krb_lib);
-}
-
-sub get_resp {
- my $prompt = shift || 'Answer?';
- my $default = shift || '';
- my $resp;
-
- $prompt .= " [ $default ]" if($default);
-
- print "\n$prompt: ";
- chomp($resp = <STDIN>);
-
- return($resp || $default);
-}
###EOF###
Modified: trunk/libauthen-krb5-simple-perl/README
URL: http://svn.debian.org/wsvn/trunk/libauthen-krb5-simple-perl/README?rev=15870&op=diff
==============================================================================
--- trunk/libauthen-krb5-simple-perl/README (original)
+++ trunk/libauthen-krb5-simple-perl/README Thu Feb 28 13:54:09 2008
@@ -1,168 +1,49 @@
Authen::Krb5::Simple version 0.32
===============================================================================
-The Authen::Krb5::Simple module provides a means to authenticate a user/password
-using Kerberose 5. Simply use this module and call its authenticate function
-with a username (or user at KRB_REALM) and a password. Detailed usage information
-can be found in the module's perldoc.
+The Authen::Krb5::Simple module provides a means to authenticate a
+user/password using Kerberose 5. Simply use this module and call its
+authenticate function with a username (or user at KRB_REALM) and a password.
+
+Detailed usage information can be found in the module's perldoc.
INSTALLATION
-To install this module edit the CONFIG file to set test username and password.
-This is optional. If no username and password is given, then the user auth
-tests will be skipped.
+To install this module edit the CONFIG file to set test kerberos realm,
+username and password. These are optional. If either the username or
+password is not given, then the user auth tests will be skipped. If a
+realm is specified, it will be used for the test. Otherwise, the default
+realm for the system will be used (if properly configured of course).
-You can also specify the location of the Kerberos include and libs directories
-in the environment variables KRB5_INCLUDE and KRB5_LIB respectively.
+You can also specify a location of the Kerberos include and libs directories
+in the environment variables KRB5_INCLUDE and KRB5_LIB respectively. Setting
+these will cause the build to try them first. This would normally be used
+if your Kerberos libraries are in a non-standard location, or you wanted to
+overide the system defaults.
Once that is done, then type the following:
- perl Makefile.PL [-krb5_prompt]
+ perl Makefile.PL
make
make test
make install
-Note: The optional "-krb5_prompt" argument will force the Makefile
- generator to prompt for the location of the krb5 include and
- lib directories.
-
- In the absence of the "-krb5_prompt" and the KRB5_XXX environment
- variable mentioned above, the module will make an attempt to figure
+Note: In the absence of the KRB5_INCLUDE and KRB4LIB environment variables
+ mentioned above, the module will make an attempt to try and find
out the location of the Kerberos 5 include and lib files. If that
- doesn't work, you will need to manually override using one of the
- above methods.
+ doesn't work, you will need to manually override by setting the
+ environment variables or editing Makfile.PL to directly.
DEPENDENCIES
This module requires the Kerberos 5 header and library files installed
on the local system.
-Here is the Authen::Krb5::Simple man page:
----------------------------------------------------------------------------
-
-NAME
- Authen::Krb5::Simple - Basic user authentication using Kerberos 5
-
-SYNOPSIS
- use Authen::Krb5::Simple;
-
- # Create a new Authen::Krb5::Simple object using
- # the system default realm.
- #
- my $krb = Authen::Krb5::Simple->new();
-
- # Authenticate a user.
- #
- my $authen = $krb->authenticate($user, $password);
-
- unless($authen) {
- my $errmsg = $krb->errstr();
- die "User: $user authentication failed: $errmsg\n";
- }
-
- # Get the current default realm.
- #
- my $realm = $krb->realm();
-
- # Set the current realm
- #
- $krb->realm('MY.NEW.REALM');
-
- # Create a new object pointing to another realm.
- #
- my $alt_krb = Authen::Krb5::Simple->new(realm => 'new.realm');
- ...
-
-DESCRIPTION
- The "Authen::Krb5::Simple" module provides a means to authenticate a
- user/password using Kerberos 5 protocol. The module's authenticate
- function takes a username (or user at kerberos_realm) and a password, and
- authenticates that user using the local Kerberos 5 installation. It was
- initially created to allow perl scripts to perform authentication
- against a Microsoft Active Directory (AD) server configured to accept
- Kerberos client requests.
-
- It is important to note: This module only performs simple
- authentication. It does not get, grant, use, or retain any kerberos
- tickets. It will check user credentials against the Kerberos server (as
- configured on the local system) each time the *authenticate* method is
- called.
-
-CONSTRUCTOR
- new
-
- The *new* method creates the *Authen::Krb5::Simple* object. It can
- take an optional argument hash. At present the only recognized
- argument is "realm".
-
- If no realm is specified, the default realm for the local host will
- be assumed. Once set, the specified realm will be used for all
- subsequent authentication calls. The realm can be changed using the
- *realm* function (see below).
-
- Examples:
-
- Using the default realm:
-
- my $krb = Authen::Krb5::Simple->new();
-
- specifying a realm:
-
- my $krb = Authen::Krb5::Simple->new(realm => 'another.realm.net');
-
-METHODS
- authenticate($user[@realm], $password)
-
- the *authenticate* method takes the user (or user at realm) and a
- password, and uses kerberos 5 (the local systems installation) to
- authenticate the user.
-
- if the user/password is good, *authenticate* will return a true
- value. Otherwise, a false value is returned and the error code is
- stored in the object.
-
- if($krb->authenticate($user, $pw)) {
- print "$user authentication successful\n";
- } else {
- print "$user authentication failed: ", $krb->errstr(), "\n";
- }
-
- realm([NEW.REALM])
-
- The *realm* method is used to set or get the current default realm.
- If an argument is passed to this method, the default realm is set to
- its value. If no argument is supplied, the current realm is
- returned.
-
- errstr
-
- The *errstr* method will return the error message from the most
- recent *authentication* call.
-
- errcode
-
- The *errstr* method will return the krb5 error code from the most
- recent *authentication* call. This value will not be very useful.
- Use the *errstr* method to get a meaningful error message.
-
-BUGS
- This version of *Authen::Krb5::Simple* does not support empty passwords.
- If you pass an empty string ('') as a password, *authenticate* will
- print a warning and return false, but there will be no error code or
- string returned if the *errstr* method is called.
-
-AUTHOR
- Damien S. Stuart, <damien.stuart at usi.net>
-
-SEE ALSO
- perl, Kerberos5 documentation.
-
-
-------------------------------------------------------------------------------
COPYRIGHT AND LICENCE
-Copyright (c) 2003 Damien S. Stuart. All rights reserved.
+Copyright (c) 2003-2008 Damien S. Stuart. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
Added: trunk/libauthen-krb5-simple-perl/Simple.xs
URL: http://svn.debian.org/wsvn/trunk/libauthen-krb5-simple-perl/Simple.xs?rev=15870&op=file
==============================================================================
--- trunk/libauthen-krb5-simple-perl/Simple.xs (added)
+++ trunk/libauthen-krb5-simple-perl/Simple.xs Thu Feb 28 13:54:09 2008
@@ -1,0 +1,87 @@
+/* $Id: Simple.xs,v 1.1.1.1 2003-01-19 20:33:34 dstuart Exp $
+*******************************************************************************
+**
+** File: Simple.xs
+**
+** Author: Damien S. Stuart
+**
+** Purpose: .xs file for the Authen::Krb5::Simple Perl module.
+**
+**
+*******************************************************************************
+*/
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#include <stdio.h>
+#include <strings.h>
+
+#include <krb5.h>
+
+int _krb5_auth(char* user, char* pass)
+{
+ int krbret;
+ krb5_context ctx;
+ krb5_creds creds;
+ krb5_principal princ;
+
+ int ret = 0;
+
+ /* Initialize krb5 context...
+ */
+ if ((krbret = krb5_init_context(&ctx))) {
+ return krbret;
+ }
+
+ memset(&creds, 0, sizeof(krb5_creds));
+
+ /* Get principal name...
+ */
+ if ((krbret = krb5_parse_name(ctx, user, &princ))) {
+ ret = krbret;
+ goto cleanup2;
+ }
+
+ /* Check the user's pasword...
+ */
+ if ((krbret = krb5_get_init_creds_password(
+ ctx, &creds, princ, pass, 0, NULL, 0, NULL, NULL))) {
+ ret = krbret;
+ goto cleanup;
+ }
+
+cleanup:
+ krb5_free_cred_contents(ctx, &creds);
+ krb5_free_principal(ctx, princ);
+
+cleanup2:
+ krb5_free_context(ctx);
+
+ return(ret);
+}
+
+MODULE = Authen::Krb5::Simple PACKAGE = Authen::Krb5::Simple
+
+PROTOTYPES: DISABLE
+
+int
+krb5_auth(user, password)
+ INPUT:
+ char * user;
+ char * password;
+ CODE:
+ RETVAL = _krb5_auth(user, password);
+ OUTPUT:
+ RETVAL
+
+char*
+krb5_errstr(errcode)
+ INPUT:
+ int errcode;
+ INIT:
+ char* result = (char*)error_message(errcode);
+ CODE:
+ RETVAL = result;
+ OUTPUT:
+ RETVAL
Modified: trunk/libauthen-krb5-simple-perl/debian/changelog
URL: http://svn.debian.org/wsvn/trunk/libauthen-krb5-simple-perl/debian/changelog?rev=15870&op=diff
==============================================================================
--- trunk/libauthen-krb5-simple-perl/debian/changelog (original)
+++ trunk/libauthen-krb5-simple-perl/debian/changelog Thu Feb 28 13:54:09 2008
@@ -4,6 +4,7 @@
* Re-add me as uploader.
* debian/control: add XS-DM-Upload-Allowed: yes.
* debian/watch: use dist-based URL.
+ * debian/rules: install upstream changelog
-- Xavier Oswald <x.oswald at free.fr> Thu, 28 Feb 2008 12:34:53 +0100
Modified: trunk/libauthen-krb5-simple-perl/debian/rules
URL: http://svn.debian.org/wsvn/trunk/libauthen-krb5-simple-perl/debian/rules?rev=15870&op=diff
==============================================================================
--- trunk/libauthen-krb5-simple-perl/debian/rules (original)
+++ trunk/libauthen-krb5-simple-perl/debian/rules Thu Feb 28 13:54:09 2008
@@ -7,8 +7,6 @@
PERL = /usr/bin/perl
endif
-# Allow disabling build optimation by setting noopt in
-# $DEB_BUILD_OPTIONS
CFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
@@ -19,16 +17,15 @@
build: build-stamp
build-stamp:
dh_testdir
- #$(PERL) Makefile.PL [-krb5_prompt]
$(PERL) Makefile.PL INSTALLDIRS=vendor
- $(MAKE) OPTIMIZE="$(CFLAGS)" LD_RUN_PATH=""
- $(MAKE) test
+ $(MAKE) OPTIMIZE="$(CFLAGS)" LD_RUN_PATH=""
touch $@
install: install-stamp
install-stamp: build-stamp
dh_testdir
dh_testroot
+ $(MAKE) test
$(MAKE) install DESTDIR=$(TMP) PREFIX=/usr
[ ! -d $(TMP)/usr/share/perl5 ] || rmdir --ignore-fail-on-non-empty --parents --verbose $(TMP)/usr/share/perl5
touch $@
@@ -36,8 +33,8 @@
clean:
dh_testdir
dh_testroot
+ [ ! -f Makefile ] || $(MAKE) realclean
dh_clean build-stamp install-stamp
- [ ! -f Makefile ] || $(MAKE) realclean
binary-indep: build install
@@ -47,7 +44,7 @@
dh_testdir
dh_testroot
dh_installdocs README
- dh_installchangelogs
+ dh_installchangelogs Changes
dh_compress
dh_fixperms
dh_strip
Added: trunk/libauthen-krb5-simple-perl/inc/Devel/CheckLib.pm
URL: http://svn.debian.org/wsvn/trunk/libauthen-krb5-simple-perl/inc/Devel/CheckLib.pm?rev=15870&op=file
==============================================================================
--- trunk/libauthen-krb5-simple-perl/inc/Devel/CheckLib.pm (added)
+++ trunk/libauthen-krb5-simple-perl/inc/Devel/CheckLib.pm Thu Feb 28 13:54:09 2008
@@ -1,0 +1,278 @@
+# $Id: CheckLib.pm,v 1.10 2007/10/30 15:12:17 drhyde Exp $
+
+package Devel::CheckLib;
+
+use strict;
+use vars qw($VERSION @ISA @EXPORT);
+$VERSION = '0.3';
+use Config;
+
+use File::Spec;
+use File::Temp;
+
+require Exporter;
+ at ISA = qw(Exporter);
+ at EXPORT = qw(assert_lib check_lib_or_exit);
+
+# localising prevents the warningness leaking out of this module
+local $^W = 1; # use warnings is a 5.6-ism
+
+_findcc(); # bomb out early if there's no compiler
+
+=head1 NAME
+
+Devel::CheckLib - check that a library is available
+
+=head1 DESCRIPTION
+
+Devel::CheckLib is a perl module that checks whether a particular C
+library is available, and dies if it is not.
+
+=head1 SYNOPSIS
+
+ # in a Makefile.PL or Build.PL
+ use lib qw(inc);
+ use Devel::CheckLib;
+
+ check_lib_or_exit( lib => 'jpeg' );
+ check_lib_or_exit( lib => [ 'iconv', 'jpeg' ] );
+
+ # or prompt for path to library and then do this:
+ check_lib_or_exit( lib => 'jpeg', libpath => $additional_path );
+
+=head1 HOW IT WORKS
+
+You pass named parameters to a function
+describing how to build and link to the library. Currently the only
+parameter supported is 'lib', which can be a string or an arrayref of
+several libraries. In the future, expect us to add something for
+checking that header files are available as well.
+
+It works by trying to compile this:
+
+ int main(void) { return 0; }
+
+and linking it to the specified libraries. If something pops out the end
+which looks executable, then we know that it worked.
+
+=head1 FUNCTIONS
+
+All of these take the same named parameters and are exported by default.
+To avoid exporting them, C<use Devel::CheckLib ()>.
+
+=head2 assert_lib
+
+Takes several named parameters.
+
+The value of C<lib> must be either a string with the name of a single
+library or a reference to an array of strings of library names. Depending
+on the compiler found, library names will be fed to the compiler either as
+C<-l> arguments or as C<.lib> file names. (E.g. C<-ljpeg> or C<jpeg.lib>)
+
+Likewise, C<libpath> must if provided either be a string or an array of strings
+representing additional paths to search for libraries.
+
+C<LIBS> must be a C<ExtUtils::MakeMaker>-style space-seperated list of
+libraries (each preceded by '-l') and directories (preceded by '-L').
+
+This will die with an error message if any of the libraries listed can
+not be found. B<Note>: dying in a Makefile.PL or Build.PL may provoke
+a 'FAIL' report from CPAN Testers' automated smoke testers. Use
+C<check_lib_or_exit> instead.
+
+=head2 check_lib_or_exit
+
+This behaves exactly the same as C<assert_lib()> except that instead of
+dieing, it warns (with exactly the same error message) and exits.
+This is intended for use in Makefile.PL / Build.PL
+when you might want to prompt the user for various paths and
+things before checking that what they've told you is sane.
+
+If a library isn't found, it exits with an exit value of 0 to avoid
+causing a CPAN Testers 'FAIL' report. CPAN Testers should ignore this
+result -- which is what you want if an external library dependency is not
+available.
+
+=cut
+
+sub check_lib_or_exit {
+ eval 'assert_lib(@_)';
+ if($@) {
+ warn $@;
+ exit;
+ }
+}
+
+sub assert_lib {
+ my %args = @_;
+ my (@libs, @libpaths);
+
+ @libs = (ref($args{lib}) ? @{$args{lib}} : $args{lib})
+ if $args{lib};
+ @libpaths = (ref($args{libpath}) ? @{$args{libpath}} : $args{libpath})
+ if $args{libpath};
+
+ # work-a-like for Makefile.PL's "LIBS" argument
+ if(defined($args{LIBS})) {
+ foreach my $arg (split(/\s+/, $args{LIBS})) {
+ die("LIBS argument badly-formed: $arg\n") unless($arg =~ /^-l/i);
+ push @{$arg =~ /^-l/ ? \@libs : \@libpaths}, substr($arg, 2);
+ }
+ }
+
+ my @cc = _findcc();
+ my($ch, $cfile) = File::Temp::tempfile(
+ 'assertlibXXXXXXXX', SUFFIX => '.c', UNLINK => 1
+ );
+ print $ch "int main(void) { return 0; }\n";
+ close($ch);
+
+ my @missing;
+ for my $lib ( @libs ) {
+ my $exefile = File::Temp::mktemp( 'assertlibXXXXXXXX' ) . $Config{_exe};
+ my @sys_cmd;
+ if ( $Config{cc} eq 'cl' ) { # Microsoft compiler
+ require Win32;
+ my @libpath = map {
+ q{/libpath:} . Win32::GetShortPathName($_)
+ } @libpaths;
+ @sys_cmd = (@cc, $cfile, "${lib}.lib", "/Fe$exefile",
+ "/link", @libpath
+ );
+ } elsif($Config{cc} =~ /bcc32(\.exe)?/) { # Borland
+ my @libpath = map { "-L$_" } @libpaths;
+ @sys_cmd = (@cc, "-o$exefile", "-l$lib", @libpath, $cfile);
+ } else { # Unix-ish
+ # gcc, Sun, AIX (gcc, cc)
+ my @libpath = map { "-L$_" } @libpaths;
+ @sys_cmd = (@cc, $cfile, "-o", "$exefile", "-l$lib", @libpath);
+ }
+ warn "# @sys_cmd\n" if $args{debug};
+ my $rv = $args{debug} ? system(@sys_cmd) : _quiet_system(@sys_cmd);
+ push @missing, $lib if $rv != 0 || ! -x $exefile;
+ _cleanup_exe($exefile);
+ }
+
+ unlink $cfile;
+ my $miss_string = join( q{, }, map { qq{'$_'} } @missing );
+ die("Can't build and link to $miss_string\n") if @missing;
+}
+
+sub _cleanup_exe {
+ my ($exefile) = @_;
+ my $ofile = $exefile;
+ $ofile =~ s/$Config{_exe}$/$Config{_o}/;
+ unlink $exefile if -f $exefile;
+ unlink $ofile if -f $ofile;
+ unlink "$exefile\.manifest" if -f "$exefile\.manifest";
+ return
+}
+
+sub _findcc {
+ my @paths = split(/$Config{path_sep}/, $ENV{PATH});
+ my @cc = split(/\s+/, $Config{cc});
+ return @cc if -x $cc[0];
+ foreach my $path (@paths) {
+ my $compiler = File::Spec->catfile($path, $cc[0]) . $Config{_exe};
+ return ($compiler, @cc[1 .. $#cc]) if -x $compiler;
+ }
+ die("Couldn't find your C compiler\n");
+}
+
+# code substantially borrowed from IPC::Run3
+sub _quiet_system {
+ my (@cmd) = @_;
+
+ # save handles
+ local *STDOUT_SAVE;
+ local *STDERR_SAVE;
+ open STDOUT_SAVE, ">&STDOUT" or die "CheckLib: $! saving STDOUT";
+ open STDERR_SAVE, ">&STDERR" or die "CheckLib: $! saving STDERR";
+
+ # redirect to nowhere
+ local *DEV_NULL;
+ open DEV_NULL, ">" . File::Spec->devnull
+ or die "CheckLib: $! opening handle to null device";
+ open STDOUT, ">&" . fileno DEV_NULL
+ or die "CheckLib: $! redirecting STDOUT to null handle";
+ open STDERR, ">&" . fileno DEV_NULL
+ or die "CheckLib: $! redirecting STDERR to null handle";
+
+ # run system command
+ my $rv = system(@cmd);
+
+ # restore handles
+ open STDOUT, ">&" . fileno STDOUT_SAVE
+ or die "CheckLib: $! restoring STDOUT handle";
+ open STDERR, ">&" . fileno STDERR_SAVE
+ or die "CheckLib: $! restoring STDERR handle";
+
+ return $rv;
+}
+
+=head1 PLATFORMS SUPPORTED
+
+You must have a C compiler installed. We check for C<$Config{cc}>,
+both literally as it is in Config.pm and also in the $PATH.
+
+It has been tested with varying degrees on rigourousness on:
+
+=over
+
+=item gcc (on Linux, *BSD, Solaris, Cygwin)
+
+=item Sun's compiler tools on Solaris
+
+=item IBM's tools on AIX
+
+=item Microsoft's tools on Windows
+
+=item MinGW on Windows (with Strawberry Perl)
+
+=item Borland's tools on Windows
+
+=back
+
+=head1 WARNINGS, BUGS and FEEDBACK
+
+This is a very early release intended primarily for feedback from
+people who have discussed it. The interface may change and it has
+not been adequately tested.
+
+Feedback is most welcome, including constructive criticism.
+Bug reports should be made using L<http://rt.cpan.org/> or by email.
+
+When submitting a bug report, please include the output from running:
+
+ perl -V
+ perl -MDevel::CheckLib
+
+=head1 SEE ALSO
+
+L<Devel::CheckOS>
+
+=head1 AUTHORS
+
+David Cantrell E<lt>david at cantrell.org.ukE<gt>
+
+David Golden E<lt>dagolden at cpan.orgE<gt>
+
+Thanks to the cpan-testers-discuss mailing list for prompting us to write it
+in the first place;
+
+to Chris Williams for help with Borland support.
+
+=head1 COPYRIGHT and LICENCE
+
+Copyright 2007 David Cantrell. Portions copyright 2007 David Golden.
+
+This module is free-as-in-speech software, and may be used, distributed,
+and modified under the same conditions as perl itself.
+
+=head1 CONSPIRACY
+
+This module is also free-as-in-mason software.
+
+=cut
+
+1;
Modified: trunk/libauthen-krb5-simple-perl/lib/Authen/Krb5/Simple.pm
URL: http://svn.debian.org/wsvn/trunk/libauthen-krb5-simple-perl/lib/Authen/Krb5/Simple.pm?rev=15870&op=diff
==============================================================================
--- trunk/libauthen-krb5-simple-perl/lib/Authen/Krb5/Simple.pm (original)
+++ trunk/libauthen-krb5-simple-perl/lib/Authen/Krb5/Simple.pm Thu Feb 28 13:54:09 2008
@@ -1,4 +1,4 @@
-# $Id: Simple.pm,v 1.6 2005/02/21 23:50:37 dstuart Exp $
+# $Id: Simple.pm,v 1.6 2005-02-21 23:50:37 dstuart Exp $
###############################################################################
#
# File: Simple.pm
@@ -21,7 +21,7 @@
our @ISA = qw(DynaLoader);
-our $VERSION = '0.32';
+our $VERSION = '0.40';
bootstrap Authen::Krb5::Simple $VERSION;
@@ -47,7 +47,7 @@
croak "Missing arg: password\n" unless(defined($pw));
if($pw eq '') {
- carp "Empty passwords are not supported.\n" if($pw eq '');
+ carp "Empty passwords are not supported.\n";
return 0;
}
@@ -64,25 +64,20 @@
# Return the error string from the most recent authenticate function.
#
sub errstr {
+ return ($_[0]->{_err_code} == 0) ? '' : krb5_errstr($_[0]->{_err_code});
+}
+
+# Return the error code from the most recent authenticate function.
+#
+sub errcode {
+ return $_[0]->{_err_code};
+}
+
+# Get or set the default realm
+#
+sub realm {
my $self = shift;
-
- return '' if($self->{_err_code} == 0);
-
- return krb5_errstr($self->{_err_code});
-}
-
-# Return the error code from the most recent authenticate function.
-#
-sub errcode {
- my $self = shift;
- return $self->{_err_code};
-}
-
-# Get or set the default realm
-#
-sub realm {
- my $self = shift;
- my $arg = shift;
+ my $arg = shift;
$self->{_realm} = $arg if(defined($arg));
@@ -125,7 +120,7 @@
# Create a new object pointing to another realm.
#
- my $alt_krb = Authen::Krb5::Simple->new(realm => 'new.realm');
+ my $alt_krb = Authen::Krb5::Simple->new(realm => 'OTHER.REALM');
...
=head1 DESCRIPTION
Modified: trunk/libauthen-krb5-simple-perl/t/01-compile.t
URL: http://svn.debian.org/wsvn/trunk/libauthen-krb5-simple-perl/t/01-compile.t?rev=15870&op=diff
==============================================================================
--- trunk/libauthen-krb5-simple-perl/t/01-compile.t (original)
+++ trunk/libauthen-krb5-simple-perl/t/01-compile.t Thu Feb 28 13:54:09 2008
@@ -1,4 +1,4 @@
-# $Id: 01-compile.t,v 1.1.1.1 2003/01/19 20:33:34 dstuart Exp $
+# $Id: 01-compile.t,v 1.1.1.1 2003-01-19 20:33:34 dstuart Exp $
###############################################################################
# Authen::Krb5::Simple Test Script
#
Modified: trunk/libauthen-krb5-simple-perl/t/02-ops.t
URL: http://svn.debian.org/wsvn/trunk/libauthen-krb5-simple-perl/t/02-ops.t?rev=15870&op=diff
==============================================================================
--- trunk/libauthen-krb5-simple-perl/t/02-ops.t (original)
+++ trunk/libauthen-krb5-simple-perl/t/02-ops.t Thu Feb 28 13:54:09 2008
@@ -1,4 +1,4 @@
-# $Id: 02-ops.t,v 1.1.1.1 2003/01/19 20:33:34 dstuart Exp $
+# $Id: 02-ops.t,v 1.1.1.1 2003-01-19 20:33:34 dstuart Exp $
###############################################################################
# Authen::Krb5::Simple Test Script
#
@@ -14,11 +14,11 @@
use Authen::Krb5::Simple;
-BEGIN { plan tests => 7 };
+BEGIN { plan tests => 10 };
# Get test user params (if any)
#
-my ($tuser, $tpw) = get_test_user();
+my $tdata = get_test_data();
my $krb = Authen::Krb5::Simple->new();
@@ -32,10 +32,16 @@
# Good pw
#
-if($tuser and $tpw) {
- $ret = $krb->authenticate($tuser, $tpw);
+if(defined($tdata->{user}) and defined($tdata->{password})) {
+ my $tuser = $tdata->{user};
+ my $tpass = $tdata->{password};
+
+ $tuser .= "\@$tdata->{realm}" if(defined($tdata->{realm}));
+
+ $ret = $krb->authenticate($tuser, $tpass);
+
my $errcode = $krb->errcode();
- my $errstr = $krb->errstr();
+ my $errstr = $krb->errstr();
print STDERR "\nGPW RET: $ret (code=$errcode, str=$errstr)\n" if($verbose);
@@ -44,13 +50,31 @@
# Valid error conditions
ok($errcode == 0);
ok($errstr eq '');
+
+ # Now munge the pw and make sure we get the expected responses
+ #
+ $ret = $krb->authenticate($tuser, "x$tpass");
+
+ $errcode = $krb->errcode();
+ $errstr = $krb->errstr();
+
+ print STDERR "\nGPW2 RET: $ret (code=$errcode, str=$errstr)\n" if($verbose);
+
+ ok(!$ret);
+
+ ok($errcode != 0);
+ ok($errstr ne '');
+
} else {
- skip(1,'Skipped user auth');
- skip(1,'Skipped user auth errcode');
- skip(1,'Skipped user auth errstr');
+ skip(1,'Skipped good auth');
+ skip(1,'Skipped good auth errcode');
+ skip(1,'Skipped good auth errstr');
+ skip(1,'Skipped bad auth');
+ skip(1,'Skipped bad auth errcode');
+ skip(1,'Skipped bad auth errstr');
}
-# Bad pw
+# Bad user and pw
#
$ret = $krb->authenticate('_xxx', '_xxx');
print STDERR "\nBPW RET: $ret\n" if($verbose);
@@ -60,8 +84,8 @@
ok($krb->errcode() != 0);
ok($krb->errstr());
-sub get_test_user {
- my ($user, $pw);
+sub get_test_data {
+ my %tdata;
unless(open(CONF, "<CONFIG")) {
print STDERR "\nUnable to read CONFIG file: $!\nSkipping user auth tests\n";
@@ -72,12 +96,13 @@
chomp;
next if(/^\s*#|^\s*$/);
- $user = $1 if(/^\s*TEST_USER\s+(.*)/);
- $pw = $1 if(/^\s*TEST_PASS\s+(.*)/);
+ $tdata{user} = $1 if(/^\s*TEST_USER\s+(.*)/);
+ $tdata{password} = $1 if(/^\s*TEST_PASS\s+(.*)/);
+ $tdata{realm} = $1 if(/^\s*TEST_REALM\s+(.*)/);
}
close(CONF);
- return(($user && $pw) ? ($user, $pw) : undef);
+ return(\%tdata);
}
###EOF###
More information about the Pkg-perl-cvs-commits
mailing list