Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postmaster no delete #248

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/configure
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,19 @@ virtual_domain_alias:
and domainalias.domain_id = domains.domain_id}}
retry_use_local_part

# Fallback in case a postmaster account does not exist. Send mail to admin
# accounts of the domain
virtual_postmaster_fallback:
driver = redirect
allow_fail
data = ${lookup mysql{select username from users,domains where admin=1 \
and domain = '${quote_mysql:$domain}' \
and users.domain_id = domains.domain_id}}
retry_use_local_part
file_transport = virtual_delivery
reply_transport = address_reply
pipe_transport = address_pipe_catchall


# This router handles aliasing using a linearly searched alias file with the
# name /etc/aliases. When this configuration is installed automatically,
Expand Down
20 changes: 12 additions & 8 deletions vexim/adminuser.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,18 @@
$sth->execute($queryParams);
while ($row = $sth->fetch()) {
if($row['enabled']==="0") print '<tr class="disabled">'; else print '<tr>';
print '<td class="trash"><a href="adminuserdelete.php?user_id='
. $row['user_id']
. '&amp;localpart='
. $row['localpart']
. '">';
print '<img class="trash" title="Delete '
. $row['realname']
. '" src="images/trashcan.gif" alt="trashcan"></a></td>';
print '<td class="trash">';
if($row['localpart']!=='postmaster') {
print '<a href="adminuserdelete.php?user_id='
. $row['user_id']
. '&amp;localpart='
. $row['localpart']
. '">';
print '<img class="trash" title="Delete '
. $row['realname']
. '" src="images/trashcan.gif" alt="trashcan"></a>';
}
print '</td>';
print '<td><a href="adminuserchange.php?user_id=' . $row['user_id']
. '&amp;localpart=' . $row['localpart']
. '" title="' . _('Click to modify')
Expand Down
10 changes: 8 additions & 2 deletions vexim/adminuserdelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
include_once dirname(__FILE__) . '/config/functions.php';
include_once dirname(__FILE__) . '/config/httpheaders.php';

# Do not allow to delete the postmaster (RFC5321)
if ($_GET['localpart']==='postmaster') {
header ("Location: adminuser.php?faildeleted={$_GET['localpart']}");
die();
}

# confirm that the postmaster is looking to delete a user they are permitted to change before going further
$query = "SELECT * FROM users WHERE user_id=:user_id
AND domain_id=:domain_id
AND domain_id=:domain_id AND localpart=:localpart
AND (type='local' OR type='piped')";
$sth = $dbh->prepare($query);
$sth->execute(array(':user_id'=>$_GET['user_id'], ':domain_id'=>$_SESSION['domain_id']));
$sth->execute(array(':user_id'=>$_GET['user_id'], ':domain_id'=>$_SESSION['domain_id'], ':localpart'=>$_GET['localpart']));
if (!$sth->rowCount()) {
header ("Location: adminuser.php?faildeleted={$_GET['localpart']}");
die();
Expand Down