I have been struggling with setting up Qmail to work on my Linux box. I can
send email from the machine, and at one point could send email to a valid
email address on that machine, although that is not working now, but that's
as far as I can get.
I've been through lots of docs, and I'm not sure where the break is, so I'm
hoping someone can help me trouble shoot.
Here's the specs:
Linux 5.2 on i386
Qmail (current version)
I.P. 204.144.178.140
I get this error when I try to send mail via a pop client on another
machine:
Your server has unexpectedly terminated the connection. Possible causes for
this include server problems, network problems, or a long period of
inactivity.
If I "telnet localhost 110" I get:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
If I run /var/mail/bin/qmail-pop3d I get:
-ERR this user has no $HOME/Maildir
If I run /var/mail/bin/instcheck I get:
instcheck: warning: /var/qmail/users has wrong permissions
(I changed this to 777 to be safe, and don't know what the correct
permissions are.)
Typing "ps" gives me:
PID TTY STAT TIME COMMAND
457 2 S 0:00 /sbin/mingetty tty2
458 3 S 0:00 /sbin/mingetty tty3
459 4 S 0:00 /sbin/mingetty tty4
460 5 S 0:00 /sbin/mingetty tty5
461 6 S 0:00 /sbin/mingetty tty6
1001 1 S 0:00 -bash
10296 p1 S 0:00 bash
10850 p2 S 0:00 su
10854 p2 S 0:00 bash
11771 p2 S 0:00 su
11773 p2 S 0:00 bash
11885 p2 S 0:00 su
11889 p2 S 0:00 bash
12817 p2 T 0:00 vi inetd.cong
12836 p2 T 0:00 vi inetd.conf
26571 p2 R 0:00 ps
Relevant lines from /etc/inetd.conf:
smtp stream tcp nowait qmaild /var/qmail/bin/tcp-env tcp-env
/var/qmail/bin/qmail-smtp
pop-3 stream tcp nowait root /var/qmail/bin qmail-popup
/var/qmail/bin checkpasswd /var/qmail/bin qmail-pop3d
I installed the check checkpasswd package, and wrote the Perl script below
to try to allow account creating via cgi. (Don't bother warning me about
taint checking, I'll put that in when I find out where the big problems
are.)
If there are other checks/test I can run please let me know.
I am really stuck here, any help would be much appreciated.
Thanks in advance,
Peter Janett
#!/usr/bin/perl -U
#
# Peter's user setup script
# This adds a Qmail POP3 user via http
# It uses qmail patches available at
# http://www.tibus.net/pgregg/projects/
# password files
$assign = "/var/qmail/users/assign";
$assign_BU = "/var/qmail/users/assign_BU";
$poppasswd = "/var/qmail/users/poppasswd";
$poppasswd_BU = "/var/qmail/users/poppasswd_BU";
#Use cgi-lib.pl to parse data
require "/home/httpd/cgi-bin/library/cgi-lib.pl";
&ReadParse(*FORM);
print "Content-type: text/html\n\n";
print<<"EEE";
<HTML>
<BODY>
EEE
# Backup assign file
# Open file, read into @bu
# to create a backup
open(DATAFILE, "$assign") || print "I can't Open file, read into bu $!\n";
flock DATAFILE, 2;
@bu=<DATAFILE>;
close(DATAFILE);
flock DATAFILE, 8;
# write data to backup file
open(BU, ">$assign_BU") || print "I can't write to backup file $!\n";
flock BU, 2;
foreach $line (@bu) {
chomp $line;
unless ($line eq "."){print BU "$line\n";}
}
close(BU);
flock BU, 8;
# check for username and ID dups,
open(DATAFILE, "$assign") || print "I can't check for username and ID dups
$!\n";
flock DATAFILE, 2;
while(<DATAFILE>) {
($username, $popidusername, $popid, $popgrpid,
$homedir, @junk) = split (/:/, $_);
$cleanedusername = $username;
$cleanedusername =~ s/=domain\-com\-//g;
# Found exising username
if ($cleanedusername eq $FORM{'username'}){
print "<H1>USERNAME $FORM{'username'} already taken\!\!</H1>";
print<<"EEE";
</BODY>
</HTML>
EEE
exit;
}
} # End while <DATAFILE>
close(DATAFILE);
flock DATAFILE, 8;
# write new data to assign file
open(ASSIGN, ">$assign") || print "I can't write write new data to assign
file $!\n";
flock ASSIGN, 2;
foreach $line (@bu) {
chomp $line;
unless ($line eq "."){print ASSIGN "$line\n";}
}
print ASSIGN
"=domain-com-$FORM{'username'}:popuser:888:231:/var/qmail/popboxes/domain-co
m/$FORM{'username'}:::\n.";
close(ASSIGN);
flock ASSIGN, 8;
# encrypt password
$pw = &GetPword;
###############################################################
# Backup passwd file
# Open file, read into @bu
# to create a backup
###############################################################
open(DATAFILE, "$poppasswd") || print "I can't Open poppasswd file, to read
into bu $!<P>\n";
flock DATAFILE, 2;
@bu=<DATAFILE>;
close(DATAFILE);
flock DATAFILE, 8;
# write data to backup file
open(BU, ">$poppasswd_BU") || print "I can't write to $poppasswd_BU backup
file $!<P>\n";
flock BU, 2;
foreach $line (@bu) {
chomp $line;
print BU "$line\n";
}
close(BU);
flock BU, 8;
# write new data to assign file
open(ASSIGN, ">>$poppasswd") || print "I can't write write new data to
$poppassword file $!<P>\n";
flock ASSIGN, 2;
print ASSIGN
"$FORM{'username'}:$pw:popuser:/var/qmail/popboxes/domain-com/$FORM{'usernam
e'}\n";
close(ASSIGN);
flock ASSIGN, 8;
###############################################################
###############################################################
# Create user directories with .qmail files inside
###############################################################
system("mkdir /var/qmail/popboxes/domain-com/$FORM{'username'};chown popuser
/var/qmail/popboxes/domain-com/$FORM{'username'};
chgrp -R popusers /var/qmail/popboxes/domain-com/$FORM{'username'};chmod 700
/var/qmail/popboxes/domain-com/$FORM{'username'}");
###############################################################
# Now create a .qmail file for delivery
###############################################################
$dot_qmail = "/var/qmail/popboxes/domain-com/$FORM{'username'}/.qmail";
print "<H1>$dot_qmail</H1>";
open(QMAIL, ">$dot_qmail") || print "I can't write write the .qmail file
$!<P>\n";
flock QMAIL, 2;
print QMAIL
'./Mailbox';
close(QMAIL);
flock QMAIL, 8;
system("chown popuser
/var/qmail/popboxes/domain-com/$FORM{'username'}/.qmail;
chgrp -R popusers /var/qmail/popboxes/domain-com/$FORM{'username'}/.qmail");
# update the cab file
system('/var/qmail/bin/qmail-newu');
###############################################################
print<<"EEE";
<H2>User: $FORM{'username'} added</H2>
=domain-com-$FORM{'username'}:popuser:888:231:/var/qmail/popboxes/domain-com
/$FORM{'username'}:::
</BODY>
</HTML>
EEE
################ subroutines ###############################
# Subroutine to prompt for and return (encrypted) password.
sub GetPword {
my ( $pwd1, $pwd2, $salt, $crypted );
my @saltchars = (a .. z, A .. Z, 0 .. 9);
$pwd1 = $FORM{'username'};
# Generate a random salt value for encryption:
srand(time || $$);
$salt = $saltchars[rand($#saltchars)] . $saltchars[rand($#saltchars)];
return crypt($pwd1, $salt);
}