version 1.5.2.1, 2009/12/11 23:12:24
|
version 1.9, 2011/01/28 08:40:52
|
Line 1
|
Line 1
|
/* compare.c - sock backend compare function */ |
/* compare.c - sock backend compare function */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/back-sock/compare.c,v 1.5 2009/01/21 23:40:37 kurt Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/back-sock/compare.c,v 1.8 2011/01/28 08:11:18 hyc Exp $ */ |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
* Copyright 1998-2009 The OpenLDAP Foundation. |
* Copyright 1998-2011 The OpenLDAP Foundation. |
* All rights reserved. |
* All rights reserved. |
* |
* |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
Line 27
|
Line 27
|
|
|
#include "slap.h" |
#include "slap.h" |
#include "back-sock.h" |
#include "back-sock.h" |
|
#include "ldif.h" |
|
|
int |
int |
sock_back_compare( |
sock_back_compare( |
Line 34 sock_back_compare(
|
Line 35 sock_back_compare(
|
SlapReply *rs ) |
SlapReply *rs ) |
{ |
{ |
struct sockinfo *si = (struct sockinfo *) op->o_bd->be_private; |
struct sockinfo *si = (struct sockinfo *) op->o_bd->be_private; |
|
AttributeDescription *entry = slap_schema.si_ad_entry; |
Entry e; |
Entry e; |
FILE *fp; |
FILE *fp; |
AclCheck ak = { &e, slap_schema.si_ad_entry, NULL, ACL_COMPARE, NULL }; |
char *text; |
|
|
e.e_id = NOID; |
e.e_id = NOID; |
e.e_name = op->o_req_dn; |
e.e_name = op->o_req_dn; |
Line 47 sock_back_compare(
|
Line 49 sock_back_compare(
|
e.e_bv.bv_val = NULL; |
e.e_bv.bv_val = NULL; |
e.e_private = NULL; |
e.e_private = NULL; |
|
|
if ( ! access_allowed( op, &ak )) |
if ( ! access_allowed( op, &e, |
|
entry, NULL, ACL_COMPARE, NULL ) ) |
{ |
{ |
send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS, NULL ); |
send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS, NULL ); |
return -1; |
return -1; |
Line 59 sock_back_compare(
|
Line 62 sock_back_compare(
|
return( -1 ); |
return( -1 ); |
} |
} |
|
|
/* |
|
* FIX ME: This should use LDIF routines so that binary |
|
* values are properly dealt with |
|
*/ |
|
|
|
/* write out the request to the compare process */ |
/* write out the request to the compare process */ |
fprintf( fp, "COMPARE\n" ); |
fprintf( fp, "COMPARE\n" ); |
fprintf( fp, "msgid: %ld\n", (long) op->o_msgid ); |
fprintf( fp, "msgid: %ld\n", (long) op->o_msgid ); |
sock_print_conn( fp, op->o_conn, si ); |
sock_print_conn( fp, op->o_conn, si ); |
sock_print_suffixes( fp, op->o_bd ); |
sock_print_suffixes( fp, op->o_bd ); |
fprintf( fp, "dn: %s\n", op->o_req_dn.bv_val ); |
fprintf( fp, "dn: %s\n", op->o_req_dn.bv_val ); |
fprintf( fp, "%s: %s\n", |
/* could be binary */ |
op->oq_compare.rs_ava->aa_desc->ad_cname.bv_val, |
text = ldif_put_wrap( LDIF_PUT_VALUE, |
op->oq_compare.rs_ava->aa_value.bv_val /* could be binary! */ ); |
op->orc_ava->aa_desc->ad_cname.bv_val, |
fclose( fp ); |
op->orc_ava->aa_value.bv_val, |
|
op->orc_ava->aa_value.bv_len, LDIF_LINE_WIDTH_MAX ); |
|
if ( text ) { |
|
fprintf( fp, "%s\n", text ); |
|
ber_memfree( text ); |
|
} else { |
|
fprintf( fp, "\n\n" ); |
|
} |
|
|
/* read in the result and send it along */ |
/* read in the result and send it along */ |
sock_read_and_send_results( op, rs, fp ); |
sock_read_and_send_results( op, rs, fp ); |