]> git.sur5r.net Git - openldap/blob - servers/slapd/back-monitor/modify.c
refactor ABI for arbitrary attribute/entry/callback registration; propagate pointers...
[openldap] / servers / slapd / back-monitor / modify.c
1 /* modify.c - monitor backend modify routine */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 2001-2005 The OpenLDAP Foundation.
6  * Portions Copyright 2001-2003 Pierangelo Masarati.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted only as authorized by the OpenLDAP
11  * Public License.
12  *
13  * A copy of this license is available in file LICENSE in the
14  * top-level directory of the distribution or, alternatively, at
15  * <http://www.OpenLDAP.org/license.html>.
16  */
17 /* ACKNOWLEDGEMENTS:
18  * This work was initially developed by Pierangelo Masarati for inclusion
19  * in OpenLDAP Software.
20  */
21
22 #include "portable.h"
23
24 #include <stdio.h>
25
26 #include <ac/string.h>
27 #include <ac/socket.h>
28
29 #include "slap.h"
30 #include "back-monitor.h"
31 #include "proto-back-monitor.h"
32
33 int
34 monitor_back_modify( Operation *op, SlapReply *rs )
35 {
36         int             rc = 0;
37         monitor_info_t  *mi = ( monitor_info_t * )op->o_bd->be_private;
38         Entry           *matched;
39         Entry           *e;
40
41         Debug(LDAP_DEBUG_ARGS, "monitor_back_modify:\n", 0, 0, 0);
42
43         /* acquire and lock entry */
44         monitor_cache_dn2entry( op, rs, &op->o_req_ndn, &e, &matched );
45         if ( e == NULL ) {
46                 rs->sr_err = LDAP_NO_SUCH_OBJECT;
47                 if ( matched ) {
48 #ifdef SLAP_ACL_HONOR_DISCLOSE
49                         if ( !access_allowed_mask( op, matched,
50                                         slap_schema.si_ad_entry,
51                                         NULL, ACL_DISCLOSE, NULL, NULL ) )
52                         {
53                                 /* do nothing */ ;
54                         } else 
55 #endif /* SLAP_ACL_HONOR_DISCLOSE */
56                         {
57                                 rs->sr_matched = matched->e_dn;
58                         }
59                 }
60                 send_ldap_result( op, rs );
61                 if ( matched != NULL ) {
62                         rs->sr_matched = NULL;
63                         monitor_cache_release( mi, matched );
64                 }
65                 return rs->sr_err;
66         }
67
68         if ( !acl_check_modlist( op, e, op->oq_modify.rs_modlist )) {
69                 rc = LDAP_INSUFFICIENT_ACCESS;
70
71         } else {
72                 rc = monitor_entry_modify( op, rs, e );
73         }
74
75 #ifdef SLAP_ACL_HONOR_DISCLOSE
76         if ( rc != LDAP_SUCCESS ) {
77                 if ( !access_allowed_mask( op, e, slap_schema.si_ad_entry,
78                                 NULL, ACL_DISCLOSE, NULL, NULL ) )
79                 {
80                         rc = LDAP_NO_SUCH_OBJECT;
81                 }
82         }
83 #endif /* SLAP_ACL_HONOR_DISCLOSE */
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