]> git.sur5r.net Git - openldap/blob - servers/slapd/back-monitor/modify.c
4c82fede7ee82df0be0ce0e9fccdefb847d3d52f
[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-2003 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         Backend         *be,
37         Connection      *conn,
38         Operation       *op,
39         struct berval   *dn,
40         struct berval   *ndn,
41         Modifications   *modlist
42         */
43 {
44         int                     rc = 0;
45         struct monitorinfo      *mi
46                 = (struct monitorinfo *) op->o_bd->be_private;
47         Entry                   *matched;
48         Entry                   *e;
49
50 #ifdef NEW_LOGGING
51         LDAP_LOG( BACK_MON, ENTRY, "monitor_back_modify: enter\n", 0, 0, 0 );
52 #else
53         Debug(LDAP_DEBUG_ARGS, "monitor_back_modify:\n", 0, 0, 0);
54 #endif
55
56         /* acquire and lock entry */
57         monitor_cache_dn2entry( op, &op->o_req_ndn, &e, &matched );
58         if ( e == NULL ) {
59                 rs->sr_err = LDAP_NO_SUCH_OBJECT;
60                 if ( matched ) {
61                         rs->sr_matched = matched->e_name.bv_val;
62                 }
63                 send_ldap_result( op, rs );
64                 if ( matched != NULL ) {
65                         rs->sr_matched = NULL;
66                         monitor_cache_release( mi, matched );
67                 }
68                 return( 0 );
69         }
70
71         if ( !acl_check_modlist( op, e, op->oq_modify.rs_modlist )) {
72                 rc = LDAP_INSUFFICIENT_ACCESS;
73         } else {
74                 rc = monitor_entry_modify( op, e );
75         }
76
77         rs->sr_err = rc;
78         send_ldap_result( op, rs );
79
80         monitor_cache_release( mi, e );
81
82         return( 0 );
83 }
84