diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index f1d716d2..53538e81 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -6,18 +6,31 @@ # # Further details on the project are available at https://github.com/postfixadmin/postfixadmin -MASTER (should have all changes from 3.3.9 plus) +MASTER (should have all changes from 3.3.10 plus) ------ - Add optional Dovecot mail-crypt plugin support - see https://github.com/postfixadmin/postfixadmin/issues/408 - Add $CONF['site_url'] to allow administrators to override a detected site url (e.g. used in password recovery emails; see https://github.com/postfixadmin/postfixadmin/issues/446 ) - Code reformat as PHPCS has a mind of it's own (function/method opening brace change of position) + - Improved UTF8 support in vacation (see https://github.com/postfixadmin/postfixadmin/pull/484) + - Fix quota levels losing config control (see bfc7af5c8efe2a68c47286cc870b56cb4f929a3f) + - vacation.pl: improve autoreply detection (see https://github.com/postfixadmin/postfixadmin/pull/482 + - vacation.pl: improve headers in auto-reply mails (add: "Auto-Submitted: auto-replied") see https://github.com/postfixadmin/postfixadmin/pull/483 + - vacation.pl: allow smtp helo to be customised; see https://github.com/postfixadmin/postfixadmin/pull/495 -Version 3.3.9 - ?????????? +Version 3.3.10 - ??? ------------------------------------------------- - - Improve Ukrainian language (thanks: andrew.kudrinov) (forgot to cherry-pick 4a960a0ce06b0754fa7b39aed0d5c57a88b20720 from master) + - Merge password expiration fixes from https://github.com/postfixadmin/postfixadmin/pull/493 + - Remove html readonly attribute from user's vacation page to/from selectors. + + +Version 3.3.9 - 2021/05/12 +------------------------------------------------- + - Improve Ukrainian language (ua.lang) (thanks: andrew.kudrinov) - Ensure we update timestamp fields (created / modified) when performing db operations, see: https://github.com/postfixadmin/postfixadmin/issues/469 - Add domain_admins.id pk column for non-sqlite users, see: https://github.com/postfixadmin/postfixadmin/issues/475 + - Add fix for MySQL error where a default datetime value in the domain field breaks the upgrade.php db schema update, see https://github.com/postfixadmin/postfixadmin/issues/489 + - Bug fix quota levels (now user configurable again; thanks @csware, see https://github.com/postfixadmin/postfixadmin/commit/bfc7af5c8efe2a68c47286cc870b56cb4f929a3f Version 3.3.8 - 2021/03/04 ------------------------------------------------- diff --git a/DOCUMENTS/Password_Expiration.md b/DOCUMENTS/Password_Expiration.md index 2008d0c1..0d9fb826 100644 --- a/DOCUMENTS/Password_Expiration.md +++ b/DOCUMENTS/Password_Expiration.md @@ -85,7 +85,7 @@ do QUERY="SELECT username,password_expiry FROM mailbox WHERE password_expiry > now() + interval $LOWER DAY AND password_expiry < NOW() + interval $INTERVAL DAY" - mysql --defaults-extra-file="$MYSQL_CREDENTIALS_FILE" "$POSTFIX_DB" -B -e "$QUERY" | while read -a RESULT ; do + mysql --defaults-extra-file="$MYSQL_CREDENTIALS_FILE" "$POSTFIX_DB" -B -N -e "$QUERY" | while IFS=$'\t' read -a RESULT ; do echo -e "Dear User, \n Your password will expire on ${RESULT[1]}" | mail -s "Password 30 days before expiration notication" -r $REPLY_ADDRESS ${RESULT[0]} done done diff --git a/VIRTUAL_VACATION/vacation.pl b/VIRTUAL_VACATION/vacation.pl index bc2e3983..824aa79d 100644 --- a/VIRTUAL_VACATION/vacation.pl +++ b/VIRTUAL_VACATION/vacation.pl @@ -58,9 +58,12 @@ our $smtp_server = 'localhost'; # port to connect to; defaults to 25 for non-SSL, 465 for 'ssl', 587 for 'starttls' our $smtp_server_port = 25; +# this is the local address from which to connect +our $smtp_client = 'localhost'; + # this is the helo we [the vacation script] use on connection; you may need to change this to your hostname or something, # depending upon what smtp helo restrictions you have in place within Postfix. -our $smtp_client = 'localhost'; +our $smtp_helo = 'localhost.localdomain'; # send mail encrypted or plaintext # if 'starttls', use STARTTLS; if 'ssl' (or 1), connect securely; otherwise, no security @@ -479,6 +482,7 @@ sub send_vacation_email { ssl => $smtp_ssl, timeout => $smtp_timeout, localaddr => $smtp_client, + helo => $smtp_helo, debug => 0, }; diff --git a/functions.inc.php b/functions.inc.php index b33bf1e6..bea132fd 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -15,7 +15,7 @@ */ -$min_db_version = 1843; # update (at least) before a release with the latest function numbrer in upgrade.php +$min_db_version = 1844; # update (at least) before a release with the latest function numbrer in upgrade.php /** * check_session diff --git a/languages/ua.lang b/languages/ua.lang index d79fa2c3..c060ba7d 100644 --- a/languages/ua.lang +++ b/languages/ua.lang @@ -276,11 +276,13 @@ $PALANG['domain_updated'] = 'Домен %s успішно оновлено.'; $PALANG['pAdminDelete_admin_error'] = 'Неможливо видалити адміністратора!'; $PALANG['domain_postdel_failed'] = 'Не вдалося коректно виконати скрипт після видалення домену, подробиці дивіться у журналі помилок!'; $PALANG['domain_postedit_failed'] = 'Не вдалося коректно виконати скрипт після редагування домену, подробиці дивіться у журналі помилок!'; + $PALANG['domain_postcreate_failed'] = 'Не вдалося коректно виконати скрипт після створення домену, подробиці дивіться у журналі помилок!'; $PALANG['mailbox_postdel_failed'] = 'Не вдалося коректно виконати скрипт після видалення поштової скриньки, подробиці дивіться у журналі помилок!'; $PALANG['mailbox_postedit_failed'] = 'Не вдалося коректно виконати скрипт після редагування поштової скриньки, подробиці дивіться у журналі помилок!'; $PALANG['mailbox_postcreate_failed'] = 'Не вдалося коректно виконати скрипт після створення поштової скриньки, подробиці дивіться у журналі помилок!'; $PALANG['mailbox_postpassword_failed'] = 'Не вдалося коректно виконати скрипт після зміни пароля поштової скриньки, подробиці дивіться у журналі помилок!'; + $PALANG['pAdminDelete_alias_domain_error'] = 'Неможливо видалити псевдоним (аліас) домену!'; $PALANG['domain_conflict_vacation_domain'] = 'Ви не можете використовувати домен автовідповідача у якості поштового домену!'; diff --git a/model/Login.php b/model/Login.php index 4018d867..6b7419c7 100644 --- a/model/Login.php +++ b/model/Login.php @@ -91,6 +91,30 @@ class Login return false; } + /** + * returns user's domain name + * @param $username + * @return string|null + * @throws Exception + */ + protected function getUserDomain(string $username) + { + $sql = "SELECT domain FROM {$this->table} WHERE username = :username AND active = :active"; + + $values = [ + 'username' => $username, + 'active' => db_get_boolean(true), + ]; + + // Fetch the domain + $result = db_query_one($sql, $values); + + if (is_array($result) && isset($result['domain'])) { + return $result['domain']; + } else { + return null; + } + } /** * @param string $username @@ -115,6 +139,14 @@ class Login 'password' => pacrypt($new_password), ); + if (Config::bool('password_expiration')) { + $domain = $this->getUserDomain($username); + if (!is_null($domain)) { + $password_expiration_value = (int)get_password_expiration_value($domain); + $set['password_expiry'] = date('Y-m-d H:i', strtotime("+$password_expiration_value day")); + } + } + $result = db_update($this->table, 'username', $username, $set); if ($result != 1) { diff --git a/model/VacationHandler.php b/model/VacationHandler.php index 73d6b91b..c01f7db8 100644 --- a/model/VacationHandler.php +++ b/model/VacationHandler.php @@ -231,9 +231,15 @@ class VacationHandler extends PFAHandler { $this->remove(); // clean out any notifications that might already have been sent. - $E_username = escape_string($this->username); - $activeFrom = date("Y-m-d 00:00:00", strtotime($activeFrom)); # TODO check if result looks like a valid date - $activeUntil = date("Y-m-d 23:59:59", strtotime($activeUntil)); # TODO check if result looks like a valid date + if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $activeFrom)) { + $activeFrom .= ' 00:00:00'; + } + if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $activeUntil)) { + $activeUntil .= ' 23:59:59'; + } + + $activeFrom = date("Y-m-d H:i", strtotime($activeFrom)); # TODO check if result looks like a valid date + $activeUntil = date("Y-m-d H:i", strtotime($activeUntil)); # TODO check if result looks like a valid date list(/*NULL*/, $domain) = explode('@', $this->username); $vacation_data = array( diff --git a/public/setup.php b/public/setup.php index a538f417..c1e7acb8 100644 --- a/public/setup.php +++ b/public/setup.php @@ -334,23 +334,28 @@ EOF;

