Add quick documentation blurb for SASL mechanisms. Make SASL

dependency optional.

FossilOrigin-Name: e26346acaa34dbbe2911cf29e44e345c2a58af3ef4f8e9b5791959f8adda1501
This commit is contained in:
mahlon@laika.com 2013-12-03 19:11:02 +00:00
parent 648e7850ba
commit f4f7d7cc60

View file

@ -145,6 +145,15 @@ credentials.
=back =back
=item B<sasl>
A space separated list of SASL mechanisms. Requires the Authen::SASL
module.
--sasl "PLAIN CRAM-MD5 GSSAPI"
=back
=over 4 =over 4
=item B<tls> =item B<tls>
@ -419,7 +428,6 @@ use warnings;
use Term::ReadKey; use Term::ReadKey;
use Term::Shell; use Term::Shell;
use Digest::MD5; use Digest::MD5;
use Authen::SASL;
use Net::LDAP qw/ use Net::LDAP qw/
LDAP_SUCCESS LDAP_SUCCESS
LDAP_SERVER_DOWN LDAP_SERVER_DOWN
@ -562,23 +570,39 @@ You may try connecting insecurely, or install the module and try again.\n} if $@
} }
} }
my $sasl; eval 'use Authen::SASL';
my $sasl_conn; my ( $sasl, $sasl_conn );
if ($conf->{'mech'}) { my $has_sasl = ! defined( $@ );
if ( $has_sasl && $conf->{'sasl'} ) {
my $serv = $conf->{'server'}; my $serv = $conf->{'server'};
$serv =~ s!^ldap[si]?://!!; $serv =~ s!^ldap[si]?://!!;
$sasl = Authen::SASL->new(mechanism=>$conf->{'mech'}); $sasl = Authen::SASL->new( mechanism => $conf->{'sasl'} );
$sasl_conn = $sasl->client_new('ldap', $serv); $sasl_conn = $sasl->client_new('ldap', $serv);
} }
# bind as an authenicated dn # bind with sasl
if ( $conf->{'binddn'} ) { #
if ( $has_sasl && $sasl_conn ) {
$rv = $ldap->bind( $rv = $ldap->bind(
$conf->{'binddn'}, $conf->{'binddn'},
password => $conf->{'bindpass'}, password => $conf->{'bindpass'},
sasl => $sasl_conn); sasl => $sasl_conn
);
}
# simple bind as an authenticated dn
#
elsif ( $conf->{'binddn'} ) {
$rv = $ldap->bind(
$conf->{'binddn'},
password => $conf->{'bindpass'}
);
}
# bind anonymously # bind anonymously
} else { #
else {
$rv = $ldap->bind(sasl => $sasl_conn); $rv = $ldap->bind(sasl => $sasl_conn);
} }
@ -2197,7 +2221,7 @@ Getopt::Long::GetOptions(
'cacheage=i', 'cacheage=i',
'promptpass|W', 'promptpass|W',
'timeout=i', 'timeout=i',
'mech|Y=s', 'sasl|Y=s',
'tls_cacert=s', 'tls_cacert=s',
'tls_cert=s', 'tls_cert=s',
'tls_key=s', 'tls_key=s',