Postlogin script

j.emerlik j.emerlik at gmail.com
Thu Nov 9 12:12:06 EET 2017


Hi,
I would like to prepare postlogin a script that allow imap connection to
roundcube for all but restrict imap access for selected users.

My question is that:

Is possible in condition IF use IP addresses as range or with mask (because
I've more than one web servers) ?

My script:

#!/bin/sh
if [ "$IP" = "172.11.0.28" ] ; then
  printf "* [ALERT] Access allowed from that IP\r\n"
  exec "$@"
fi

CHECK_USER=`PGPASSWORD="somepass" /usr/local/pg950/bin/psql -q -t -U
someuser -d maildb -c "select imap_allowed from __users where name =
'$USER' LIMIT 1"`

if [ $CHECK_USER == "f" ] ; then
exit 0
fi

if [ $CHECK_USER == "t" ] ; then
exec "$@"
fi

Regards,
Jack


More information about the dovecot mailing list