Back to index

openldap  2.4.31
modify.c
Go to the documentation of this file.
00001 /* modify.c - monitor backend modify routine */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 2001-2012 The OpenLDAP Foundation.
00006  * Portions Copyright 2001-2003 Pierangelo Masarati.
00007  * All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted only as authorized by the OpenLDAP
00011  * Public License.
00012  *
00013  * A copy of this license is available in file LICENSE in the
00014  * top-level directory of the distribution or, alternatively, at
00015  * <http://www.OpenLDAP.org/license.html>.
00016  */
00017 /* ACKNOWLEDGEMENTS:
00018  * This work was initially developed by Pierangelo Masarati for inclusion
00019  * in OpenLDAP Software.
00020  */
00021 
00022 #include "portable.h"
00023 
00024 #include <stdio.h>
00025 
00026 #include <ac/string.h>
00027 #include <ac/socket.h>
00028 
00029 #include "slap.h"
00030 #include "back-monitor.h"
00031 #include "proto-back-monitor.h"
00032 
00033 int
00034 monitor_back_modify( Operation *op, SlapReply *rs )
00035 {
00036        int           rc = 0;
00037        monitor_info_t       *mi = ( monitor_info_t * )op->o_bd->be_private;
00038        Entry         *matched;
00039        Entry         *e;
00040 
00041        Debug(LDAP_DEBUG_ARGS, "monitor_back_modify:\n", 0, 0, 0);
00042 
00043        /* acquire and lock entry */
00044        monitor_cache_dn2entry( op, rs, &op->o_req_ndn, &e, &matched );
00045        if ( e == NULL ) {
00046               rs->sr_err = LDAP_NO_SUCH_OBJECT;
00047               if ( matched ) {
00048                      if ( !access_allowed_mask( op, matched,
00049                                    slap_schema.si_ad_entry,
00050                                    NULL, ACL_DISCLOSE, NULL, NULL ) )
00051                      {
00052                             /* do nothing */ ;
00053                      } else {
00054                             rs->sr_matched = matched->e_dn;
00055                      }
00056               }
00057               send_ldap_result( op, rs );
00058               if ( matched != NULL ) {
00059                      rs->sr_matched = NULL;
00060                      monitor_cache_release( mi, matched );
00061               }
00062               return rs->sr_err;
00063        }
00064 
00065        if ( !acl_check_modlist( op, e, op->orm_modlist )) {
00066               rc = LDAP_INSUFFICIENT_ACCESS;
00067 
00068        } else {
00069               assert( !SLAP_SHADOW( op->o_bd ) );
00070               slap_mods_opattrs( op, &op->orm_modlist, 0 );
00071 
00072               rc = monitor_entry_modify( op, rs, e );
00073        }
00074 
00075        if ( rc != LDAP_SUCCESS ) {
00076               if ( !access_allowed_mask( op, e, slap_schema.si_ad_entry,
00077                             NULL, ACL_DISCLOSE, NULL, NULL ) )
00078               {
00079                      rc = LDAP_NO_SUCH_OBJECT;
00080               }
00081        }
00082 
00083        rs->sr_err = rc;
00084        send_ldap_result( op, rs );
00085 
00086        monitor_cache_release( mi, e );
00087 
00088        return rs->sr_err;
00089 }
00090