20090313 important bug in netldapldif - plembo/onemoretech GitHub Wiki

title: Important bug in Net::LDAP::LDIF link: https://onemoretech.wordpress.com/2009/03/13/important-bug-in-netldapldif/ author: lembobro description: post_id: 360 created: 2009/03/13 21:14:10 created_gmt: 2009/03/13 21:14:10 comment_status: open post_name: important-bug-in-netldapldif status: publish post_type: post

Important bug in Net::LDAP::LDIF

Working on my new workstation today, I discovered what to me is an important bug in recent versions of perl-ldap (a/k/a Net::LDAP).

The problem is with the current_lines method in LDIF.pm, which is supposed to allow you to dump all lines of an LDIF entry to STDOUT or another filehandle. Basically the 0.18 version of LDIF.pm that comes with perl-ldap 0.39 fails to display anything.

After some experimentation I found that the latest version that actually works is 0.16, that shipped with perl-ldap 0.33 many years ago. Interestingly, the 0.16 version of LDIF.pm that comes with Ubuntu’s libnet-ldap-perl package does not exactly match what comes with the perl-ldap 0.33 distribution.

So I’ve filed my first bug report for my favorite perl module.

As a workaround I have compiled LDIF.pm from the 0.33 perl-ldap distribution and copied it over what was installed there by Ubuntu’s package in /usr/share/perl5/Net/LDAP.

POSTCRIPT:

You have to love open source. Graham Barr, the author of perl-ldap, found the origin of this bug in a commit made almost 4 years ago.

He suggested I try adding

$self->{_current_lines} = $entry; $self->{_next_lines} = $entry;

"just before the un-wrappingof the lines". I found that location in the latest distribution of LDIF.pm between lines 128 and 129. After inserting the recommended code there I recompiled and copied the resulting LDIF.pm over the existing module. Testing showed the fix worked perfectly. Per a later message from Graham this bug will be fixed in the next release.

Download fixed LDIF.pm file from here, and copy over existing, until then.

BEST PRACTICE NOTE:

Recently I decided to segregate modified modules out from the main perl distribution on my own systems. What I came up with is a new “Custom” category. On most systems these would live someplace like /usr/local/lib/perl5/site_perl/5.10.0/Custom. On Ubuntu it would be /usr/local/lib/perl/5.10.0/Custom. As a result it now gets invoked as:

Custom::Net::LDAP::LDIF

The only thing you need to do to make this work is change the package declaration in the first line of the module to:

package Custom::Net::LDAP::LDIF

Copyright 2004-2019 Phil Lembo