3 # Convert vchkpw to userdb format.
5 # $Id: vchkpw2userdb.in,v 1.4 2000/02/16 01:12:13 mrsam Exp $
7 # Copyright 1998 - 1999 Double Precision, Inc. See COPYING for
8 # distribution information.
12 die "Invalid options.\n" unless
13 GetOptions("vpopmailhome=s" => \$vpopmailhome,
14 "todir=s" => \$todir);
16 if ( ! ( $vpopmailhome =~ /./ ))
18 (undef, undef, undef, undef, undef, undef, undef, $vpopmailhome)
19 = getpwnam("vpopmail");
21 die "Cannot find vpopmail home.\n" unless $vpopmailhome =~ /./;
24 -d "$vpopmailhome" || die "$vpopmailhome: not found.\n";
28 -d "$todir" || mkdir($todir, 0700) || die "$!\n";
33 if ($bindir =~ /^(.*)\/[^\/]*$/ )
42 die "Unable to locate pw2userdb.\n" unless -f "$bindir/pw2userdb";
48 $redir=">$todir/users-vpasswd";
49 -d "$todir/domains" || mkdir("$todir/domains", 0700) || die "$!\n";
52 if ( -f "$vpopmailhome/users/vpasswd")
54 $rc=system ("$bindir/pw2userdb --vpopuid --passwd='$vpopmailhome/users/vpasswd' --noshadow --nouid $redir");
55 exit $rc / 256 if $rc;
58 if ( opendir(DIR, "$vpopmailhome/domains"))
60 while ($domain=readdir(DIR))
62 $domainopt="--domain='$domain'";
63 $domainopt="" if $domain eq "default";
64 next if $domain eq "." || $domain eq "..";
65 next unless -f "$vpopmailhome/domains/$domain/vpasswd";
69 $redir=">$todir/domains/$domain";
70 $redir=">$todir/users-default"
71 if $domain eq "default";
74 $rc=system ("$bindir/pw2userdb --passwd='$vpopmailhome/domains/$domain/vpasswd' --vpopuid --noshadow --nouid $domainopt $redir");
76 exit $rc / 256 if $rc != 0;