Ftpauth

From Qmail Info Wiki

#!/bin/bash

#  ftpauth: This program is called by pure-authd to check if the email l/p are correct
#  Copyright (C) 2005 Roman Volf

#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.

#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.

#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

VPOPHOME=/home/vpopmail


## Do not change anything below here

PATH=$PATH:$VPOPHOME/bin


VPOPMAIL_UID=`printf "%s\0%s\0%s\0" $AUTHD_ACCOUNT $AUTHD_PASSWORD Y123457 | vchkpw id -u vpopmail 3<&0`
VPOPMAIL_GID=`id -g vpopmail`
DOMAIN_DIR=`vdominfo -d $DOMAIN`
USER_DIR=`vuserinfo -d $AUTHD_ACCOUNT`

if [ $VPOPMAIL_UID ]; then
        DOMAIN=`echo $AUTHD_ACCOUNT|cut -d "@" -f 2`
        USER=`echo $AUTHD_ACCOUNT|cut -d "@" -f 1`
        DOMAIN_DIR=`vdominfo -d $DOMAIN`
        if [ !  -f $DOMAIN_DIR/.qmail-$USER ]; then
                echo "| /var/qmail/bin/preline /usr/local/bin/preprocmail" > $DOMAIN_DIR/.qmail-$USER
                echo "| $VPOPHOME/bin/vdelivermail '' $USER_DIR/Maildir/" >> $DOMAIN_DIR/.qmail-$USER
                chown vpopmail $DOMAIN_DIR/.qmail-$USER
                chmod 600 $DOMAIN_DIR/.qmail-$USER
        fi
        echo "auth_ok:1"
        echo "uid:$VPOPMAIL_UID"
        echo "gid:$VPOPMAIL_GID"
        echo "dir:$USER_DIR"
        echo "end"
        exit
fi

echo "auth_ok:0"
echo "end"