Database Update

getMessage()); + echo "

Something went wrong while trying to connect to the database. A message should be logged - check PHP's error_log (" . ini_get('error_log') . ')

\n'; + error_log("Couldn't perform PostfixAdmin database update - failed to connect to db? " . $e->getMessage() . " Trace: " . $e->getTraceAsString()); } if ($db) { - print "

Everything seems fine... attempting to create/update database structure

\n"; - require_once(dirname(__FILE__) . '/upgrade.php'); + echo "

Everything seems fine... attempting to create/update database structure

\n"; + try { + require_once(dirname(__FILE__) . '/upgrade.php'); + } catch (\Exception $e) { + if ($authenticated) { + echo "

Exception message: {$e->getMessage()} - check logs!

"; + } + echo "

Something went wrong while trying to apply database updates, a message should be logged - check PHP's error_log (" . ini_get('error_log') . ')

\n'; + error_log("Couldn't perform PostfixAdmin database update via upgrade.php - " . $e->getMessage() . " Trace: " . $e->getTraceAsString()); + } } else { echo "

Could not connect to database to perform updates; check PHP error log.

"; } - } else { - echo "

Please login to see perform database update.

"; - } ?> diff --git a/public/upgrade.php b/public/upgrade.php index afb8346b..577b9f0d 100644 --- a/public/upgrade.php +++ b/public/upgrade.php @@ -256,7 +256,7 @@ function db_query_parsed($sql, $ignore_errors = 0, $attach_mysql = "") '{UNSIGNED}' => 'unsigned' , '{FULLTEXT}' => 'FULLTEXT', '{BOOLEAN}' => "tinyint(1) NOT NULL DEFAULT '" . db_get_boolean(false) . "'", - '{UTF-8}' => '/*!40100 CHARACTER SET utf8 */', + '{UTF-8}' => '/*!40100 CHARACTER SET utf8mb4 */', '{LATIN1}' => '/*!40100 CHARACTER SET latin1 COLLATE latin1_general_ci */', '{IF_NOT_EXISTS}' => 'IF NOT EXISTS', '{RENAME_COLUMN}' => 'CHANGE COLUMN', @@ -1903,6 +1903,7 @@ function upgrade_1837() _db_add_field($table, 'token_validity', '{DATETIME}', 'token'); } } + # TODO MySQL: # - various varchar fields do not have a default value # https://sourceforge.net/projects/postfixadmin/forums/forum/676076/topic/3419725 diff --git a/public/vacation.php b/public/vacation.php index 36558c01..59b662b0 100644 --- a/public/vacation.php +++ b/public/vacation.php @@ -154,7 +154,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($action == 'fChange') { - ## check if ActiveUnitl is not back in time, + ## check if ActiveUntil is not back in time, ## because vacation.pl will report SMTP recipient $smtp_recipient which resolves to $email does not have an active vacation (rv: $rv, email: $email)" ## and will not send message diff --git a/templates/vacation.tpl b/templates/vacation.tpl index 654522ea..b57134fd 100644 --- a/templates/vacation.tpl +++ b/templates/vacation.tpl @@ -17,7 +17,7 @@ class="form-control hidden"/>
+ class="form-control" />
@@ -31,7 +31,7 @@
+ class="form-control" />