upload http
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / support / SHA1 / convert-sha1.pl
1 #!/usr/bin/perl -w
2 use strict;
3
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.
8
9 my $uid='';
10 my $passwd='';
11
12 while (my $line = <>) {
13   chomp $line;
14   if ( $line =~ /uid:\s*(.+)/) { $uid = $1 }
15   if ( $line =~ /userpassword:\s*(\{\w+\}.+)/) {
16     $passwd = $1;
17     $passwd =~ s/^\{crypt\}//i;  # Apache stores crypt without a magic string
18   }
19
20   if (length($line)==0) {
21
22     if (length $uid and length $passwd) {
23       print $uid, ':', $passwd, "\n";
24     } # output if we have something to print
25
26     $uid = '';
27     $passwd = '';
28
29   } # if newline
30 } # while something to read
31
32 # handle last entry if there isn't a newline before EOF
33     if (length $uid and length $passwd) {
34   print $uid, ':', $passwd, "\n";
35 }
36