diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 11:11:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 11:11:40 +0000 |
commit | 7731832751ab9f3c6ddeb66f186d3d7fa1934a6d (patch) | |
tree | e91015872543a59be2aad26c2fea02e41b57005d /servers/slapd/back-sock/searchexample.pl | |
parent | Initial commit. (diff) | |
download | openldap-7731832751ab9f3c6ddeb66f186d3d7fa1934a6d.tar.xz openldap-7731832751ab9f3c6ddeb66f186d3d7fa1934a6d.zip |
Adding upstream version 2.4.57+dfsg.upstream/2.4.57+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | servers/slapd/back-sock/searchexample.pl | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/servers/slapd/back-sock/searchexample.pl b/servers/slapd/back-sock/searchexample.pl new file mode 100644 index 0000000..a9b066c --- /dev/null +++ b/servers/slapd/back-sock/searchexample.pl @@ -0,0 +1,90 @@ +#!/usr/bin/perl -w -T +# $OpenLDAP$ +## This work is part of OpenLDAP Software <http://www.openldap.org/>. +## +## Copyright 2007-2021 The OpenLDAP Foundation. +## All rights reserved. +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted only as authorized by the OpenLDAP +## Public License. +## +## A copy of this license is available in the file LICENSE in the +## top-level directory of the distribution or, alternatively, at +## <http://www.OpenLDAP.org/license.html>. +## +## ACKNOWLEDGEMENTS: +## This work was initially developed by Brian Candler for inclusion +## in OpenLDAP Software. + +# See: http://search.cpan.org/dist/Net-Server/ + +package ExampleDB; + +use strict; +use vars qw(@ISA); +use Net::Server::PreFork; # any personality will do + +@ISA = qw(Net::Server::PreFork); + +ExampleDB->run( + port=>"/tmp/example.sock|unix" + #conf_file=>"/etc/example.conf" +); +exit; + +### over-ridden subs below +# The protocol is the same as back-shell + +sub process_request { + my $self = shift; + + eval { + + local $SIG{ALRM} = sub { die "Timed Out!\n" }; + my $timeout = 30; # give the user 30 seconds to type a line + alarm($timeout); + + my $request = <STDIN>; + + if ($request eq "SEARCH\n") { + my %req = (); + while (my $line = <STDIN>) { + chomp($line); + last if $line eq ""; + if ($line =~ /^([^:]+):\s*(.*)$/) { # FIXME: handle base64 encoded + $req{$1} = $2; + } + } + #sleep(2); # to test concurrency + print "dn: cn=test, dc=example, dc=com\n"; + print "cn: test\n"; + print "objectclass: cnobject\n"; + print "\n"; + print "RESULT\n"; + print "code: 0\n"; + print "info: answered by process $$\n"; + } + else { + print "RESULT\n"; + print "code: 53\n"; # unwillingToPerform + print "info: I don't implement $request"; + } + + }; + + return unless $@; + if( $@=~/timed out/i ){ + print "RESULT\n"; + print "code: 3\n"; # timeLimitExceeded + print "info: Timed out\n"; + } + else { + print "RESULT\n"; + print "code: 1\n"; # operationsError + print "info: $@\n"; # FIXME: remove CR/LF + } + +} + +1; |