Home | History | Annotate | Line # | Download | only in back-monitor
modify.c revision 1.1.1.4.10.1
      1 /*	$NetBSD: modify.c,v 1.1.1.4.10.1 2017/04/21 16:52:30 bouyer Exp $	*/
      2 
      3 /* modify.c - monitor backend modify routine */
      4 /* $OpenLDAP$ */
      5 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
      6  *
      7  * Copyright 2001-2016 The OpenLDAP Foundation.
      8  * Portions Copyright 2001-2003 Pierangelo Masarati.
      9  * All rights reserved.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted only as authorized by the OpenLDAP
     13  * Public License.
     14  *
     15  * A copy of this license is available in file LICENSE in the
     16  * top-level directory of the distribution or, alternatively, at
     17  * <http://www.OpenLDAP.org/license.html>.
     18  */
     19 /* ACKNOWLEDGEMENTS:
     20  * This work was initially developed by Pierangelo Masarati for inclusion
     21  * in OpenLDAP Software.
     22  */
     23 
     24 #include <sys/cdefs.h>
     25 __RCSID("$NetBSD: modify.c,v 1.1.1.4.10.1 2017/04/21 16:52:30 bouyer Exp $");
     26 
     27 #include "portable.h"
     28 
     29 #include <stdio.h>
     30 
     31 #include <ac/string.h>
     32 #include <ac/socket.h>
     33 
     34 #include "slap.h"
     35 #include "back-monitor.h"
     36 #include "proto-back-monitor.h"
     37 
     38 int
     39 monitor_back_modify( Operation *op, SlapReply *rs )
     40 {
     41 	int 		rc = 0;
     42 	monitor_info_t	*mi = ( monitor_info_t * )op->o_bd->be_private;
     43 	Entry		*matched;
     44 	Entry		*e;
     45 
     46 	Debug(LDAP_DEBUG_ARGS, "monitor_back_modify:\n", 0, 0, 0);
     47 
     48 	/* acquire and lock entry */
     49 	monitor_cache_dn2entry( op, rs, &op->o_req_ndn, &e, &matched );
     50 	if ( e == NULL ) {
     51 		rs->sr_err = LDAP_NO_SUCH_OBJECT;
     52 		if ( matched ) {
     53 			if ( !access_allowed_mask( op, matched,
     54 					slap_schema.si_ad_entry,
     55 					NULL, ACL_DISCLOSE, NULL, NULL ) )
     56 			{
     57 				/* do nothing */ ;
     58 			} else {
     59 				rs->sr_matched = matched->e_dn;
     60 			}
     61 		}
     62 		send_ldap_result( op, rs );
     63 		if ( matched != NULL ) {
     64 			rs->sr_matched = NULL;
     65 			monitor_cache_release( mi, matched );
     66 		}
     67 		return rs->sr_err;
     68 	}
     69 
     70 	if ( !acl_check_modlist( op, e, op->orm_modlist )) {
     71 		rc = LDAP_INSUFFICIENT_ACCESS;
     72 
     73 	} else {
     74 		assert( !SLAP_SHADOW( op->o_bd ) );
     75 		slap_mods_opattrs( op, &op->orm_modlist, 0 );
     76 
     77 		rc = monitor_entry_modify( op, rs, e );
     78 	}
     79 
     80 	if ( rc != LDAP_SUCCESS ) {
     81 		if ( !access_allowed_mask( op, e, slap_schema.si_ad_entry,
     82 				NULL, ACL_DISCLOSE, NULL, NULL ) )
     83 		{
     84 			rc = LDAP_NO_SUCH_OBJECT;
     85 		}
     86 	}
     87 
     88 	rs->sr_err = rc;
     89 	send_ldap_result( op, rs );
     90 
     91 	monitor_cache_release( mi, e );
     92 
     93 	return rs->sr_err;
     94 }
     95 
     96