1 1.3 christos /* $NetBSD: compare.c,v 1.4 2025/09/05 21:16:28 christos Exp $ */ 2 1.2 christos 3 1.1 lukem /* compare.c - monitor backend compare routine */ 4 1.2 christos /* $OpenLDAP$ */ 5 1.1 lukem /* This work is part of OpenLDAP Software <http://www.openldap.org/>. 6 1.1 lukem * 7 1.4 christos * Copyright 2001-2024 The OpenLDAP Foundation. 8 1.1 lukem * Portions Copyright 2001-2003 Pierangelo Masarati. 9 1.1 lukem * All rights reserved. 10 1.1 lukem * 11 1.1 lukem * Redistribution and use in source and binary forms, with or without 12 1.1 lukem * modification, are permitted only as authorized by the OpenLDAP 13 1.1 lukem * Public License. 14 1.1 lukem * 15 1.1 lukem * A copy of this license is available in file LICENSE in the 16 1.1 lukem * top-level directory of the distribution or, alternatively, at 17 1.1 lukem * <http://www.OpenLDAP.org/license.html>. 18 1.1 lukem */ 19 1.1 lukem /* ACKNOWLEDGEMENTS: 20 1.1 lukem * This work was initially developed by Pierangelo Masarati for inclusion 21 1.1 lukem * in OpenLDAP Software. 22 1.1 lukem */ 23 1.1 lukem 24 1.2 christos #include <sys/cdefs.h> 25 1.3 christos __RCSID("$NetBSD: compare.c,v 1.4 2025/09/05 21:16:28 christos Exp $"); 26 1.2 christos 27 1.1 lukem #include "portable.h" 28 1.1 lukem 29 1.1 lukem #include <stdio.h> 30 1.1 lukem 31 1.1 lukem #include <slap.h> 32 1.1 lukem #include "back-monitor.h" 33 1.1 lukem 34 1.1 lukem int 35 1.1 lukem monitor_back_compare( Operation *op, SlapReply *rs ) 36 1.1 lukem { 37 1.1 lukem monitor_info_t *mi = ( monitor_info_t * ) op->o_bd->be_private; 38 1.1 lukem Entry *e, *matched = NULL; 39 1.1 lukem int rc; 40 1.1 lukem 41 1.1 lukem /* get entry with reader lock */ 42 1.1 lukem monitor_cache_dn2entry( op, rs, &op->o_req_ndn, &e, &matched ); 43 1.1 lukem if ( e == NULL ) { 44 1.1 lukem rs->sr_err = LDAP_NO_SUCH_OBJECT; 45 1.1 lukem if ( matched ) { 46 1.1 lukem if ( !access_allowed_mask( op, matched, 47 1.1 lukem slap_schema.si_ad_entry, 48 1.1 lukem NULL, ACL_DISCLOSE, NULL, NULL ) ) 49 1.1 lukem { 50 1.1 lukem /* do nothing */ ; 51 1.1 lukem } else { 52 1.1 lukem rs->sr_matched = matched->e_dn; 53 1.1 lukem } 54 1.1 lukem } 55 1.1 lukem send_ldap_result( op, rs ); 56 1.1 lukem if ( matched ) { 57 1.1 lukem monitor_cache_release( mi, matched ); 58 1.1 lukem rs->sr_matched = NULL; 59 1.1 lukem } 60 1.1 lukem 61 1.1 lukem return rs->sr_err; 62 1.1 lukem } 63 1.1 lukem 64 1.2 christos monitor_entry_update( op, rs, e ); 65 1.2 christos rs->sr_err = slap_compare_entry( op, e, op->orc_ava ); 66 1.1 lukem rc = rs->sr_err; 67 1.1 lukem switch ( rc ) { 68 1.1 lukem case LDAP_COMPARE_FALSE: 69 1.1 lukem case LDAP_COMPARE_TRUE: 70 1.1 lukem rc = LDAP_SUCCESS; 71 1.1 lukem break; 72 1.1 lukem } 73 1.1 lukem 74 1.1 lukem send_ldap_result( op, rs ); 75 1.1 lukem rs->sr_err = rc; 76 1.1 lukem 77 1.1 lukem monitor_cache_release( mi, e ); 78 1.1 lukem 79 1.1 lukem return rs->sr_err; 80 1.1 lukem } 81 1.1 lukem 82