]> git.sur5r.net Git - openldap/blob - servers/slapd/back-perl/bind.c
Add a safety check to bvcasechr
[openldap] / servers / slapd / back-perl / bind.c
1 /* $OpenLDAP$ */
2 /*
3  *       Copyright 1999, John C. Quillan, All rights reserved.
4  *
5  *       Redistribution and use in source and binary forms are permitted only
6  *       as authorized by the OpenLDAP Public License.  A copy of this
7  *       license is available at http://www.OpenLDAP.org/license.html or
8  *       in file LICENSE in the top-level directory of the distribution.
9  */
10
11 #include "portable.h"
12 /* init.c - initialize shell backend */
13         
14 #include <stdio.h>
15 /*      #include <ac/types.h>
16         #include <ac/socket.h>
17 */
18
19 #include <EXTERN.h>
20 #include <perl.h>
21
22 #include "slap.h"
23 #include "perl_back.h"
24
25
26 /**********************************************************
27  *
28  * Bind
29  *
30  **********************************************************/
31 int
32 perl_back_bind(
33         Backend *be,
34         Connection *conn,
35         Operation *op,
36         struct berval *dn,
37         struct berval *ndn,
38         int method,
39         struct berval *cred,
40         struct berval *edn
41 )
42 {
43         int return_code;
44         int count;
45
46         PerlBackend *perl_back = (PerlBackend *) be->be_private;
47
48         ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );  
49
50         {
51                 dSP; ENTER; SAVETMPS;
52
53                 PUSHMARK(sp);
54                 XPUSHs( perl_back->pb_obj_ref );
55                 XPUSHs(sv_2mortal(newSVpv( dn->bv_val , 0)));
56                 XPUSHs(sv_2mortal(newSVpv( cred->bv_val , cred->bv_len)));
57                 PUTBACK;
58
59                 count = perl_call_method("bind", G_SCALAR);
60
61                 SPAGAIN;
62
63                 if (count != 1) {
64                         croak("Big trouble in back_bind\n");
65                 }
66
67                 return_code = POPi;
68                                                          
69
70                 PUTBACK; FREETMPS; LEAVE;
71         }
72
73         ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );        
74
75         Debug( LDAP_DEBUG_ANY, "Perl BIND\n", 0, 0, 0 );
76
77         return ( return_code );
78 }
79
80