X-Git-Url: http://git.rot13.org/?p=virtual-ldap;a=blobdiff_plain;f=bin%2Fldap-rewrite.pl;h=a6eff6e7791e02ba877f671830ef4ea1e7df8837;hp=d3d8da0c2cd177304a55e9c064f528f2ffc9236e;hb=24a2710e5e18cee3bbe8e2a3caf00bb7349adcd1;hpb=cc919bb8c5863d65db2cab4a7937521ba3ba5e28 diff --git a/bin/ldap-rewrite.pl b/bin/ldap-rewrite.pl index d3d8da0..a6eff6e 100755 --- a/bin/ldap-rewrite.pl +++ b/bin/ldap-rewrite.pl @@ -24,9 +24,23 @@ my $config = { upstream_ldap => 'ldap.ffzg.hr', upstream_ssl => 1, overlay_prefix => 'ffzg-', + log_file => 'log', }; +my $log_fh; + +sub log { + open($log_fh, '>', $config->{log_file}) || die "can't open ", $config->{log_file},": $!"; + $log_fh->autoflush(1); + print $log_fh join("\n", @_),"\n"; +} + +BEGIN { + $SIG{'__WARN__'} = sub { warn @_; main::log(@_); } +} + + if ( ! -d $config->{yaml_dir} ) { warn "DISABLE ", $config->{yaml_dir}," data overlay"; } @@ -108,12 +122,11 @@ sub log_response { foreach my $type ( keys %$data ) { my $vals = $data->{$type}; - $vals =~ s{#\s*$}{}; - - my @vals = split(/\s*#\s*/, $vals); - push @{ $response->{protocolOp}->{searchResEntry}->{attributes} }, - { type => $config->{overlay_prefix} . $type, vals => [ @vals ] }; + push @{ $response->{protocolOp}->{searchResEntry}->{attributes} }, { + type => $config->{overlay_prefix} . $type, + vals => ref($vals) eq 'ARRAY' ? $vals : [ $vals ], + }; } } @@ -154,6 +167,8 @@ sub run_proxy { } +$ENV{LANG} = 'C'; # so we don't double-encode utf-8 if LANG is utf-8 + my $listenersock = IO::Socket::INET->new( Listen => 5, Proto => 'tcp',