1/*	$NetBSD: modify.c,v 1.1.1.3 2010/12/12 15:23:16 adam Exp $	*/
2
3/* modify.c - monitor backend modify routine */
4/* OpenLDAP: pkg/ldap/servers/slapd/back-monitor/modify.c,v 1.24.2.6 2010/04/13 20:23:33 kurt Exp */
5/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
6 *
7 * Copyright 2001-2010 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 "portable.h"
25
26#include <stdio.h>
27
28#include <ac/string.h>
29#include <ac/socket.h>
30
31#include "slap.h"
32#include "back-monitor.h"
33#include "proto-back-monitor.h"
34
35int
36monitor_back_modify( Operation *op, SlapReply *rs )
37{
38	int 		rc = 0;
39	monitor_info_t	*mi = ( monitor_info_t * )op->o_bd->be_private;
40	Entry		*matched;
41	Entry		*e;
42
43	Debug(LDAP_DEBUG_ARGS, "monitor_back_modify:\n", 0, 0, 0);
44
45	/* acquire and lock entry */
46	monitor_cache_dn2entry( op, rs, &op->o_req_ndn, &e, &matched );
47	if ( e == NULL ) {
48		rs->sr_err = LDAP_NO_SUCH_OBJECT;
49		if ( matched ) {
50			if ( !access_allowed_mask( op, matched,
51					slap_schema.si_ad_entry,
52					NULL, ACL_DISCLOSE, NULL, NULL ) )
53			{
54				/* do nothing */ ;
55			} else {
56				rs->sr_matched = matched->e_dn;
57			}
58		}
59		send_ldap_result( op, rs );
60		if ( matched != NULL ) {
61			rs->sr_matched = NULL;
62			monitor_cache_release( mi, matched );
63		}
64		return rs->sr_err;
65	}
66
67	if ( !acl_check_modlist( op, e, op->orm_modlist )) {
68		rc = LDAP_INSUFFICIENT_ACCESS;
69
70	} else {
71		assert( !SLAP_SHADOW( op->o_bd ) );
72		slap_mods_opattrs( op, &op->orm_modlist, 0 );
73
74		rc = monitor_entry_modify( op, rs, e );
75	}
76
77	if ( rc != LDAP_SUCCESS ) {
78		if ( !access_allowed_mask( op, e, slap_schema.si_ad_entry,
79				NULL, ACL_DISCLOSE, NULL, NULL ) )
80		{
81			rc = LDAP_NO_SUCH_OBJECT;
82		}
83	}
84
85	rs->sr_err = rc;
86	send_ldap_result( op, rs );
87
88	monitor_cache_release( mi, e );
89
90	return rs->sr_err;
91}
92
93