3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 2007-2010 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
17 ## This work was initially developed by Brian Candler for inclusion
18 ## in OpenLDAP Software.
20 # See: http://search.cpan.org/dist/Net-Server/
26 use Net::Server::PreFork; # any personality will do
28 @ISA = qw(Net::Server::PreFork);
31 port=>"/tmp/example.sock|unix"
32 #conf_file=>"/etc/example.conf"
36 ### over-ridden subs below
37 # The protocol is the same as back-shell
44 local $SIG{ALRM} = sub { die "Timed Out!\n" };
45 my $timeout = 30; # give the user 30 seconds to type a line
48 my $request = <STDIN>;
50 if ($request eq "SEARCH\n") {
52 while (my $line = <STDIN>) {
55 if ($line =~ /^([^:]+):\s*(.*)$/) { # FIXME: handle base64 encoded
59 #sleep(2); # to test concurrency
60 print "dn: cn=test, dc=example, dc=com\n";
62 print "objectclass: cnobject\n";
66 print "info: answered by process $$\n";
70 print "code: 53\n"; # unwillingToPerform
71 print "info: I don't implement $request";
77 if( $@=~/timed out/i ){
79 print "code: 3\n"; # timeLimitExceeded
80 print "info: Timed out\n";
84 print "code: 1\n"; # operationsError
85 print "info: $@\n"; # FIXME: remove CR/LF