1 /* add.c - shell backend add 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>
23 struct shellinfo *si = (struct shellinfo *) op->o_bd->be_private;
24 AttributeDescription *entry = slap_schema.si_ad_entry;
28 if ( si->si_add == NULL ) {
29 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
30 "add not implemented" );
34 if ( ! access_allowed( op, op->oq_add.rs_e,
35 entry, NULL, ACL_WRITE, NULL ) )
37 send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS, NULL );
41 if ( (op->o_private = (void *) forkandexec( si->si_add, &rfp, &wfp )) == (void *) -1 ) {
42 send_ldap_error( op, rs, LDAP_OTHER,
43 "could not fork/exec" );
47 /* write out the request to the add process */
48 fprintf( wfp, "ADD\n" );
49 fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
50 print_suffixes( wfp, op->o_bd );
51 ldap_pvt_thread_mutex_lock( &entry2str_mutex );
52 fprintf( wfp, "%s", entry2str( op->oq_add.rs_e, &len ) );
53 ldap_pvt_thread_mutex_unlock( &entry2str_mutex );
56 /* read in the result and send it along */
57 read_and_send_results( op, rs, rfp );