diff --git a/lam-packaging/debian/README.Debian b/lam-packaging/debian/README.Debian
index dbc34a966..34698b55a 100644
--- a/lam-packaging/debian/README.Debian
+++ b/lam-packaging/debian/README.Debian
@@ -14,7 +14,6 @@ Configuration:
All settings can be edited via the webfrontend. Please
point your browser to the LAM start page and then select
"LAM configuration".
- The default password for the configuration is "lam".
Lamdaemon:
diff --git a/lam-packaging/docker/start.sh b/lam-packaging/docker/start.sh
index bf5db8d9d..d2adf7db7 100755
--- a/lam-packaging/docker/start.sh
+++ b/lam-packaging/docker/start.sh
@@ -4,7 +4,7 @@
# This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
# Copyright (C) 2019 Felix Bartels
-# 2019 - 2024 Roland Gruber
+# 2019 - 2025 Roland Gruber
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -59,7 +59,6 @@ if [ "$LAM_SKIP_PRECONFIGURE" != "true" ]; then
LAM_CONFIGURATION_PASSWORD="${LAM_CONFIGURATION_PASSWORD:-}"
sed -i -f- /etc/ldap-account-manager/config.cfg <<- EOF
- s|"password": "[^"]*"|"password": "${LAM_PASSWORD_SSHA}"|;
s|"license": "[^"]*"|"license": "${LAM_LICENSE}"|;
s|"configDatabaseType": "[^"]*"|"configDatabaseType": "${LAM_CONFIGURATION_DATABASE}"|;
s|"configDatabaseServer": "[^"]*"|"configDatabaseServer": "${LAM_CONFIGURATION_HOST}"|;
@@ -68,6 +67,9 @@ if [ "$LAM_SKIP_PRECONFIGURE" != "true" ]; then
s|"configDatabaseUser": "[^"]*"|"configDatabaseUser": "${LAM_CONFIGURATION_USER}"|;
s|"configDatabasePassword": "[^"]*"|"configDatabasePassword": "${LAM_CONFIGURATION_PASSWORD}"|;
EOF
+ if ! grep -e '"password":' /etc/ldap-account-manager/config.cfg > /dev/null; then
+ sed -i "2i\ \ \"password\": \"${LAM_PASSWORD_SSHA}\"," /etc/ldap-account-manager/config.cfg
+ fi
unset LAM_PASSWORD
set +e
@@ -82,12 +84,14 @@ EOF
sed -i -f- /var/lib/ldap-account-manager/config/lam.conf <<- EOF
s|"ServerURL": "[^"]*"|"ServerURL": "${LDAP_SERVER}"|;
s|"Admins": "[^"]*"|"Admins": "${LDAP_ADMIN_USER}"|;
- s|"Passwd": "[^"]*"|"Passwd": "${LAM_PASSWORD_SSHA}"|;
s|"treeViewSuffix": "[^"]*"|"treeViewSuffix": "${LDAP_BASE_DN}"|;
s|"defaultLanguage": "[^"]*"|"defaultLanguage": "${LAM_LANG}.utf8"|;
s|"suffix_user": "[^"]*"|"suffix_user": "${LDAP_USERS_DN}"|;
s|"suffix_group": "[^"]*"|"suffix_group": "${LDAP_GROUPS_DN}"|;
EOF
+ if ! grep -e '"Passwd":' /var/lib/ldap-account-manager/config/lam.conf > /dev/null; then
+ sed -i "2i\ \ \"Passwd\": \"${LAM_PASSWORD_SSHA}\"," /var/lib/ldap-account-manager/config/lam.conf
+ fi
fi
diff --git a/lam/HISTORY b/lam/HISTORY
index b2d6d5790..6f61b00e2 100644
--- a/lam/HISTORY
+++ b/lam/HISTORY
@@ -1,5 +1,6 @@
March 2025 9.1
- Usability improvements (348, 360)
+ - Security: LAM no longer ships with any default passwords, main configuration password is requested on login if not yet set (#390)
- Fixed bugs:
-> Ambiguous tooltip on profile editor for Shadow users (#394)
-> Self service photo file enhancements (#396)
diff --git a/lam/README b/lam/README
index b9aab3c01..a7bd58eb9 100644
--- a/lam/README
+++ b/lam/README
@@ -15,9 +15,6 @@ LAM - Readme
Installation and documentation:
Please see the LAM manual in docs/manual/index.html.
- Default password:
- The default password to edit the configuration options is "lam".
-
Download:
You can get the newest version at https://www.ldap-account-manager.org/.
diff --git a/lam/config/addressbook.sample.conf b/lam/config/addressbook.sample.conf
index ba6fa60d4..3b46d4538 100644
--- a/lam/config/addressbook.sample.conf
+++ b/lam/config/addressbook.sample.conf
@@ -3,7 +3,6 @@
"useTLS": "yes",
"followReferrals": "false",
"pagedResults": "false",
- "Passwd": "{CRYPT-SHA512}$6$ZJcXwaxHP0GQH0Rd$Ggkn8Wz\/8ntCM9v0TywomjkgSvV.3BoayFwnc9QP3MV.b7HWaqLOA8urP2e7HyEmU\/JmC8xR7jTqrXCHC4kFr. WkpjWHdheEhQMEdRSDBSZA==",
"Admins": "cn=Manager,dc=my-domain,dc=com",
"defaultLanguage": "en_GB.utf8",
"scriptPath": "",
diff --git a/lam/config/config.cfg.sample b/lam/config/config.cfg.sample
index 046734c5e..f1ed0d05d 100644
--- a/lam/config/config.cfg.sample
+++ b/lam/config/config.cfg.sample
@@ -1,5 +1,4 @@
{
- "password": "{CRYPT-SHA512}$6$WheNHdlVwDoL4s.x$DrZ10TpIGQa5wd0jbvtm8eaTleJCf1nec3ihOaNwMdPUKVFCphXwtnTSmFFXjhGa45RlrSEWhDVyjLCMiV\/.c. V2hlTkhkbFZ3RG9MNHMueA==",
"default": "lam",
"sessionTimeout": "30",
"hideLoginErrorDetails": "false",
diff --git a/lam/config/samba3.sample.conf b/lam/config/samba3.sample.conf
index 66c7864f4..4bfddb42e 100644
--- a/lam/config/samba3.sample.conf
+++ b/lam/config/samba3.sample.conf
@@ -3,7 +3,6 @@
"useTLS": "yes",
"followReferrals": "false",
"pagedResults": "false",
- "Passwd": "{CRYPT-SHA512}$6$MUWJEkvtUY7G5sFA$QS6voQCksH9gNbbbQpjDKt65iez9bgKQI2x60DAffCK5.LO\/\/QfYTetQ6V2PlUR32CTkuhlSXSGXnH9scD\/zb0 TVVXSkVrdnRVWTdHNXNGQQ==",
"Admins": "cn=Manager,dc=my-domain,dc=com",
"defaultLanguage": "en_GB.utf8",
"scriptPath": "",
diff --git a/lam/config/unix.sample.conf b/lam/config/unix.sample.conf
index 53aedf331..865c24cd5 100644
--- a/lam/config/unix.sample.conf
+++ b/lam/config/unix.sample.conf
@@ -3,7 +3,6 @@
"useTLS": "no",
"followReferrals": "false",
"pagedResults": "false",
- "Passwd": "{CRYPT-SHA512}$6$zvb8WVEHSAKEGtGO$573kA9Us8LtGLLm5Gu87P\/vIiF\/2Ol\/DauzPmUpvC4eCL\/t0WWiwBaY19Rx5G3wzbeZWWlE1kp2fikrpZTZ51\/ enZiOFdWRUhTQUtFR3RHTw==",
"Admins": "cn=Manager,dc=my-domain,dc=com",
"defaultLanguage": "en_GB.utf8",
"scriptPath": "",
diff --git a/lam/config/windows_samba4.sample.conf b/lam/config/windows_samba4.sample.conf
index e521c78a7..f2ab63f47 100644
--- a/lam/config/windows_samba4.sample.conf
+++ b/lam/config/windows_samba4.sample.conf
@@ -3,7 +3,6 @@
"useTLS": "no",
"followReferrals": "false",
"pagedResults": "false",
- "Passwd": "{CRYPT-SHA512}$6$9IWWua4lbp7uiLCC$AHPgST1YAm3yUAWKGeNZ5f9GCo1wBGyVo3MGvAt6.UOtQ9dYxs4WeQ4mlzjR30rD6cRayMNRBWqYFuBLvzn9T0 OUlXV3VhNGxicDd1aUxDQw==",
"Admins": "cn=Administrator,cn=users,dc=my-domain,dc=com",
"defaultLanguage": "en_GB.utf8",
"scriptPath": "",
diff --git a/lam/docs/manual-sources/appendix-troubleshooting.xml b/lam/docs/manual-sources/appendix-troubleshooting.xml
index 97e6763b5..eaf6cfa62 100644
--- a/lam/docs/manual-sources/appendix-troubleshooting.xml
+++ b/lam/docs/manual-sources/appendix-troubleshooting.xml
@@ -28,27 +28,23 @@
Locate config.cfg: On DEB/RPM installations it is in
- /usr/share/ldap-account-manager/config and for tar.bz2 in config
+ /usr/share/ldap-account-manager/config and
+ for tar.bz2 in config
folder.
- Locate the "password" entry in the file
+ Locate the "password" line in the file
- Replace the password hash after "password: " with your new
- clear-text password (e.g. "secret")
+ Remove the password line in the configuration file
- After the change the line should look like this:
-
- password: secret
-
- You can now login using your new password. Set the password once
- again via GUI in main configuration settings. This will then put again
- a hash value in the config.cfg file.
+ When you open LAM's start page you will now be asked to set a
+ new password.
diff --git a/lam/docs/manual-sources/chapter-configuration.xml b/lam/docs/manual-sources/chapter-configuration.xml
index 4cdf0a059..f82352a9f 100644
--- a/lam/docs/manual-sources/chapter-configuration.xml
+++ b/lam/docs/manual-sources/chapter-configuration.xml
@@ -44,11 +44,6 @@
General settings
- After selecting "Edit general settings" you will need to enter the
- master configuration password.
- The default password for new installations is "lam". Now you can edit the
- general settings.
-
Configuration Database
diff --git a/lam/docs/manual-sources/overview.xml b/lam/docs/manual-sources/overview.xml
index c12fe9bf1..f9c57580f 100644
--- a/lam/docs/manual-sources/overview.xml
+++ b/lam/docs/manual-sources/overview.xml
@@ -87,26 +87,15 @@
Edge (max. 2 years old)
-
-
- Opera (max. 2 years old)
-
- The default password to edit the configuration options is
- "lam".
-
License:
LAM is published under the GNU General Public License. The complete
list of licenses can be found in the copyright file.
- Default password:
-
- The default password for the LAM configuration is "lam".
-
Have fun!
The LAM development team
diff --git a/lam/lib/config.inc b/lam/lib/config.inc
index 90ac5bdf5..6d8e535e2 100644
--- a/lam/lib/config.inc
+++ b/lam/lib/config.inc
@@ -12,7 +12,7 @@ use function LAM\TYPES\getScopeFromTypeId;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2003 - 2024 Roland Gruber
+ Copyright (C) 2003 - 2025 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -50,6 +50,19 @@ include_once __DIR__ . "/types.inc";
/** 2-factor */
include_once __DIR__ . '/2factor.inc';
+/**
+ * Checks if the configuration password is secure.
+ *
+ * @param string $password password
+ * @return bool is secure
+ */
+function isValidConfigurationPassword(string $password): bool {
+ return preg_match('/[a-zA-Z]/', $password)
+ && preg_match('/\d/', $password)
+ && preg_match('/[^a-zA-Z0-9]/', $password)
+ && (strlen($password) >= 8);
+}
+
/**
* Sets the environment variables for custom SSL CA certificates.
*/
@@ -1453,6 +1466,15 @@ class LAMConfig {
return "{CRYPT-SHA512}" . crypt($password, '$6$' . $salt) . " " . base64_encode($salt);
}
+ /**
+ * Returns if the server profile has a password set.
+ *
+ * @return bool password is set
+ */
+ public function hasPasswordSet(): bool {
+ return ($this->Passwd != null) && ($this->Passwd !== '');
+ }
+
/**
* Returns the LDAP suffix for the given account type
*
@@ -3242,8 +3264,9 @@ class LAMCfgMain {
/**
* Saves the configuration to the persistence layer.
+ * @throws LAMException error saving config
*/
- public function save() {
+ public function save(): void {
if ($this->configDatabaseType === self::DATABASE_MYSQL) {
$this->saveLocal(true);
$this->saveDb();
@@ -3261,7 +3284,7 @@ class LAMCfgMain {
@chmod($sslPath, 0600);
}
else {
- StatusMessage("ERROR", _("Cannot write certificate file. Please check the permissions of config/serverCerts.pem."));
+ throw new LAMException(_("Cannot write certificate file. Please check the permissions of config/serverCerts.pem."));
}
}
// delete SSL certificate
@@ -3269,7 +3292,7 @@ class LAMCfgMain {
$sslPath = $this->getInternalSSLCaCertFileName();
$result = @unlink($sslPath);
if (!$result) {
- StatusMessage("ERROR", _("Cannot write certificate file. Please check the permissions of config/serverCerts.pem."));
+ throw new LAMException(_("Cannot write certificate file. Please check the permissions of config/serverCerts.pem."));
}
}
}
@@ -3296,6 +3319,7 @@ class LAMCfgMain {
* Saves preferences to config file config.cfg
*
* @param bool $persistenceOnly store only persistence related data
+ * @throws LAMException error saving config
*/
public function saveLocal(bool $persistenceOnly): void {
$data = $persistenceOnly ? $this->exportPersistenceData() : $this->exportData();
@@ -3308,10 +3332,19 @@ class LAMCfgMain {
chmod($this->conffile, 0600);
}
else {
- StatusMessage("ERROR", "", _("Cannot open config file!") . " (" . $this->conffile . ")");
+ throw new LAMException(_("Cannot open config file!") . " (" . $this->conffile . ")");
}
}
+ /**
+ * Returns if the main config has a password set.
+ *
+ * @return bool password is set
+ */
+ public function hasPasswordSet(): bool {
+ return ($this->password != null) && ($this->password !== '');
+ }
+
/**
* Sets a new config password.
*
diff --git a/lam/locale/es_ES/LC_MESSAGES/messages.mo b/lam/locale/es_ES/LC_MESSAGES/messages.mo
index 4a2d51003..9c5853e96 100644
Binary files a/lam/locale/es_ES/LC_MESSAGES/messages.mo and b/lam/locale/es_ES/LC_MESSAGES/messages.mo differ
diff --git a/lam/locale/es_ES/LC_MESSAGES/messages.po b/lam/locale/es_ES/LC_MESSAGES/messages.po
index 68ac6c6ee..a0ef96e4d 100644
--- a/lam/locale/es_ES/LC_MESSAGES/messages.po
+++ b/lam/locale/es_ES/LC_MESSAGES/messages.po
@@ -5,12 +5,13 @@
# Julio C. Ortega, 2022-2024
# Julio C. Ortega, 2015-2021
# Leandro Lattanzio, 2023
+# Roland Gruber , 2025
msgid ""
msgstr ""
"Project-Id-Version: LDAP Account Manager\n"
"Report-Msgid-Bugs-To: post@rolandgruber.de\n"
"PO-Revision-Date: 2011-09-29 18:53+0000\n"
-"Last-Translator: Julio C. Ortega, 2022-2024\n"
+"Last-Translator: Roland Gruber , 2025\n"
"Language-Team: Spanish (Spain) (http://app.transifex.com/gruberroland/lam/language/es_ES/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -8775,11 +8776,11 @@ msgstr "Móvil"
#: ../lib/modules/inetOrgPerson.inc:3760 ../lib/modules/inetOrgPerson.inc:3802
#: ../lib/modules/inetOrgPerson.inc:4147
msgid "Mobile number"
-msgstr "Numero de ḿmóbil"
+msgstr "Número de móvil"
#: ../lib/modules/inetOrgPerson.inc:2751
msgid "Mobile telephone number"
-msgstr "Número de teléfono movil"
+msgstr "Número de teléfono móvil"
#: ../lib/modules/qmailGroup.inc:183 ../lib/modules/qmailGroup.inc:187
#: ../lib/modules/qmailGroup.inc:316 ../lib/modules/qmailGroup.inc:376
@@ -16357,7 +16358,7 @@ msgstr "Número de Fax del usuario."
#: ../lib/modules/windowsLDSUser.inc:312 ../lib/modules/inetOrgPerson.inc:648
#: ../lib/modules/inetOrgPerson.inc:652 ../lib/modules/windowsUser.inc:423
msgid "The user's mobile number."
-msgstr "Numero de móvil del usuario."
+msgstr "Número de móvil del usuario."
#: ../lib/modules/windowsLDSUser.inc:284 ../lib/modules/windowsLDSUser.inc:288
#: ../lib/modules/inetOrgPerson.inc:780 ../lib/modules/inetOrgPerson.inc:784
diff --git a/lam/templates/config/conflogin.php b/lam/templates/config/conflogin.php
index a6737ade6..9a5eaefd0 100644
--- a/lam/templates/config/conflogin.php
+++ b/lam/templates/config/conflogin.php
@@ -1,22 +1,22 @@
getProfiles();
+ $profileNames = $serverProfilePersistenceManager->getProfiles();
+ foreach ($profileNames as $profileName) {
+ $profile = $serverProfilePersistenceManager->loadProfile($profileName);
+ if (!$profile->hasPasswordSet()) {
+ $profileNamesWithoutPassword[] = $profileName;
+ }
+ }
}
catch (LAMException $e) {
logNewMessage(LOG_ERR, 'Unable to read server profiles: ' . $e->getTitle());
}
printHeaderContents(_("Login"), '../..');
-if (count($files) < 1) {
+if (count($profileNames) < 1) {
$message = new htmlStatusMessage('INFO', _("No server profiles found. Please create one."));
}
+if ($profileNamesWithoutPassword !== []) {
+ $message = new htmlStatusMessage('INFO', _("There is at least one server profile without password. Please click on the manage server profiles link to set a password."),
+ htmlspecialchars(implode(', ', $profileNamesWithoutPassword)));
+}
?>
@@ -128,36 +139,34 @@ printJsIncludes('../..');
// message
if ($message !== null) {
- $row->add($message, 12);
+ $row->add($message);
$row->addVerticalSpacer('2rem');
}
$box = new htmlResponsiveRow();
- if (count($files) > 0) {
- $box->add(new htmlOutputText(_("Please enter your password to change the server preferences:")), 12);
+ if (count($profileNames) > 0) {
+ $box->add(new htmlOutputText(_("Please enter your password to change the server preferences:")));
$box->addVerticalSpacer('1.5rem');
$conf = new LAMCfgMain();
$selectedProfile = [];
- $profilesExisting = false;
- $profiles = $files;
- if (!empty($_COOKIE["lam_default_profile"]) && in_array($_COOKIE["lam_default_profile"], $files)) {
+ if (!empty($_COOKIE["lam_default_profile"]) && in_array($_COOKIE["lam_default_profile"], $profileNames)) {
$selectedProfile[] = $_COOKIE["lam_default_profile"];
}
else {
$selectedProfile[] = $conf->default;
}
- $box->add(new htmlResponsiveSelect('filename', $profiles, $selectedProfile, _('Profile name')), 12);
+ $box->add(new htmlResponsiveSelect('filename', $profileNames, $selectedProfile, _('Profile name')));
$passwordInput = new htmlResponsiveInputField(_('Password'), 'passwd', '', '200');
$passwordInput->setIsPassword(true);
$passwordInput->setCSSClasses(['lam-initial-focus']);
- $box->add($passwordInput, 12);
+ $box->add($passwordInput);
$box->addVerticalSpacer('1rem');
$button = new htmlButton('submit', _("Ok"));
$button->setCSSClasses(['lam-primary']);
$box->addLabel($button);
$box->add(new htmlOutputText(''), 0, 6);
$box->addVerticalSpacer('1.5rem');
- $box->add(new htmlHorizontalLine(), 12);
+ $box->add(new htmlHorizontalLine());
$box->addVerticalSpacer('1.5rem');
}
$manageLink = new htmlLink(_("Manage server profiles"), 'profmanage.php');
@@ -165,7 +174,7 @@ printJsIncludes('../..');
$boxDiv = new htmlDiv(null, $box);
$boxDiv->setCSSClasses(['roundedShadowBox', 'limitWidth', 'text-center']);
- $row->add($boxDiv, 12);
+ $row->add($boxDiv);
// back link
$row->addVerticalSpacer('2rem');
diff --git a/lam/templates/config/confmain.php b/lam/templates/config/confmain.php
index d8a55979d..453e9a74a 100644
--- a/lam/templates/config/confmain.php
+++ b/lam/templates/config/confmain.php
@@ -27,7 +27,7 @@ use ServerProfilePersistenceManager;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2003 - 2023 Roland Gruber
+ Copyright (C) 2003 - 2025 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -842,10 +842,13 @@ function checkInput(): array {
$conf->setTwoFactorRememberDevicePassword($_POST['twoFactorRememberDevicePassword']);
}
// check if password was changed
- if (isset($_POST['passwd1']) && ($_POST['passwd1'] != '')) {
- if ($_POST['passwd1'] != $_POST['passwd2']) {
+ if (!empty($_POST['passwd1'])) {
+ if ($_POST['passwd1'] !== $_POST['passwd2']) {
$errors[] = ["ERROR", _("Passwords are different!")];
}
+ elseif (!isValidConfigurationPassword($_POST['passwd1'])) {
+ $errors[] = ["ERROR", _('Profile password'), _('Please enter at least 8 characters including letters, a number and a symbol.')];
+ }
else {
// set new password
$conf->set_Passwd($_POST['passwd1']);
diff --git a/lam/templates/config/mainmanage.php b/lam/templates/config/mainmanage.php
index 5c13990d6..15c84b554 100644
--- a/lam/templates/config/mainmanage.php
+++ b/lam/templates/config/mainmanage.php
@@ -4,28 +4,28 @@ namespace LAM\CONFIG;
use htmlJavaScript;
use htmlResponsiveTable;
use LAM\LOGIN\WEBAUTHN\WebauthnManager;
-use \LAMCfgMain;
-use \htmlTable;
-use \htmlTitle;
-use \htmlStatusMessage;
-use \htmlSubTitle;
-use \htmlSpacer;
-use \htmlOutputText;
-use \htmlLink;
-use \htmlGroup;
-use \htmlButton;
-use \htmlHelpLink;
-use \htmlInputField;
-use \htmlInputFileUpload;
-use \DateTime;
-use \DateTimeZone;
-use \htmlResponsiveRow;
-use \htmlResponsiveInputTextarea;
-use \htmlResponsiveSelect;
-use \htmlResponsiveInputCheckbox;
-use \htmlResponsiveInputField;
-use \htmlDiv;
-use \htmlHiddenInput;
+use LAMCfgMain;
+use htmlTable;
+use htmlTitle;
+use htmlStatusMessage;
+use htmlSubTitle;
+use htmlSpacer;
+use htmlOutputText;
+use htmlLink;
+use htmlGroup;
+use htmlButton;
+use htmlHelpLink;
+use htmlInputField;
+use htmlInputFileUpload;
+use DateTime;
+use DateTimeZone;
+use htmlResponsiveRow;
+use htmlResponsiveInputTextarea;
+use htmlResponsiveSelect;
+use htmlResponsiveInputCheckbox;
+use htmlResponsiveInputField;
+use htmlDiv;
+use htmlHiddenInput;
use LAMException;
use LamTemporaryFilesManager;
use PDO;
@@ -33,7 +33,7 @@ use PDO;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2003 - 2024 Roland Gruber
+ Copyright (C) 2003 - 2025 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -114,7 +114,8 @@ printHeaderContents(_("Edit general settings"), '../..');
-
@@ -134,37 +135,41 @@ $errors = [];
$messages = [];
// check if submit button was pressed
if (isset($_POST['submitFormData'])) {
- if (extension_loaded('PDO')) {
- // set database
- $cfg->configDatabaseType = $_POST['configDatabaseType'];
- $cfg->configDatabaseServer = $_POST['configDatabaseServer'];
- $cfg->configDatabasePort = $_POST['configDatabasePort'];
- $cfg->configDatabaseName = $_POST['configDatabaseName'];
- $cfg->configDatabaseUser = $_POST['configDatabaseUser'];
- $cfg->configDatabasePassword = $_POST['configDatabasePassword'];
- if ($cfg->configDatabaseType === LAMCfgMain::DATABASE_MYSQL) {
- if (empty($cfg->configDatabaseServer) || !get_preg($cfg->configDatabaseServer, 'hostname')) {
- $errors[] = _('Please enter a valid database host name.');
- }
- if (empty($cfg->configDatabaseName)) {
- $errors[] = _('Please enter a valid database name.');
- }
- if (empty($cfg->configDatabaseUser)) {
- $errors[] = _('Please enter a valid database user.');
- }
- if (empty($cfg->configDatabasePassword)) {
- $errors[] = _('Please enter a valid database password.');
- }
- }
- }
+ if (extension_loaded('PDO')) {
+ // set database
+ $cfg->configDatabaseType = $_POST['configDatabaseType'];
+ $cfg->configDatabaseServer = $_POST['configDatabaseServer'];
+ $cfg->configDatabasePort = $_POST['configDatabasePort'];
+ $cfg->configDatabaseName = $_POST['configDatabaseName'];
+ $cfg->configDatabaseUser = $_POST['configDatabaseUser'];
+ $cfg->configDatabasePassword = $_POST['configDatabasePassword'];
+ if ($cfg->configDatabaseType === LAMCfgMain::DATABASE_MYSQL) {
+ if (empty($cfg->configDatabaseServer) || !get_preg($cfg->configDatabaseServer, 'hostname')) {
+ $errors[] = _('Please enter a valid database host name.');
+ }
+ if (empty($cfg->configDatabaseName)) {
+ $errors[] = _('Please enter a valid database name.');
+ }
+ if (empty($cfg->configDatabaseUser)) {
+ $errors[] = _('Please enter a valid database user.');
+ }
+ if (empty($cfg->configDatabasePassword)) {
+ $errors[] = _('Please enter a valid database password.');
+ }
+ }
+ }
// set master password
- if (isset($_POST['masterpassword']) && ($_POST['masterpassword'] != "")) {
- if ($_POST['masterpassword'] && $_POST['masterpassword2'] && ($_POST['masterpassword'] == $_POST['masterpassword2'])) {
+ if (!empty($_POST['masterpassword'])) {
+ if (($_POST['masterpassword'] !== $_POST['masterpassword2'])) {
+ $errors[] = _("Master passwords are different.");
+ }
+ elseif (!isValidConfigurationPassword($_POST['masterpassword'])) {
+ $errors[] = _('Please enter at least 8 characters including letters, a number and a symbol.');
+ }
+ else {
$cfg->setPassword($_POST['masterpassword']);
$msg = _("New master password set successfully.");
unset($_SESSION["mainconf_password"]);
- } else {
- $errors[] = _("Master passwords are different or empty!");
}
}
// set license
@@ -176,19 +181,19 @@ if (isset($_POST['submitFormData'])) {
$cfg->licenseEmailFrom = $_POST['licenseEmailFrom'];
$cfg->licenseEmailTo = $_POST['licenseEmailTo'];
if ((($cfg->licenseWarningType === LAMCfgMain::LICENSE_WARNING_EMAIL) || ($cfg->licenseWarningType === LAMCfgMain::LICENSE_WARNING_ALL))
- && !get_preg($cfg->licenseEmailFrom, 'email')) {
- $errors[] = _('Licence') . ': ' . _('From address') . ' - ' . _('Please enter a valid email address!');
- }
+ && !get_preg($cfg->licenseEmailFrom, 'email')) {
+ $errors[] = _('Licence') . ': ' . _('From address') . ' - ' . _('Please enter a valid email address!');
+ }
if (($cfg->licenseWarningType === LAMCfgMain::LICENSE_WARNING_EMAIL) || ($cfg->licenseWarningType === LAMCfgMain::LICENSE_WARNING_ALL)) {
- $toEmails = preg_split('/;[ ]*/', $cfg->licenseEmailTo);
- if ($toEmails !== false) {
+ $toEmails = preg_split('/;[ ]*/', $cfg->licenseEmailTo);
+ if ($toEmails !== false) {
foreach ($toEmails as $toEmail) {
if (!get_preg($toEmail, 'email')) {
$errors[] = _('Licence') . ': ' . _('To address') . ' - ' . _('Please enter a valid email address!');
break;
}
}
- }
+ }
}
}
// set session timeout
@@ -213,11 +218,12 @@ if (isset($_POST['submitFormData'])) {
}
}
$allowedHosts = implode(",", $allowedHostsList);
- } else {
+ }
+ else {
$allowedHosts = "";
}
$cfg->allowedHosts = $allowedHosts;
- // set allowed hosts for self service
+ // set allowed hosts for self-service
if (isLAMProVersion()) {
if (isset($_POST['allowedHostsSelfService'])) {
$allowedHostsSelfService = $_POST['allowedHostsSelfService'];
@@ -237,7 +243,8 @@ if (isset($_POST['submitFormData'])) {
}
$allowedHostsSelfServiceList = array_unique($allowedHostsSelfServiceList);
$allowedHostsSelfService = implode(",", $allowedHostsSelfServiceList);
- } else {
+ }
+ else {
$allowedHostsSelfService = "";
}
$cfg->allowedHostsSelfService = $allowedHostsSelfService;
@@ -247,34 +254,37 @@ if (isset($_POST['submitFormData'])) {
// set log destination
if ($_POST['logDestination'] == "none") {
$cfg->logDestination = "NONE";
- } elseif ($_POST['logDestination'] == "syslog") {
+ }
+ elseif ($_POST['logDestination'] == "syslog") {
$cfg->logDestination = "SYSLOG";
- } elseif ($_POST['logDestination'] == "remote") {
+ }
+ elseif ($_POST['logDestination'] == "remote") {
$cfg->logDestination = "REMOTE:" . $_POST['logRemote'];
$remoteParts = explode(':', $_POST['logRemote']);
if ((count($remoteParts) !== 2) || !get_preg($remoteParts[0], 'DNSname') || !get_preg($remoteParts[1], 'digit')) {
$errors[] = _("Please enter a valid remote server in format \"server:port\".");
}
- } else {
- $isValidLogFile = isset($_POST['logFile']) && LAMCfgMain::isValidLogFilename($_POST['logFile']);
+ }
+ else {
+ $isValidLogFile = isset($_POST['logFile']) && LAMCfgMain::isValidLogFilename($_POST['logFile']);
$blockedPrefixes = ['/usr', '/etc', '/dev', '/boot', '/lib', '/proc', '/root', '/run', '/sys', '/snap'];
if (!empty($_SERVER['DOCUMENT_ROOT'])) {
- $blockedPrefixes[] = $_SERVER['DOCUMENT_ROOT'];
- }
+ $blockedPrefixes[] = $_SERVER['DOCUMENT_ROOT'];
+ }
foreach ($blockedPrefixes as $blockedPrefix) {
- if (!$isValidLogFile) {
- break;
- }
- if (str_starts_with($_POST['logFile'], $blockedPrefix)) {
- $isValidLogFile = false;
- }
- }
+ if (!$isValidLogFile) {
+ break;
+ }
+ if (str_starts_with($_POST['logFile'], $blockedPrefix)) {
+ $isValidLogFile = false;
+ }
+ }
if ($isValidLogFile) {
$cfg->logDestination = $_POST['logFile'];
- }
+ }
else {
$errors[] = _("The log file is empty or contains invalid characters! Valid characters are: a-z, A-Z, 0-9, /, ., _ and -. The file must end with '.log' or '.txt'.");
- }
+ }
}
// password policies
$cfg->passwordMinLength = $_POST['passwordMinLength'];
@@ -315,8 +325,8 @@ if (isset($_POST['submitFormData'])) {
else {
$messages[] = _('You might need to restart your webserver for changes to take effect.');
}
- }
- }
+ }
+ }
}
}
if (isset($_POST['sslCaCertDelete'])) {
@@ -327,7 +337,7 @@ if (isset($_POST['submitFormData'])) {
$matches = [];
if (preg_match('/^ldaps:\/\/([a-zA-Z0-9_.-]+)(:(\d+))?$/', $_POST['serverurl'], $matches)) {
$port = '636';
- if (isset($matches[3]) && !empty($matches[3])) {
+ if (!empty($matches[3])) {
$port = $matches[3];
}
$pemResult = getLDAPSSLCertificate($matches[1], $port);
@@ -335,10 +345,12 @@ if (isset($_POST['submitFormData'])) {
$messages[] = _('Imported certificate from server.');
$messages[] = _('You might need to restart your webserver for changes to take effect.');
$cfg->uploadSSLCaCert($pemResult);
- } else {
+ }
+ else {
$errors[] = _('Unable to import server certificate. Please use the upload function.');
}
- } else {
+ }
+ else {
$errors[] = _('Invalid server name. Please enter "server" or "server:port".');
}
}
@@ -355,19 +367,19 @@ if (isset($_POST['submitFormData'])) {
$cfg->mailEncryption = $_POST['mailEncryption'];
$cfg->mailServer = $_POST['mailServer'];
if (!empty($cfg->mailServer) && !get_preg($cfg->mailServer, 'hostAndPort')) {
- $errors[] = _('Please enter the mail server with host name and port.');
- }
+ $errors[] = _('Please enter the mail server with host name and port.');
+ }
$mailAttribute = strtolower($_POST['mailAttribute']);
$mailBackupAttribute = strtolower($_POST['mailBackupAttribute']);
if (empty($mailAttribute)) {
$cfg->mailAttribute = LAMCfgMain::MAIL_ATTRIBUTE_DEFAULT;
- }
- elseif (preg_match('/^[a-z0-9_-]+$/', $mailAttribute)) {
- $cfg->mailAttribute = $mailAttribute;
- }
+ }
+ elseif (preg_match('/^[a-z0-9_-]+$/', $mailAttribute)) {
+ $cfg->mailAttribute = $mailAttribute;
+ }
else {
- $errors[] = _('The mail attributes are invalid.');
- }
+ $errors[] = _('The mail attributes are invalid.');
+ }
if (empty($mailBackupAttribute)) {
$cfg->mailBackupAttribute = LAMCfgMain::MAIL_BACKUP_ATTRIBUTE_DEFAULT;
}
@@ -379,22 +391,25 @@ if (isset($_POST['submitFormData'])) {
}
}
$cfg->errorReporting = $_POST['errorReporting'];
- // module settings
- $allModules = getAllModules();
- $moduleSettings = $cfg->getModuleSettings();
- foreach ($allModules as $module) {
- $module->checkGlobalConfigOptions($moduleSettings, $messages, $errors);
- }
- $cfg->setModuleSettings($moduleSettings);
+ // module settings
+ $allModules = getAllModules();
+ $moduleSettings = $cfg->getModuleSettings();
+ foreach ($allModules as $module) {
+ $module->checkGlobalConfigOptions($moduleSettings, $messages, $errors);
+ }
+ $cfg->setModuleSettings($moduleSettings);
// save settings
- if (isset($_POST['submit'])) {
- $cfg->save();
- if (empty($errors)) {
- $scriptTag = new htmlJavaScript('window.lam.dialog.showSuccessMessageAndRedirect("' . _("Your settings were successfully saved.") . '", "", "' . _('Ok') . '", "../login.php")');
- parseHtml(null, $scriptTag, [], false, null);
- echo '