1 1.3 christos /* $NetBSD: modify.c,v 1.4 2025/09/05 21:16:28 christos Exp $ */ 2 1.2 christos 3 1.1 lukem /* modify.c - monitor backend modify 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: modify.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 <ac/string.h> 32 1.1 lukem #include <ac/socket.h> 33 1.1 lukem 34 1.1 lukem #include "slap.h" 35 1.1 lukem #include "back-monitor.h" 36 1.1 lukem #include "proto-back-monitor.h" 37 1.1 lukem 38 1.1 lukem int 39 1.1 lukem monitor_back_modify( Operation *op, SlapReply *rs ) 40 1.1 lukem { 41 1.1 lukem int rc = 0; 42 1.1 lukem monitor_info_t *mi = ( monitor_info_t * )op->o_bd->be_private; 43 1.1 lukem Entry *matched; 44 1.1 lukem Entry *e; 45 1.1 lukem 46 1.3 christos Debug(LDAP_DEBUG_ARGS, "monitor_back_modify:\n" ); 47 1.1 lukem 48 1.1 lukem /* acquire and lock entry */ 49 1.1 lukem monitor_cache_dn2entry( op, rs, &op->o_req_ndn, &e, &matched ); 50 1.1 lukem if ( e == NULL ) { 51 1.1 lukem rs->sr_err = LDAP_NO_SUCH_OBJECT; 52 1.1 lukem if ( matched ) { 53 1.1 lukem if ( !access_allowed_mask( op, matched, 54 1.1 lukem slap_schema.si_ad_entry, 55 1.1 lukem NULL, ACL_DISCLOSE, NULL, NULL ) ) 56 1.1 lukem { 57 1.1 lukem /* do nothing */ ; 58 1.1 lukem } else { 59 1.1 lukem rs->sr_matched = matched->e_dn; 60 1.1 lukem } 61 1.1 lukem } 62 1.1 lukem send_ldap_result( op, rs ); 63 1.1 lukem if ( matched != NULL ) { 64 1.1 lukem rs->sr_matched = NULL; 65 1.1 lukem monitor_cache_release( mi, matched ); 66 1.1 lukem } 67 1.1 lukem return rs->sr_err; 68 1.1 lukem } 69 1.1 lukem 70 1.1 lukem if ( !acl_check_modlist( op, e, op->orm_modlist )) { 71 1.1 lukem rc = LDAP_INSUFFICIENT_ACCESS; 72 1.1 lukem 73 1.1 lukem } else { 74 1.1 lukem assert( !SLAP_SHADOW( op->o_bd ) ); 75 1.1 lukem slap_mods_opattrs( op, &op->orm_modlist, 0 ); 76 1.1 lukem 77 1.1 lukem rc = monitor_entry_modify( op, rs, e ); 78 1.1 lukem } 79 1.1 lukem 80 1.1 lukem if ( rc != LDAP_SUCCESS ) { 81 1.1 lukem if ( !access_allowed_mask( op, e, slap_schema.si_ad_entry, 82 1.1 lukem NULL, ACL_DISCLOSE, NULL, NULL ) ) 83 1.1 lukem { 84 1.1 lukem rc = LDAP_NO_SUCH_OBJECT; 85 1.1 lukem } 86 1.1 lukem } 87 1.1 lukem 88 1.1 lukem rs->sr_err = rc; 89 1.1 lukem send_ldap_result( op, rs ); 90 1.1 lukem 91 1.1 lukem monitor_cache_release( mi, e ); 92 1.1 lukem 93 1.1 lukem return rs->sr_err; 94 1.1 lukem } 95 1.1 lukem 96