]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/unbind.c
ca091da4361990c75f316340cf8d4efddb15f420
[openldap] / servers / slapd / back-shell / unbind.c
1 /* unbind.c - shell backend unbind function */
2 /* $OpenLDAP$ */
3
4 #include "portable.h"
5
6 #include <stdio.h>
7
8 #include <ac/socket.h>
9 #include <ac/string.h>
10
11 #include "slap.h"
12 #include "shell.h"
13
14 int
15 shell_back_unbind(
16     Backend             *be,
17     Connection          *conn,
18     Operation           *op
19 )
20 {
21         struct shellinfo        *si = (struct shellinfo *) be->be_private;
22         FILE                    *rfp, *wfp;
23
24         if ( si->si_unbind == NULL ) {
25                 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
26                     "unbind not implemented", NULL, NULL );
27                 return 0;
28         }
29
30         if ( (op->o_private = (void *) forkandexec( si->si_unbind, &rfp, &wfp ))
31             == (void *) -1 ) {
32                 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
33                     "could not fork/exec", NULL, NULL );
34                 return 0;
35         }
36
37         /* write out the request to the unbind process */
38         fprintf( wfp, "UNBIND\n" );
39         fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
40         print_suffixes( wfp, be );
41         fprintf( wfp, "dn: %s\n", (conn->c_dn ? conn->c_dn : "") );
42         fclose( wfp );
43
44         /* no response to unbind */
45         fclose( rfp );
46
47         return 0;
48 }