Skip to content

Commit

Permalink
dovecot: update lastauth.protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Dec 7, 2024
1 parent f64bdaf commit 4ee8078
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
9 changes: 0 additions & 9 deletions include/vpopmail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ install_vpopmail_source()
stage_exec sh -c 'cd /data/src/vpopmail; aclocal' || exit 1
stage_exec sh -c "cd /data/src/vpopmail; CFLAGS=\"-fcommon\" ./configure $_conf_args" || exit 1
stage_exec sh -c 'cd /data/src/vpopmail; make install' || exit 1

# TODO: check and automate this
echo; echo "
ALTER TABLE vpopmail MODIFY column pw_name char(64);
ALTER TABLE vpopmail MODIFY column pw_passwd char(128);
ALTER TABLE vpopmail MODIFY column pw_gecos char(64);
"; echo

tell_status "*** Run the above commands above to update MySQL. *** "
}

install_vpopmail_port()
Expand Down
12 changes: 6 additions & 6 deletions provision/dovecot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -566,18 +566,18 @@ EO_PF_FILTER
configure_dovecot_lastauth()
{
store_exec "$ZFS_DATA_MNT/dovecot/bin/lastauth" <<EO_LASTAUTH
store_exec "$ZFS_DATA_MNT/dovecot/bin/lastauth.sh" <<EO_LASTAUTH
#!/bin/sh
set -e
domain=$(echo \$USER | cut -f2 -d@)
user=$(echo \$USER | cut -f1 -d@)
domain=\$(echo \$USER | cut -f2 -d@)
user=\$(echo \$USER | cut -f1 -d@)
echo "UPDATE lastauth SET timestamp=UNIX_TIMESTAMP(now()), remote_ip='\$IP' WHERE user='\$user' AND domain='\$domain';" | \
mysql --defaults-extra-file=/data/etc/.my.cnf
echo "UPDATE vpopmail.lastauth SET timestamp=UNIX_TIMESTAMP(now()), remote_ip='\$IP' WHERE user='\$user' AND domain='\$domain';" \
| mysql --defaults-extra-file=/data/etc/.my.cnf vpopmail
exec "$@"
exec "\$@"
EO_LASTAUTH
_mycnf="$ZFS_DATA_MNT/dovecot/etc/.my.cnf"
Expand Down
18 changes: 18 additions & 0 deletions provision/vpopmail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,22 @@ install_vpopmail_mysql_aliastable()
echo "CREATE TABLE IF NOT EXISTS aliasdomains (alias varchar(100) NOT NULL, domain varchar(100) NOT NULL, PRIMARY KEY (alias));" | mysql_query vpopmail || return 1
}
alter_vpopmail_tables()
{
echo "ALTER TABLE vpopmail.vpopmail
MODIFY COLUMN pw_name varchar(64),
MODIFY COLUMN pw_domain varchar(96),
MODIFY COLUMN pw_passwd varchar(128),
MODIFY COLUMN pw_gecos varchar(64),
MODIFY COLUMN pw_dir varchar(160),
MODIFY COLUMN pw_clear_passwd varchar(128);" | mysql_query
echo "ALTER TABLE vpopmail.lastauth
MODIFY COLUMN user varchar(64),
MODIFY COLUMN domain varchar(96),
MODIFY COLUMN remote_ip varchar(39);" | mysql_query
}
install_vpop_nrpe()
{
if [ -z "$TOASTER_NRPE" ]; then
Expand Down Expand Up @@ -259,9 +275,11 @@ install_vpopmail()
install_vpopmail_port
#install_vpopmail_source
if [ "$TOASTER_MYSQL" = "1" ]; then
install_vpopmail_mysql_grants
install_vpopmail_mysql_aliastable
alter_vpopmail_tables
fi
install_qmailadmin
Expand Down

0 comments on commit 4ee8078

Please sign in to comment.