1 /* modify.c - shell backend modify function */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
13 #include <ac/socket.h>
29 struct shellinfo *si = (struct shellinfo *) be->be_private;
30 AttributeDescription *entry = slap_schema.si_ad_entry;
35 if ( si->si_modify == NULL ) {
36 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
37 "modify not implemented", NULL, NULL );
50 if ( ! access_allowed( be, conn, op, &e,
51 entry, NULL, ACL_WRITE, NULL ) )
53 send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
54 NULL, NULL, NULL, NULL );
58 if ( (op->o_private = (void *) forkandexec( si->si_modify, &rfp, &wfp ))
60 send_ldap_result( conn, op, LDAP_OTHER, NULL,
61 "could not fork/exec", NULL, NULL );
65 /* write out the request to the modify process */
66 fprintf( wfp, "MODIFY\n" );
67 fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
68 print_suffixes( wfp, be );
69 fprintf( wfp, "dn: %s\n", dn->bv_val );
70 for ( ; ml != NULL; ml = ml->sml_next ) {
73 /* FIXME: should use LDIF routines to deal with binary data */
75 switch ( mod->sm_op ) {
77 fprintf( wfp, "add: %s\n", mod->sm_desc->ad_cname.bv_val );
81 fprintf( wfp, "delete: %s\n", mod->sm_desc->ad_cname.bv_val );
84 case LDAP_MOD_REPLACE:
85 fprintf( wfp, "replace: %s\n", mod->sm_desc->ad_cname.bv_val );
89 if( mod->sm_bvalues != NULL ) {
90 for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
91 fprintf( wfp, "%s: %s\n", mod->sm_desc->ad_cname.bv_val,
92 mod->sm_bvalues[i].bv_val /* binary! */ );
96 fprintf( wfp, "-\n" );
100 /* read in the results and send them along */
101 read_and_send_results( be, conn, op, rfp, NULL, 0 );