~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to support/SHA1/convert-sha1.pl

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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