Compare commits

..

3 Commits

5 changed files with 81 additions and 20 deletions

View File

@ -1,8 +1,24 @@
## OpenSMTPD Admin ## OpenSMTPD Admin
Fork of Postfix Admin 2.1.0 (released in 2007) OpenSMTPD Admin started as a fork of Postfix Admin 2.1.0 (released
in 2007), and grew quickly in a complete rewrite for OpenSMTPD.
Database needed to use SQL with OpenSMTPD ## Installation of packages
To get going on OpenBSD you will need to install the following packages:
mariadb-server
php
php-pdo_mysql
For OpenSMTPD you need the packages:
opensmtpd-extras
opensmtpd-extras-mysql
Once the packages are installed follow the steps outlined in /usr/local/share/doc/pkg-readmes
You need to create the database with:
CREATE DATABASE IF NOT EXISTS `opensmtpd` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci; CREATE DATABASE IF NOT EXISTS `opensmtpd` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `opensmtpd`; USE `opensmtpd`;
@ -15,7 +31,7 @@ Database needed to use SQL with OpenSMTPD
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`username`), PRIMARY KEY (`username`),
KEY `username` (`username`) KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Admins' ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Admins';
CREATE TABLE `alias` ( CREATE TABLE `alias` (
`address` varchar(255) NOT NULL DEFAULT '', `address` varchar(255) NOT NULL DEFAULT '',
@ -25,7 +41,7 @@ Database needed to use SQL with OpenSMTPD
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`address`), PRIMARY KEY (`address`),
KEY `address` (`address`) KEY `address` (`address`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Aliases' ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Aliases';
CREATE TABLE `domain` ( CREATE TABLE `domain` (
`domain` varchar(255) NOT NULL DEFAULT '', `domain` varchar(255) NOT NULL DEFAULT '',
@ -36,14 +52,14 @@ Database needed to use SQL with OpenSMTPD
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`domain`), PRIMARY KEY (`domain`),
KEY `domain` (`domain`) KEY `domain` (`domain`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Domains' ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Domains';
CREATE TABLE `domain_admins` ( CREATE TABLE `domain_admins` (
`username` varchar(255) NOT NULL DEFAULT '', `username` varchar(255) NOT NULL DEFAULT '',
`domain` varchar(255) NOT NULL DEFAULT '', `domain` varchar(255) NOT NULL DEFAULT '',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
KEY `username` (`username`) KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Domain Admins' ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Domain Admins';
CREATE TABLE `log` ( CREATE TABLE `log` (
`timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@ -52,7 +68,7 @@ Database needed to use SQL with OpenSMTPD
`action` varchar(255) NOT NULL DEFAULT '', `action` varchar(255) NOT NULL DEFAULT '',
`data` varchar(255) NOT NULL DEFAULT '', `data` varchar(255) NOT NULL DEFAULT '',
KEY `timestamp` (`timestamp`) KEY `timestamp` (`timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Log' ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Log';
CREATE TABLE `mailbox` ( CREATE TABLE `mailbox` (
`username` varchar(255) NOT NULL DEFAULT '', `username` varchar(255) NOT NULL DEFAULT '',
@ -64,7 +80,7 @@ Database needed to use SQL with OpenSMTPD
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`username`), PRIMARY KEY (`username`),
KEY `username` (`username`) KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Mailboxes' ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Mailboxes';
CREATE TABLE `vacation` ( CREATE TABLE `vacation` (
`email` varchar(255) NOT NULL DEFAULT '', `email` varchar(255) NOT NULL DEFAULT '',
@ -75,10 +91,55 @@ Database needed to use SQL with OpenSMTPD
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`email`), PRIMARY KEY (`email`),
KEY `email` (`email`) KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Vacation' ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Vacation';
Config for OpenSMTPTD, MySQL/MariaDB example: You can create the database user with something like:
CREATE USER IF NOT EXISTS 'opensmtpd'@'localhost' IDENTIFIED BY 'RandomString';
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER ON opensmtpd.* TO 'opensmtpd'@'localhost';
As an example configuration for httpd you can use:
server "opensmtpadmin" {
listen on * tls port 443
tls {
certificate "/etc/ssl/opensmtpdadmin.fullchain.pem"
key "/etc/ssl/private/opensmtpadmin.key"
}
tcp { nodelay, sack }
log style forwarded
location "/admin/*" {
authenticate with "/opensmtpdadmin/admin/.htpasswd"
root "/opensmtpdadmin"
fastcgi socket "/run/php-fpm.sock"
}
location "*.php*" {
root "/opensmtpdadmin"
directory index index.php
fastcgi socket "/run/php-fpm.sock"
}
location "/*" {
root "/opensmtpdadmin"
directory index index.php
}
}
As soon as that is done you can go to https://<yourhost>/<br>
You will be greeted by setup.php to check if everything is present to run OpenSMTPDAdmin.
Copy or move the conf.php-sample to conf.php and make the needed changes for your setup.<br>
You can remove setup.php if you want.
After that you can go to https://<yourhost>/admin/admin.php where you create the SUPER ADMIN.<br>
NOTE: Once this is done either remove or protect this directory / file.
You are now ready to use OpenSMTPDAdmin.
To use the accounts OpenSMTPDAdmin create in OpenSMTPD you can use the below config:
# /etc/mail/smtpd.conf # /etc/mail/smtpd.conf
table credentials mysql:/etc/mail/sql.conf table credentials mysql:/etc/mail/sql.conf
@ -86,6 +147,7 @@ Config for OpenSMTPTD, MySQL/MariaDB example:
table userinfo mysql:/etc/mail/sql.conf table userinfo mysql:/etc/mail/sql.conf
table virtuals mysql:/etc/mail/sql.conf table virtuals mysql:/etc/mail/sql.conf
Connecting the database to smtpd: Connecting the database to smtpd:
# /etc/mail/sql.conf # /etc/mail/sql.conf

View File

@ -24,7 +24,7 @@ define('ALIASES', '10');
define('MAILBOXES', '10'); define('MAILBOXES', '10');
// Mail Admin Administrator tag // Mail Admin Administrator tag
define('ADMIN_RIGHTS', 'ADMINISTRATOR'); define('ADMIN_ROLE', 'ADMINISTRATOR');
// Expose virtual mail construct 'vmail' to admins. // Expose virtual mail construct 'vmail' to admins.
define('ALIAS_CONTROL', 'NO'); define('ALIAS_CONTROL', 'NO');

View File

@ -2,7 +2,7 @@
// //
// OpenSMTPD Admin // OpenSMTPD Admin
// by Mischa Peters <mischa at high5 dot nl> // by Mischa Peters <mischa at high5 dot nl>
// Copyright (c) 2022 High5! // Copyright (c) 2022-2023 High5!
// License Info: LICENSE.TXT // License Info: LICENSE.TXT
// //
// File: functions.inc.php // File: functions.inc.php
@ -12,8 +12,8 @@ if (preg_match("/functions.inc.php/", $_SERVER['SCRIPT_NAME'])) {
die(); die();
} }
require_once './conf.php'; require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'conf.php');
define("VERSION", "version 1.0.0"); define("VERSION", "version 1.0.1");
// //
// Check if debug is enabled or not // Check if debug is enabled or not
@ -22,7 +22,6 @@ if (DEBUG == 'true') {
ini_set('display_errors', 1); ini_set('display_errors', 1);
ini_set('display_startup_errors', 1); ini_set('display_startup_errors', 1);
error_reporting(E_ALL); error_reporting(E_ALL);
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
} else { } else {
ini_set('display_errors', 0); ini_set('display_errors', 0);
ini_set('display_startup_errors', 0); ini_set('display_startup_errors', 0);

View File

@ -2,7 +2,7 @@
/** /**
* OpenSMTPD Admin Refactor * OpenSMTPD Admin Refactor
* by Jeroen Janssen <jeroen at laylo dot io> * by Jeroen Janssen <jeroen at laylo dot io>
* Copyright (c) 2022 LAYLO * Copyright (c) 2022-2023 LAYLO
*/ */
// Check whether the configuration file exists - bail if that is the case // Check whether the configuration file exists - bail if that is the case
@ -12,7 +12,7 @@ if (file_exists(realpath("./conf.php"))) {
} }
// Define the app specifics // Define the app specifics
DEFINE('APP_NAME', 'OpenSMTPD Admin Setup Checker'); DEFINE('APP_NAME', 'OpenSMTPD Admin Setup Checker');
DEFINE('VERSION', '1.1'); DEFINE('VERSION', '1.2');
// Start generating the HTML output // Start generating the HTML output
$html = '<html>'; $html = '<html>';
@ -30,14 +30,14 @@ $html .= '<td><strong>PHP version:</strong></td>';
$html .= (version_compare(PHP_VERSION, '7.4.0') >= 0) ? '<td><span style="color:green;">' . phpversion() . '</td>' : '<td><span style="color:red;">' . phpversion() . '</span></td>'; $html .= (version_compare(PHP_VERSION, '7.4.0') >= 0) ? '<td><span style="color:green;">' . phpversion() . '</td>' : '<td><span style="color:red;">' . phpversion() . '</span></td>';
$html .= '</tr><tr>'; $html .= '</tr><tr>';
$html .= '<td><strong>SQL support:</strong></td>'; $html .= '<td><strong>SQL support:</strong></td>';
$html .= (extension_loaded('mysqli')) ? '<td><span style="color:green;">MySQL/MariaDB</span>' : '<td><span style="color:red;">MySQL/MariaDB</span>'; $html .= (extension_loaded('PDO')) ? '<td><span style="color:green;">PDO - MySQL/MariaDB</span>' : '<td><span style="color:red;">PDO - MySQL/MariaDB</span>';
$html .= '</tr><tr>'; $html .= '</tr><tr>';
$html .= '<td><strong>Functions:</strong></td>'; $html .= '<td><strong>Functions:</strong></td>';
$html .= (extension_loaded('pcre')) ? '<td><span style="color:green;">pcre</span>' : '<td><span style="color:red;">pcre</span>'; $html .= (extension_loaded('pcre')) ? '<td><span style="color:green;">pcre</span>' : '<td><span style="color:red;">pcre</span>';
$html .= (function_exists('get_magic_quotes_gpc')) ? ' - <span style="color:green;">get_magic_quotes_gpc</span>' : ' - <span style="color:red;">get_magic_quotes_gpc</span>';
$html .= (function_exists('session_start')) ? ' - <span style="color:green;">session_start</span></td>' : ' - <span style="color:red;">session_start</span></td>'; $html .= (function_exists('session_start')) ? ' - <span style="color:green;">session_start</span></td>' : ' - <span style="color:red;">session_start</span></td>';
$html .= '</tr>'; $html .= '</tr>';
$html .= '</table>'; $html .= '</table>';
$html .= '<p>cp or mv conf.php-sample to conf.php and change it to reflect your setup.</p>';
$html .= '</body>'; $html .= '</body>';
$html .= '</html>'; $html .= '</html>';

View File

@ -1,6 +1,6 @@
<div id="menu"> <div id="menu">
<ul> <ul>
<?php if (count($list_domains) == 0) { ?> <?php if (count($list_domains) == 0 && $ROLE != ADMIN_ROLE) { ?>
<li><a target="_top" href="password.php"><?php echo $LANG['Menu_user_password']; ?></a></li> <li><a target="_top" href="password.php"><?php echo $LANG['Menu_user_password']; ?></a></li>
<?php if (VACATION == "YES") { ?> <?php if (VACATION == "YES") { ?>
<li><a target="_top" href="vacation.php"><?php echo $LANG['Menu_user_vacation']; ?></a></li> <li><a target="_top" href="vacation.php"><?php echo $LANG['Menu_user_vacation']; ?></a></li>