4 # This is public domain code. Do whatever you want with it.
5 # It was originally included in Clinton Wong's Apache 1.3.6 SHA1/ldif
6 # patch distribution as sample code for converting accounts from
7 # ldif format (as used by Netscape web servers) to Apache password format.
12 while (my $line = <>) {
14 if ( $line =~ /uid:\s*(.+)/) { $uid = $1 }
15 if ( $line =~ /userpassword:\s*(\{\w+\}.+)/) {
17 $passwd =~ s/^\{crypt\}//i; # Apache stores crypt without a magic string
20 if (length($line)==0) {
22 if (length $uid and length $passwd) {
23 print $uid, ':', $passwd, "\n";
24 } # output if we have something to print
30 } # while something to read
32 # handle last entry if there isn't a newline before EOF
33 if (length $uid and length $passwd) {
34 print $uid, ':', $passwd, "\n";