Public domain
daemontools original download link
daemontools patch original download link
mkdir -p /usr/local/daemontools/{package,command,service}
ln -sfn /usr/local/daemontools/command /command
ln -sfn /usr/local/daemontools/service /service
cd /usr/src
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/daemontools-0.76.tar.gz"
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Patches/daemontools-0.76.errno.patch"
tar -C /usr/local/daemontools/package -zxpf daemontools-0.76.tar.gz
cd /usr/local/daemontools/package/admin/daemontools-0.76
patch -p1 < /usr/src/daemontools-0.76.errno.patch
package/install
if ! grep -q svscanboot /etc/inittab
then echo "SV:123456:respawn:/command/svscanboot" >> /etc/inittab
fi
init q
ps auxw | grep svs
ucspi-tcp original download link
ucspi-tcp patch original download link
rblsmtpd patch original download link
cd /usr/src
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/ucspi-tcp-0.88.tar.gz"
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Patches/ucspi-tcp-0.88.errno.patch"
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Patches/rblsmtpd-nodefaultrbl.patch"
tar zxf ucspi-tcp-0.88.tar.gz
cd ucspi-tcp-0.88
patch -p1 < ../ucspi-tcp-0.88.errno.patch
patch -p1 < ../rblsmtpd-nodefaultrbl.patch
make
make setup check
netqmail original download link
mkdir -p /usr/local/qmail
ln -sfn /usr/local/qmail /var/qmail
groupadd nofiles
useradd -g nofiles -d /var/qmail/alias alias
useradd -g nofiles -d /var/qmail qmaild
useradd -g nofiles -d /var/qmail qmaill
useradd -g nofiles -d /var/qmail qmailp
groupadd qmail
useradd -g qmail -d /var/qmail qmailq
useradd -g qmail -d /var/qmail qmailr
useradd -g qmail -d /var/qmail qmails
cd /usr/src/
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/netqmail-1.06.tar.gz"
tar zxf netqmail-1.06.tar.gz
cd netqmail-1.06
make setup check
cd /usr/src
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/libev-3.9.tar.gz"
tar zxf libev-3.9.tar.gz
cd libev-3.9
./configure && make && make install
ldconfig
mysql_install_db --user=mysql
chmod +x /etc/rc.d/rc.mysqld
/etc/rc.d/rc.mysqld start
sleep 5
mysql -e "drop database test"
mysql -e "delete from mysql.user where user=''"
HOSTS=$(mysql -e "select host, user from mysql.user" | awk '{ if (/root/) print $1}')
QUERY=""
for HOST in $HOSTS; do
QUERY="set password for 'root'@'${HOST}' = password ('passdb');${QUERY}"
done
mysql -e "${QUERY}"
mysql -ppassdb -e "CREATE DATABASE vpopmail"
mysql -ppassdb -e "GRANT select,insert,update,delete,create,drop ON vpopmail.* TO vpopmail@localhost IDENTIFIED BY 'passvpop'"
vpopmail original download link
groupadd -g 89 vchkpw
useradd -m -g vchkpw -u 89 -d /var/qmail/vpopmail vpopmail
mkdir -p /var/qmail/vpopmail/etc/
cd /usr/src
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/vpopmail-5.5.0.tar.bz2"
tar jxf vpopmail-5.5.0.tar.bz2
chown -R root.root vpopmail-5.5.0
cd vpopmail-5.5.0
echo "localhost|0|vpopmail|passvpop|vpopmail" > /var/qmail/vpopmail/etc/vpopmail.mysql
chown vpopmail.vchkpw /var/qmail/vpopmail/etc/vpopmail.mysql
chmod 640 /var/qmail/vpopmail/etc/vpopmail.mysql
touch /var/qmail/control/tcp.smtp
./configure \
--enable-logging=p \
--enable-passwd=n \
--enable-roaming-users \
--enable-clear-passwd \
--enable-tcpserver-file=/var/qmail/control/tcp.smtp
make
cd backends/mysql/
./configure \
--enable-valias \
--disable-auth-logging
make
mkdir -p /var/qmail/vpopmail/lib/
make install
cd ../..
make install-strip
chown -R vpopmail.vchkpw /var/qmail/vpopmail
cp vusaged/contrib/rc.vusaged /etc/rc.d/
chmod +x /etc/rc.d/rc.vusaged
echo "if [ -x /etc/rc.d/rc.vusaged ];then /etc/rc.d/rc.vusaged start ;fi" >> /etc/rc.d/rc.local
if ! grep -q vpopmail /etc/ld.so.conf ; then echo "/usr/local/qmail/vpopmail/lib/" >> /etc/ld.so.conf ;fi
ldconfig
#!/bin/sh
PATH="/var/qmail/bin:$PATH"
export PATH
QMAILDUID=$(id -u qmaild)
NOFILESGID=$(id -g qmaild)
case "$1" in
start)
echo "Starting qmail MTA ..."
if svok /service/qmail-send ; then
svc -u /service/qmail-send /service/qmail-send/log
else
echo "qmail-send supervise not running"
fi
if svok /service/qmail-smtpd ; then
svc -u /service/qmail-smtpd /service/qmail-smtpd/log
else
echo "qmail-smtpd supervise not running"
fi
;;
stop)
echo "Stopping qmail MTA ..."
echo " qmail-smtpd"
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo " qmail-send"
svc -d /service/qmail-send /service/qmail-send/log
;;
stat)
svstat /service/qmail-send
svstat /service/qmail-send/log
svstat /service/qmail-smtpd
svstat /service/qmail-smtpd/log
qmail-qstat
;;
doqueue|alrm|flush)
echo "Flushing timeout table and sending ALRM signal to qmail-send."
/var/qmail/bin/qmail-tcpok
svc -a /service/qmail-send
;;
queue)
qmail-qstat
qmail-qread
;;
reload|hup)
echo "Sending HUP signal to qmail-send."
svc -h /service/qmail-send
;;
pause)
echo "Pausing qmail-send"
svc -p /service/qmail-send
echo "Pausing qmail-smtpd"
svc -p /service/qmail-smtpd
;;
cont)
echo "Continuing qmail-send"
svc -c /service/qmail-send
echo "Continuing qmail-smtpd"
svc -c /service/qmail-smtpd
;;
restart)
echo "Restarting qmail:"
echo "* Stopping qmail-smtpd."
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo "* Sending qmail-send SIGTERM and restarting."
svc -t /service/qmail-send /service/qmail-send/log
echo "* Restarting qmail-smtpd."
svc -u /service/qmail-smtpd /service/qmail-smtpd/log
;;
cdb)
tcprules /var/qmail/control/tcp.smtp.cdb /var/qmail/control/tcp.smtp.tmp < /var/qmail/control/tcp.smtp
chmod 644 /var/qmail/control/tcp.smtp.cdb
echo "Reloaded /var/qmail/control/tcp.smtp"
;;
help)
cat <<HELP
stop -- stops mail service (smtp connections refused, nothing goes out)
start -- starts mail service (smtp connection accepted, mail can go out)
pause -- temporarily stops mail service (connections accepted, nothing leaves)
cont -- continues paused mail service
stat -- displays status of mail service
cdb -- rebuild the tcpserver cdb file for smtp
restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it
doqueue -- schedules queued messages for immediate delivery
reload -- sends qmail-send HUP, rereading locals and virtualdomains
queue -- shows status of queue
alrm -- same as doqueue
flush -- same as doqueue
hup -- same as reload
HELP
;;
*)
echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}"
exit 1
;;
esac
chmod +x /var/qmail/bin/qmailctl
ln -sfn /var/qmail/bin/qmailctl /usr/bin
mkdir -p /var/qmail/supervise/qmail-{send,smtpd}/log
mv /usr/sbin/sendmail /usr/sbin/sendmail.old
chmod 0 /usr/sbin/sendmail.old
ln -s /var/qmail/bin/sendmail /usr/sbin
#!/bin/sh
# Using stdout for logging
# Using control/defaultdelivery from qmail-local to deliver messages by default
exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start "$(cat /var/qmail/control/defaultdelivery)"
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t s10485760 n100 /var/qmail/log/send
#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
exit 1
fi
exec /usr/local/bin/softlimit -m 2000000 \
/usr/local/bin/tcpserver -v -H -R -l "$LOCAL" -x /var/qmail/control/tcp.smtp.cdb -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 smtp /var/qmail/bin/qmail-smtpd "$LOCAL" \
/var/qmail/vpopmail/bin/vchkpw /bin/true 2>&1
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t s10485760 n100 /var/qmail/log/smtpd
/var/qmail/vpopmail/bin/vadddomain professorhack.com 123456
/var/qmail/vpopmail/bin/vaddaliasdomain professorhack.com mail.professorhack
/var/qmail/vpopmail/bin/vadduser pejman@professorhack.com test123
/var/qmail/vpopmail/bin/valias -i postmaster@professorhack.com root@professorhack.com
/var/qmail/vpopmail/bin/valias -i postmaster@professorhack.com mailer-daemon@professorhack.com
/var/qmail/vpopmail/bin/valias -i postmaster@professorhack.com abuse@professorhack.com
/var/qmail/vpopmail/bin/valias -v professorhack.com
echo ./Maildir/ > /var/qmail/control/defaultdelivery
echo 20 > /var/qmail/control/concurrencyincoming
chmod 644 /var/qmail/control/concurrencyincoming
echo mail.professorhack.com > /var/qmail/control/me
echo professorhack.com > /var/qmail/control/helohost
chmod 644 /var/qmail/control/me
echo professorhack.com > /var/qmail/control/doublebouncehost
echo doublebounce > /var/qmail/control/doublebounceto
echo "#" > /var/qmail/vpopmail/domains/professorhack.com/.qmail-doublebounce
| /var/qmail/vpopmail/bin/vdelivermail '' delete
echo '127.0.0.1:allow,RELAYCLIENT=""' >> /var/qmail/control/tcp.smtp
qmailctl cdb
chmod 755 /var/qmail/supervise/qmail-send/run
chmod 755 /var/qmail/supervise/qmail-send/log/run
chmod 755 /var/qmail/supervise/qmail-smtpd/run
chmod 755 /var/qmail/supervise/qmail-smtpd/log/run
mkdir -p /var/qmail/log/{smtpd,send}
chown -R qmaill /var/qmail/log/
/etc/rc.d/rc.vusaged start
ln -s /var/qmail/supervise/qmail-send /service
ln -s /var/qmail/supervise/qmail-smtpd /service
sleep 5
ps -A | grep qmail
netstat -a | egrep "smtp|pop3"
qmailctl stat
ps -efl | grep "service errors" | grep -v grep
cd /usr/src
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/dovecot-1.2.11.tar.gz"
tar zxf dovecot-1.2.11.tar.gz
cd dovecot-1.2.11
./configure \
--prefix=/usr/local/qmail/dovecot \
--with-checkpassword \
--with-prefetch-userdb \
--without-static-userdb \
--without-vpopmail \
--without-passwd \
--without-passwd-file \
--without-shadow \
--without-nss
make && make install
groupadd dovecot
useradd -g dovecot dovecot
mkdir -p /var/qmail/log/dovecot
mkdir -p /usr/local/qmail/dovecot/var/run/dovecot
cd /usr/local/qmail/dovecot/etc
cp dovecot-example.conf dovecot.conf
sed 's,#.*$,,' dovecot.conf | grep -v '^ *$'
protocols = imap
listen = 127.0.0.1
disable_plaintext_auth = no
log_path = /var/qmail/log/dovecot/error.log
info_log_path = /var/qmail/log/dovecot/info.log
ssl = no
mail_location = maildir:~/Maildir
mail_uid = 89
mail_gid = 89
first_valid_uid = 89
last_valid_uid = 89
first_valid_gid = 89
last_valid_gid = 89
protocol imap {
}
protocol pop3 {
}
protocol lda {
}
auth default {
mechanisms = plain
#passdb pam {
#}
passdb checkpassword {
args = /var/qmail/vpopmail/bin/vchkpw
}
userdb prefetch {
}
#userdb passwd {
#}
user = root
count = 1
}
dict {
}
plugin {
}
/usr/local/qmail/dovecot/sbin/dovecot -n
#!/bin/sh
PROCESS="dovecot"
PREFIX="/usr/local/qmail/dovecot"
DAEMON="$PREFIX/sbin/dovecot"
PIDFILE="$PREFIX/var/run/dovecot/master.pid"
TIMEOUT="100"
start()
{
echo -n "Starting $PROCESS . . ."
PID=$(ps -A | egrep " ${PROCESS}$" | awk '{print$1}')
if [ "$PID" != "" ]; then
echo "$PROCESS is already running (PID=$PID)"
else
if [ -f $PIDFILE ] ; then
rm $PIDFILE
fi
$DAEMON > /dev/null 2>&1
echo " Ok"
fi
}
stop()
{
echo -n "Stoping $PROCESS . . ."
PID=$(ps -A | egrep " ${PROCESS}$" | awk '{print$1}')
if [ "$PID" != "" ] ; then
kill -TERM $PID
sleep 1
fi
time=0
while [ $time != "$TIMEOUT" ] ; do
PID=$(ps -A | egrep " ${PROCESS}$" | awk '{print$1}')
if [ "$PID" == "" ] ; then
break
else
time=`expr $time + 1`
echo -n ".$time"
sleep 1
fi
done
echo " Ok"
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
sleep 1
start
;;
*)
echo "usage $0 start|stop|restart"
;;
esac
#!/bin/bash
# Dovecot Recovery
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin"
if ! ps ax | grep -v grep | egrep -q '/dovecot$'; then
/etc/rc.d/rc.dovecot restart
fi
echo "if [ -x /etc/rc.d/rc.dovecot ]; then /etc/rc.d/rc.dovecot start ;fi" >> /etc/rc.d/rc.local
echo "if [ -x /etc/rc.d/rc.dovecot ]; then /etc/rc.d/rc.dovecot stop ;fi" >> /etc/rc.d/rc.local_shutdown
chmod +x /etc/rc.d/rc.local_shutdown
chmod +x /etc/rc.d/rc.dovecot
chmod +x /usr/local/sbin/recovery.sh
/etc/rc.d/rc.dovecot start
* * * * * /usr/local/sbin/recovery.sh &> /dev/null
sed -i -e 's,AllowOverride None,AllowOverride All,' /etc/httpd/httpd.conf
sed -i -e 's,#Include /etc/httpd/mod_php.conf,Include /etc/httpd/mod_php.conf,' /etc/httpd/httpd.conf
sed -i -e 's,DirectoryIndex index.html,DirectoryIndex index.php index.html,' /etc/httpd/httpd.conf
chmod +x /etc/rc.d/rc.httpd
/etc/rc.d/rc.httpd stop
/etc/rc.d/rc.httpd start
roundcube original download link
cd /usr/src
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/roundcubemail-0.3.1.tar.gz"
tar zxf roundcubemail-0.3.1.tar.gz
mkdir -p /var/qmail/roundcube
cp -r roundcubemail-0.3.1/* /var/qmail/roundcube/
chown -R apache.apache /var/qmail/roundcube/temp
chown -R apache.apache /var/qmail/roundcube/logs
mysql -ppassdb -e "CREATE DATABASE roundcubemail"
mysql -ppassdb -e "GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube@localhost IDENTIFIED BY 'passround'"
mysql -ppassdb -e "FLUSH PRIVILEGES"
mysql -ppassdb roundcubemail < /var/qmail/roundcube/SQL/mysql.initial.sql
<?php
$rcmail_config = array();
$rcmail_config['debug_level'] = 1;
$rcmail_config['log_driver'] = 'file';
$rcmail_config['log_date_format'] = 'd-M-Y H:i:s O';
$rcmail_config['syslog_id'] = 'roundcube';
$rcmail_config['syslog_facility'] = LOG_USER;
$rcmail_config['log_dir'] = 'logs/';
$rcmail_config['temp_dir'] = 'temp/';
$rcmail_config['plugins'] = array();
$rcmail_config['enable_caching'] = FALSE;
$rcmail_config['message_cache_lifetime'] = '10d';
$rcmail_config['force_https'] = FALSE;
$rcmail_config['auto_create_user'] = TRUE;
$rcmail_config['default_host'] = 'localhost';
$rcmail_config['default_port'] = 143;
$rcmail_config['imap_auth_type'] = null;
$rcmail_config['imap_root'] = null;
$rcmail_config['imap_delimiter'] = null;
$rcmail_config['username_domain'] = 'professorhack.com';
$rcmail_config['mail_domain'] = '';
$rcmail_config['virtuser_file'] = '';
$rcmail_config['virtuser_query'] = '';
$rcmail_config['smtp_server'] = 'localhost';
$rcmail_config['smtp_port'] = 25;
$rcmail_config['smtp_user'] = '';
$rcmail_config['smtp_pass'] = '';
$rcmail_config['smtp_auth_type'] = '';
$rcmail_config['smtp_helo_host'] = '';
$rcmail_config['smtp_log'] = TRUE;
$rcmail_config['sql_debug'] = false;
$rcmail_config['imap_debug'] = false;
$rcmail_config['ldap_debug'] = false;
$rcmail_config['smtp_debug'] = false;
$rcmail_config['sendmail_delay'] = 0;
$rcmail_config['list_cols'] = array('subject', 'from', 'date', 'size', 'flag', 'attachment');
$rcmail_config['skin_include_php'] = FALSE;
$rcmail_config['session_lifetime'] = 10;
$rcmail_config['ip_check'] = false;
$rcmail_config['double_auth'] = false;
$rcmail_config['des_key'] = 'qC6zt+T?cL41UeYODFe6XPOR';
$rcmail_config['language'] = null;
$rcmail_config['date_short'] = 'D H:i';
$rcmail_config['date_long'] = 'd.m.Y H:i';
$rcmail_config['date_today'] = 'H:i';
$rcmail_config['useragent'] = 'RoundCube Webmail/'.RCMAIL_VERSION;
$rcmail_config['product_name'] = 'RoundCube Webmail';
$rcmail_config['drafts_mbox'] = 'Drafts';
$rcmail_config['junk_mbox'] = 'Junk';
$rcmail_config['sent_mbox'] = 'Sent';
$rcmail_config['trash_mbox'] = 'Trash';
$rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'Junk', 'Trash');
$rcmail_config['create_default_folders'] = TRUE;
$rcmail_config['protect_default_folders'] = TRUE;
$rcmail_config['quota_zero_as_unlimited'] = FALSE;
$rcmail_config['mdn_requests'] = 0;
$rcmail_config['default_charset'] = 'ISO-8859-1';
$rcmail_config['enable_spellcheck'] = false;
$rcmail_config['spellcheck_engine'] = 'pspell';
$rcmail_config['spellcheck_uri'] = '';
$rcmail_config['spellcheck_languages'] = NULL;
$rcmail_config['generic_message_footer'] = '';
$rcmail_config['http_received_header'] = false;
$rcmail_config['http_received_header_encrypt'] = false;
$rcmail_config['mail_header_delimiter'] = NULL;
$rcmail_config['session_domain'] = '';
$rcmail_config['address_book_type'] = 'sql';
$rcmail_config['ldap_public'] = array();
$rcmail_config['autocomplete_addressbooks'] = array('sql');
$rcmail_config['dont_override'] = array();
$rcmail_config['identities_level'] = 3;
$rcmail_config['include_host_config'] = false;
$rcmail_config['max_pagesize'] = 200;
$rcmail_config['mime_magic'] = '/usr/share/misc/magic';
$rcmail_config['message_sort_col'] = 'date';
$rcmail_config['message_sort_order'] = 'DESC';
$rcmail_config['enable_installer'] = false;
$rcmail_config['log_logins'] = false;
$rcmail_config['delete_always'] = false;
$rcmail_config['min_keep_alive'] = 60;
$rcmail_config['email_dns_check'] = false;
$rcmail_config['skin'] = 'default';
$rcmail_config['pagesize'] = 40;
$rcmail_config['timezone'] = 'auto';
$rcmail_config['dst_active'] = (bool)date('I');
$rcmail_config['prefer_html'] = TRUE;
$rcmail_config['show_images'] = 0;
$rcmail_config['htmleditor'] = true;
$rcmail_config['prettydate'] = TRUE;
$rcmail_config['draft_autosave'] = 300;
$rcmail_config['preview_pane'] = FALSE;
$rcmail_config['focus_on_new_message'] = true;
$rcmail_config['logout_purge'] = FALSE;
$rcmail_config['logout_expunge'] = FALSE;
$rcmail_config['inline_images'] = TRUE;
$rcmail_config['mime_param_folding'] = 0;
$rcmail_config['skip_deleted'] = FALSE;
$rcmail_config['read_when_deleted'] = TRUE;
$rcmail_config['flag_for_deletion'] = FALSE;
$rcmail_config['keep_alive'] = 60;
$rcmail_config['check_all_folders'] = FALSE;
$rcmail_config['display_next'] = FALSE;
$rcmail_config['index_sort'] = TRUE;
?>
<?php
$rcmail_config = array();
$rcmail_config['db_dsnw'] = 'mysql://roundcube:passround@localhost/roundcubemail';
$rcmail_config['db_dsnr'] = '';
$rcmail_config['db_max_length'] = 512000; // 500K
$rcmail_config['db_persistent'] = FALSE;
$rcmail_config['db_table_users'] = 'users';
$rcmail_config['db_table_identities'] = 'identities';
$rcmail_config['db_table_contacts'] = 'contacts';
$rcmail_config['db_table_session'] = 'session';
$rcmail_config['db_table_cache'] = 'cache';
$rcmail_config['db_table_messages'] = 'messages';
$rcmail_config['db_sequence_users'] = 'user_ids';
$rcmail_config['db_sequence_identities'] = 'identity_ids';
$rcmail_config['db_sequence_contacts'] = 'contact_ids';
$rcmail_config['db_sequence_cache'] = 'cache_ids';
$rcmail_config['db_sequence_messages'] = 'message_ids';
?>
rm -rf /var/www/htdocs/roundcube/installer/
ln -sfn /var/qmail/roundcube /var/www/htdocs/
http://zentus.com/rhost-check.html
original download link
cd /usr/src
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/rhost-check.c"
gcc -O -o rhost-check rhost-check.c
mv rhost-check /var/qmail/bin
/*
* Public domain 2008 David Crawshaw <david@zentus.com>
* http://www.zentus.com/rhost-check.html
* Usage: tcpserver -R -h -p 0 smtp rhost-check rblsmtpd qmail-smtpd
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char* argv[])
{
if (argc < 2) {
fputs("usage: rhost-check program [arguments]\n", stderr);
return 111;
}
if (getenv("TCPREMOTEHOST") == 0) {
putenv("RBLSMTPD=-We do not accept mail from IP addresses without reverse DNS !!!");
}
execvp(argv[1], argv+1);
fputs("error: execution of rhost-check failed\n", stderr);
return 111;
}
#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
exit 1
fi
exec /usr/local/bin/softlimit -m 2000000 \
/usr/local/bin/tcpserver -v -h -p -R \
-l "$LOCAL" -x /var/qmail/control/tcp.smtp.cdb \
-c "$MAXSMTPD" -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \
/var/qmail/bin/rhost-check \
/usr/local/bin/rblsmtpd \
/var/qmail/bin/qmail-smtpd "$LOCAL" \
/var/qmail/vpopmail/bin/vchkpw /bin/true 2>&1
qmailctl restart
qmailctl stat
jgreylist.c original download link
jgreylist-clean original download link
mkdir -p /var/qmail/jgreylist
chmod 0700 /var/qmail/jgreylist
chown qmaild:nofiles /var/qmail/jgreylist
cd /usr/src/
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/jgreylist.c"
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/jgreylist-clean"
gcc -o jgreylist jgreylist.c
/bin/mv jgreylist /var/qmail/bin/
/bin/mv jgreylist-clean /var/qmail/bin/
chown root:nofiles /var/qmail/bin/jgreylist
chmod 0755 /var/qmail/bin/jgreylist
chmod +x /var/qmail/bin/jgreylist-clean
ln -sfn /var/qmail/bin/jgreylist-clean /etc/cron.daily/jgreylist-clean
#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
export JGREYLIST_DIR=/var/qmail/jgreylist
export JGREYLIST_NOREV=""
export JGREYLIST_BY_IP="0"
export JGREYLIST_HOLDTIME="120"
export JGREYLIST_LOG="1"
export JGREYLIST_LOG_PID="1"
export JGREYLIST_LOG_SMTP="0"
export JGREYLIST_TIMEOUT="60"
export JGREYLIST_LIMIT="20"
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
exit 1
fi
exec /usr/local/bin/softlimit -m 10000000 \
/usr/local/bin/tcpserver -v -h -R -p \
-l "$LOCAL" -x /var/qmail/control/tcp.smtp.cdb \
-c "$MAXSMTPD" -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \
/var/qmail/bin/jgreylist \
/var/qmail/bin/qmail-smtpd "$LOCAL" \
/var/qmail/vpopmail/bin/vchkpw /bin/true 2>&1
127.0.0.1:allow,RELAYCLIENT="",JGREYLIST=""
qmailctl cdb
qmailctl restart
sleep 5
qmailctl stat
tail -n 100 -f /var/qmail/log/*/current | tai64nlocal
djbdns original download link
djbdns patch original download link
cd /usr/local/daemontools/package
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/djbdns-1.05.tar.gz"
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Patches/djbdns-1.05.errno.patch"
tar zxf djbdns-1.05.tar.gz
cd djbdns-1.05
patch -p1 < ../djbdns-1.05.errno.patch
make
make setup check
mkdir -p /usr/local/djbdns
groupadd dns
useradd dnscache -g dns -d /usr/local/djbdns -s /bin/false
useradd dnscachelog -g dns -d /usr/local/djbdns -s /bin/false
dnscache-conf dnscache dnscachelog /usr/local/djbdns/dnscache 172.16.20.2
wget ftp://ftp.internic.net/domain/named.root -q -O - | grep ' A ' | awk '{print$4}' > /etc/dnsroots.global
cp /etc/dnsroots.global /usr/local/djbdns/dnscache/root/servers/@
ln -sfn /usr/local/djbdns/dnscache /service/dnscache
sleep 5
echo 100000000 > /service/dnscache/env/CACHESIZE
echo 104857600 > /service/dnscache/env/DATALIMIT
svc -t /service/dnscache
sleep 5
svstat /service/dnscache
touch /usr/local/djbdns/dnscache/root/ip/172.16.20.2
ps -A | grep dnscache
ps auxw | grep dnscache
echo 8.8.8.8 > /usr/local/djbdns/dnscache/root/servers/@
echo 1 > /usr/local/djbdns/dnscache/env/FORWARDONLY
svc -t /service/dnscache
sleep 5
svstat /service/dnscache
echo 127.0.0.1 > /usr/local/djbdns/dnscache/root/servers/rbldns.professorhack.com
svc -h /service/dnscache
nameserver 172.16.20.2
# http://ladro.com/docs/dns/rblsmtpd.html
# top level DNS for *.mail.professorhack.com :
# &mail.professorhack.com::mail.professorhack.com:600
mkdir -p /usr/local/djbdns
groupadd dns
useradd rbldns -g dns -d /usr/local/djbdns -s /bin/false
useradd rbldnslog -g dns -d /usr/local/djbdns -s /bin/false
rbldns-conf rbldns rbldnslog /usr/local/djbdns/rbldns 127.0.0.1 rbldns.professorhack.com
ln -sfn /usr/local/djbdns/rbldns /service/rbldns
svc -t /service/dnscache
sleep 5
svstat /service/rbldns /service/dnscache
lsof -n -i:53
ps -A | grep rbldns
ps auxw | grep rbldns
tail -f /service/rbldns/log/main/current
:127.0.0.2:rbldns.professorhack.com Real-time Blackhole List for $
cd /usr/local/djbdns/rbldns/root/
echo 192.168.5.100 >> data
make
dnsqr a 100.5.168.192.rbldns.professorhack.com
dnsqr txt 100.5.168.192.rbldns.professorhack.com
...
...
exec /usr/local/bin/softlimit -m 10000000 \
/usr/local/bin/tcpserver -v -h -R -p \
-l "$LOCAL" -x /var/qmail/control/tcp.smtp.cdb \
-c "$MAXSMTPD" -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \
/usr/local/bin/rblsmtpd -b -r rbldns.professorhack.com \
/var/qmail/bin/jgreylist \
/var/qmail/bin/qmail-smtpd "$LOCAL" \
/var/qmail/vpopmail/bin/vchkpw /bin/true 2>&1
svc -t /service/{*,*/log}
sleep 5
svstat /service/{*,*/log}
# rbldns patch by Pejman Moghadam - http://www.pmoghadam.com
# change default TTL from 2048 to 120
# diff -u rbldns.c.orig rbldns.c > rbldns.c.patch
--- rbldns.c.orig 2010-05-13 09:46:18.000000000 +0430
+++ rbldns.c 2010-05-13 09:46:56.000000000 +0430
@@ -65,12 +65,12 @@
}
if (flaga) {
- if (!response_rstart(q,DNS_T_A,2048)) return 0;
+ if (!response_rstart(q,DNS_T_A,120)) return 0; /* patch : changed from 2048 to 120 */
if (!response_addbytes(data,4)) return 0;
response_rfinish(RESPONSE_ANSWER);
}
if (flagtxt) {
- if (!response_rstart(q,DNS_T_TXT,2048)) return 0;
+ if (!response_rstart(q,DNS_T_TXT,120)) return 0; /* patch : changed from 2048 to 120 */
ch = dlen - 4;
if (!response_addbytes(&ch,1)) return 0;
if (!response_addbytes(data + 4,dlen - 4)) return 0;
cd /usr/local/daemontools/package/djbdns-1.05
patch < rbldns.c.patch
svc -d /service/dnscache /service/rbldns
make
make setup check
svc -u /service/dnscache /service/rbldns
sleep 5
svstat /service/{*,*/log}
dnsqr a 100.5.168.192.rbldns.professorhack.com
dnsqr txt 100.5.168.192.rbldns.professorhack.com
BY: Pejman Moghadam
TAG: qmail, vpopmail, mysql, dovecot, roundcube, rbldns, daemontools, ucspi-tcp, sendmail, greylist, djbdns, dnscache, dns, djb
DATE: 2010-05-13 16:36:44