Re: [vchkpw] vpopmail vpasswd file difference(s) between 4.9.10 and 5.3.8 (convert from cdb to mysql)
Just in case anyone else runs into this, I wrote a little Perl script that parses out /var/qmail/users/assign to fetch a list of domains that are active on the mail server. Then, for each domain it goes out and fetches the vpasswd file and feeds its contents into a SQL database. It works quite nicely. Matt #!/usr/bin/perl use strict; use DBI; my $host = 'localhost'; my $user = 'vpopmail'; my $password = 'secret'; my $db = 'vpopmail'; my $domainfile="/var/qmail/users/assign"; my @connect = ("dbi:mysql:database=$db:host=$host", $user, $password); my $dbh = DBI->connect(@connect); warn "@connect" unless $dbh; my @domainlist = get_domainlist( $domainfile ); foreach my $file ( @domainlist ) { #print "$file->{'dom'} \t $file->{'dir'} \n"; add_users( $file->{'dir'}, $file->{'dom'} ); }; $dbh->disconnect; print "All done.\n\n"; ## ## Subdomains ## sub get_domainlist { my @domainlist; print "Reading in the file $_[0]..."; open ( DOMAINLIST, $_[0] ) || die "couldn't open $_[0]: $!\n"; my @lines = ; close (DOMAINLIST) || die "couldn't close $_[0]: $!\n"; print "done.\n\n"; print "Extracting the list of domains..."; my $row = "0"; foreach my $line ( @lines ) { my @fields = split(":", $line); my %domain = ( dir => "$fields[4]/vpasswd", dom => "$fields[1]" ); $domainlist[$row] = \%domain; $row++; }; print "done.\n\n."; return @domainlist; } sub add_users { if ( -e $_[0] ) { open ( USERLIST, $_[0] ) || warn "couldn't open $_[0]: $!\n"; my @users = ; close (USERLIST); foreach my $user (@users) { chomp $user; my @f = split(":", $user); print "$user\n"; my $query = "INSERT INTO vpopmail SET pw_name=\"$f[0]\", pw_domain=\"$_[1]\", pw_passwd=\"$f[1]\", pw_uid=\"$f[2]\", pw_gid=\"$f[3]\", pw_gecos=\"$f[4]\", pw_dir=\"$f[5]\", pw_shell=\"$f[6]\""; my $sth = $dbh->prepare($query); $sth->execute; my $x = $DBI::errstr; if ($x) { print "Error running $query\n"; }; $sth->finish; }; }; } On Tuesday, September 24, 2002, at 04:03 PM, Matt Simerson wrote: > I'm rebuilding a dinosaur mail server that I built a couple years ago. > It's running vpopmail 4.9.10 using cdb authentication. I'm upgrading > to 5.3.8 with MySQL authentication. > > I've build out the new 5.3.8 system and cluster of machines. It's all > up, running and happy. I've NFS mounted all the home directories from > the old cluster onto the new system so that I have ready access to the > vpasswd and vpasswd.cdb files. They are mounted onto the local > filesystem so that the paths in /var/qmail/users/assign are correct. > > I run vconvert -c -m test.domain.com and it exits quietly indicating > success: > > mail8# ~vpopmail/bin/vconvert -c -m -v -d test.simerson.net > version: 5.3.8 > converting test.simerson.net done > > However, when I check the MySQL server, there's no entries in the > vpopmail table that correspond to that domain. :-( > > I've tested this one step further. I've manually added a valid user > ([EMAIL PROTECTED]) into the new mail system by manually adding > it into the MySQL table. It works fine, authenticates, etc. That > basically makes it work with my new mail system and the old one at the > same time. Cool. Anyway, if I run vconvert again, it'll actually > delete that entry from the vpopmail table. Is that supposed to > happen? > > Everything on the new system works just fine except the vconvert > function. Can anyone verify that vconvert actually does work? Can you > sanitize a copy of a newer vpasswd file and send it my way so I can > compare it to my ancient system to see if the format is still the > same? > > Matt >
Re: [vchkpw] vpopmail vpasswd file difference(s) between 4.9.10 and 5.3.8
That was it, thanks HD. Upon comparing his vpasswd file and mine, there's an extra field in the vpasswd file for the clear text password. If I merely add another colon to the end of each line in the vpasswd file, vconvert works just fine. I'd suggest updating the vconvert program so that it does not require the clear text password field to be present in order to function properly. That will make legacy installs much easier to upgrade. Lastly, I'm not entirely certain *why* running vconvert against my older vpasswd file deleted all mysql entries in the vpopmail table but it's not a safe behavior. Maybe it just removes all entries that match the domain before importing and then does the import. It would be a really good idea to verify that there's some new data capable of being inserted before deleting the old entries. Matt On Wednesday, September 25, 2002, at 11:18 AM, H. D. Lee wrote: > Hi Matt, > > On 2002.09.24_16:03:52_+, Matt Simerson wrote: >> Everything on the new system works just fine except the vconvert >> function. Can anyone verify that vconvert actually does work? > > Yes, it actually works. Below are the steps I have taken to come up > with > that statement: > 1. Compile and install 5.3.8 with cdb. > 2. Test create a domain (devel.dutnux.com) and some users. > 3. Recompile with mysql support, install, using 5.3.8. > 4. Invoke ./vconvert -c -m -v -d devel.dutnux.com > version: 5.3.8 > could not connect to mysql update server Unknown database 'vpopmail' > with database > converting devel.dutnux.com done > 5. I checked mysql, it created vpopmail database and table for me. > The vpopmail table contain exactly the user I created. > >> Can you sanitize a copy of a newer vpasswd file and send it my way so >> I can compare it to my ancient system to see if the format is still >> the same? > > This is the first line of the vpasswd file I have. It was created using > 5.3.8 with password learning support: > > postmaster:$1$R.O7J$cRKPnHXAkWuZ6epI94R.k/:1:0:Postmaster: > /home/vpopmail/domains/devel.dutnux.com/postmaster:10M:dutnux > > Sorry for the wrapped line. > >> Matt >> > > HTH > > -- > H. D. Lee >
Re: [vchkpw] vpopmail vpasswd file difference(s) between 4.9.10 and 5.3.8
Hi Matt, On 2002.09.24_16:03:52_+, Matt Simerson wrote: > Everything on the new system works just fine except the vconvert > function. Can anyone verify that vconvert actually does work? Yes, it actually works. Below are the steps I have taken to come up with that statement: 1. Compile and install 5.3.8 with cdb. 2. Test create a domain (devel.dutnux.com) and some users. 3. Recompile with mysql support, install, using 5.3.8. 4. Invoke ./vconvert -c -m -v -d devel.dutnux.com version: 5.3.8 could not connect to mysql update server Unknown database 'vpopmail' with database converting devel.dutnux.com done 5. I checked mysql, it created vpopmail database and table for me. The vpopmail table contain exactly the user I created. > Can you sanitize a copy of a newer vpasswd file and send it my way so > I can compare it to my ancient system to see if the format is still > the same? This is the first line of the vpasswd file I have. It was created using 5.3.8 with password learning support: postmaster:$1$R.O7J$cRKPnHXAkWuZ6epI94R.k/:1:0:Postmaster: /home/vpopmail/domains/devel.dutnux.com/postmaster:10M:dutnux Sorry for the wrapped line. > Matt > HTH -- H. D. Lee