fix: read settings from directadmin plugin directory
This commit is contained in:
@@ -4,12 +4,12 @@ declare(strict_types=1);
|
|||||||
final class Settings
|
final class Settings
|
||||||
{
|
{
|
||||||
public const BASE_DIR = '/usr/local/hitme_plugins/mail-login';
|
public const BASE_DIR = '/usr/local/hitme_plugins/mail-login';
|
||||||
public const CONFIG_DIR = self::BASE_DIR . '/config';
|
public const PLUGIN_DIR = '/usr/local/directadmin/plugins/mail-login';
|
||||||
public const SECRET_DIR = self::BASE_DIR . '/secrets';
|
public const SECRET_DIR = self::BASE_DIR . '/secrets';
|
||||||
public const LOG_DIR = self::BASE_DIR . '/logs';
|
public const LOG_DIR = self::BASE_DIR . '/logs';
|
||||||
public const STATE_DIR = self::BASE_DIR . '/state';
|
public const STATE_DIR = self::BASE_DIR . '/state';
|
||||||
public const AUDIT_LOG = self::LOG_DIR . '/audit.log';
|
public const AUDIT_LOG = self::LOG_DIR . '/audit.log';
|
||||||
public const EXTERNAL_SETTINGS = self::CONFIG_DIR . '/plugin-settings.conf';
|
public const EXTERNAL_SETTINGS = self::PLUGIN_DIR . '/plugin-settings.conf';
|
||||||
|
|
||||||
/** @var array<string,string> */
|
/** @var array<string,string> */
|
||||||
private array $values;
|
private array $values;
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
# Ten plik jest runtime configuration pluginu.
|
||||||
|
# Plugin czyta ustawienia bezpośrednio z:
|
||||||
|
# /usr/local/directadmin/plugins/mail-login/plugin-settings.conf
|
||||||
|
|
||||||
# Czy plugin jest domyślnie dostępny dla wszystkich użytkowników.
|
# Czy plugin jest domyślnie dostępny dla wszystkich użytkowników.
|
||||||
DEFAULT_ENABLE=true
|
DEFAULT_ENABLE=true
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ name=mail-login
|
|||||||
id=mail-login
|
id=mail-login
|
||||||
type=user
|
type=user
|
||||||
author=HITME.PL
|
author=HITME.PL
|
||||||
version=1.0.6
|
version=1.0.7
|
||||||
active=no
|
active=no
|
||||||
installed=no
|
installed=no
|
||||||
user_run_as=root
|
user_run_as=root
|
||||||
|
|||||||
+5
-6
@@ -4,15 +4,14 @@ set -eu
|
|||||||
BASE_DIR="/usr/local/hitme_plugins/mail-login"
|
BASE_DIR="/usr/local/hitme_plugins/mail-login"
|
||||||
PLUGIN_DIR="/usr/local/directadmin/plugins/mail-login"
|
PLUGIN_DIR="/usr/local/directadmin/plugins/mail-login"
|
||||||
|
|
||||||
mkdir -p "$BASE_DIR/config" "$BASE_DIR/secrets" "$BASE_DIR/logs" "$BASE_DIR/state/rate-limit"
|
mkdir -p "$BASE_DIR/secrets" "$BASE_DIR/logs" "$BASE_DIR/state/rate-limit"
|
||||||
chmod 700 "$BASE_DIR/config" "$BASE_DIR/secrets" "$BASE_DIR/logs" "$BASE_DIR/state" "$BASE_DIR/state/rate-limit"
|
chmod 700 "$BASE_DIR/secrets" "$BASE_DIR/logs" "$BASE_DIR/state" "$BASE_DIR/state/rate-limit"
|
||||||
|
|
||||||
if [ ! -f "$BASE_DIR/config/plugin-settings.conf" ]; then
|
if [ -f "$PLUGIN_DIR/plugin-settings.conf" ]; then
|
||||||
cp "$PLUGIN_DIR/plugin-settings.conf" "$BASE_DIR/config/plugin-settings.conf"
|
chmod 600 "$PLUGIN_DIR/plugin-settings.conf"
|
||||||
chmod 600 "$BASE_DIR/config/plugin-settings.conf"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
touch "$BASE_DIR/logs/audit.log"
|
touch "$BASE_DIR/logs/audit.log"
|
||||||
chmod 600 "$BASE_DIR/logs/audit.log"
|
chmod 600 "$BASE_DIR/logs/audit.log"
|
||||||
|
|
||||||
echo "mail-login installed"
|
echo "mail-login installed; configuration is read from $PLUGIN_DIR/plugin-settings.conf"
|
||||||
|
|||||||
+8
-3
@@ -2,9 +2,14 @@
|
|||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
BASE_DIR="/usr/local/hitme_plugins/mail-login"
|
BASE_DIR="/usr/local/hitme_plugins/mail-login"
|
||||||
mkdir -p "$BASE_DIR/config" "$BASE_DIR/secrets" "$BASE_DIR/logs" "$BASE_DIR/state/rate-limit"
|
PLUGIN_DIR="/usr/local/directadmin/plugins/mail-login"
|
||||||
chmod 700 "$BASE_DIR/config" "$BASE_DIR/secrets" "$BASE_DIR/logs" "$BASE_DIR/state" "$BASE_DIR/state/rate-limit"
|
|
||||||
|
mkdir -p "$BASE_DIR/secrets" "$BASE_DIR/logs" "$BASE_DIR/state/rate-limit"
|
||||||
|
chmod 700 "$BASE_DIR/secrets" "$BASE_DIR/logs" "$BASE_DIR/state" "$BASE_DIR/state/rate-limit"
|
||||||
|
if [ -f "$PLUGIN_DIR/plugin-settings.conf" ]; then
|
||||||
|
chmod 600 "$PLUGIN_DIR/plugin-settings.conf"
|
||||||
|
fi
|
||||||
touch "$BASE_DIR/logs/audit.log"
|
touch "$BASE_DIR/logs/audit.log"
|
||||||
chmod 600 "$BASE_DIR/logs/audit.log"
|
chmod 600 "$BASE_DIR/logs/audit.log"
|
||||||
|
|
||||||
echo "mail-login updated; external configuration preserved"
|
echo "mail-login updated; configuration is read from $PLUGIN_DIR/plugin-settings.conf"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ test('plugin metadata and packaging docs match project rules', function (): void
|
|||||||
assert_contains('name=mail-login', $conf);
|
assert_contains('name=mail-login', $conf);
|
||||||
assert_contains('id=mail-login', $conf);
|
assert_contains('id=mail-login', $conf);
|
||||||
assert_contains('type=user', $conf);
|
assert_contains('type=user', $conf);
|
||||||
assert_contains('version=1.0.6', $conf);
|
assert_contains('version=1.0.7', $conf);
|
||||||
assert_contains('user_run_as=root', $conf);
|
assert_contains('user_run_as=root', $conf);
|
||||||
assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/src', $packing);
|
assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/src', $packing);
|
||||||
assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/archives/X.Y.Z/mail-login.tar.gz', $packing);
|
assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/archives/X.Y.Z/mail-login.tar.gz', $packing);
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ test('settings expose secure defaults from plugin-settings.conf', function (): v
|
|||||||
assert_same('https://mx1.mojserwer.pl:2222', $settings->targetBaseUrl());
|
assert_same('https://mx1.mojserwer.pl:2222', $settings->targetBaseUrl());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('settings runtime file is the directadmin plugin settings file', function (): void {
|
||||||
|
assert_same('/usr/local/directadmin/plugins/mail-login/plugin-settings.conf', Settings::EXTERNAL_SETTINGS);
|
||||||
|
});
|
||||||
|
|
||||||
test('settings reject login key ttl outside production range', function (): void {
|
test('settings reject login key ttl outside production range', function (): void {
|
||||||
foreach (['4', '301', 'abc'] as $ttl) {
|
foreach (['4', '301', 'abc'] as $ttl) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user