From c9bc296a4287731fa123f89cd51f12e072f8fdcb Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 2 May 2025 07:38:33 +0200 Subject: [PATCH 1/7] #409 split config of custom scripts --- lam/tests/lib/modules/CustomScriptsTest.php | 32 ++------------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/lam/tests/lib/modules/CustomScriptsTest.php b/lam/tests/lib/modules/CustomScriptsTest.php index cdb0e4d9d..49ece0d30 100644 --- a/lam/tests/lib/modules/CustomScriptsTest.php +++ b/lam/tests/lib/modules/CustomScriptsTest.php @@ -70,17 +70,13 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) { public function testCustomScriptParser() { $parser = new \CustomScriptParser(); - $scripts = $parser->parse($this->configLines, false); + $scripts = $parser->parse($this->configLines); $this->assertNotEmpty($scripts); $this->assertEquals(7, count($scripts)); $typeManager = new TypeManager(); $script = $scripts[0]; - $configuredType = new ConfiguredType($typeManager, 'user', 'user'); - $configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1'); - $this->assertTrue($script->matchesConfiguredType($configuredType)); - $this->assertFalse($script->matchesConfiguredType($configuredWrongType)); $this->assertTrue($script->isManual()); $this->assertEquals('echo $uid$', $script->getCommand()); $this->assertEquals('manual', $script->getType()); @@ -88,10 +84,6 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) { $this->assertEquals('Group 1', $script->getGroupLabel()); $script = $scripts[1]; - $configuredType = new ConfiguredType($typeManager, 'user', 'user'); - $configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1'); - $this->assertTrue($script->matchesConfiguredType($configuredType)); - $this->assertFalse($script->matchesConfiguredType($configuredWrongType)); $this->assertTrue($script->isManual()); $this->assertEquals('echo $description$', $script->getCommand()); $this->assertEquals('manual', $script->getType()); @@ -99,10 +91,6 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) { $this->assertEquals('Group 2', $script->getGroupLabel()); $script = $scripts[2]; - $configuredType = new ConfiguredType($typeManager, 'user', 'user'); - $configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1'); - $this->assertTrue($script->matchesConfiguredType($configuredType)); - $this->assertFalse($script->matchesConfiguredType($configuredWrongType)); $this->assertFalse($script->isManual()); $this->assertEquals('echo $dn$', $script->getCommand()); $this->assertEquals('postModify', $script->getType()); @@ -110,10 +98,6 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) { $this->assertEquals(_('Post-modify'), $script->getTypeLabel()); $script = $scripts[3]; - $configuredType = new ConfiguredType($typeManager, 'gon', 'gon_1'); - $configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1'); - $this->assertTrue($script->matchesConfiguredType($configuredType)); - $this->assertFalse($script->matchesConfiguredType($configuredWrongType)); $this->assertFalse($script->isManual()); $this->assertEquals('echo NEW $member$ OLD $ORIG.member$', $script->getCommand()); $this->assertEquals('preModify', $script->getType()); @@ -121,20 +105,12 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) { $this->assertEquals(_('Pre-modify'), $script->getTypeLabel()); $script = $scripts[4]; - $configuredType = new ConfiguredType($typeManager, 'group', 'group_3'); - $configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1'); - $this->assertTrue($script->matchesConfiguredType($configuredType)); - $this->assertFalse($script->matchesConfiguredType($configuredWrongType)); $this->assertTrue($script->isManual()); $this->assertEquals('echo group3', $script->getCommand()); $this->assertEquals('manual', $script->getType()); $this->assertNull($script->getLabel()); $script = $scripts[5]; - $configuredType = new ConfiguredType($typeManager, 'group', 'group_3'); - $configuredWrongType = new ConfiguredType($typeManager, 'gon', 'gon_1'); - $this->assertTrue($script->matchesConfiguredType($configuredType)); - $this->assertFalse($script->matchesConfiguredType($configuredWrongType)); $this->assertFalse($script->isManual()); $this->assertEquals('echo group3', $script->getCommand()); $this->assertEquals('postCreate', $script->getType()); @@ -142,10 +118,6 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) { $this->assertEquals(_('Post-create'), $script->getTypeLabel()); $script = $scripts[6]; - $configuredType = new ConfiguredType($typeManager, 'group', 'group_3'); - $configuredWrongType = new ConfiguredType($typeManager, 'gon', 'gon_1'); - $this->assertTrue($script->matchesConfiguredType($configuredType)); - $this->assertFalse($script->matchesConfiguredType($configuredWrongType)); $this->assertFalse($script->isManual()); $this->assertEquals('echo group', $script->getCommand()); $this->assertEquals('preCreate', $script->getType()); @@ -174,7 +146,7 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) { public function testCustomScriptParserSelfService() { $parser = new \CustomScriptParser(); - $scripts = $parser->parse($this->configLinesSelfService, true); + $scripts = $parser->parse($this->configLinesSelfService); $this->assertNotEmpty($scripts); $this->assertEquals(2, count($scripts)); From 03a9dc83e06110d75c6c1cb28e8f832cbbf7a74b Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 2 May 2025 07:53:54 +0200 Subject: [PATCH 2/7] #409 split config of custom scripts --- lam/HISTORY | 2 ++ .../manual-sources/chapter-installation.xml | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/lam/HISTORY b/lam/HISTORY index 035a7e09a..8b715d611 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -4,6 +4,8 @@ June 2025 9.2 - Multi-edit tool: change operations are combined by DN to allow e.g. adding object classes with required attributes (408) - Windows users: support thumbnail images (needs to be activated in server profile) (431) - Tree view: better editing of olcAccess (420) + - LAM Pro: + -> Custom scripts: split config by account type (409) - Fixed bugs: -> Unix: profile editor for users not working (418) -> Custom fields: problems with deleting facsimileTelephoneNumber (419) diff --git a/lam/docs/manual-sources/chapter-installation.xml b/lam/docs/manual-sources/chapter-installation.xml index 7bbb52c74..363b4679a 100644 --- a/lam/docs/manual-sources/chapter-installation.xml +++ b/lam/docs/manual-sources/chapter-installation.xml @@ -608,6 +608,36 @@ version. Unless explicitly noticed there is no need to install an intermediate release. +
+ 9.1 -> 9.2 + + LAM Pro: + + + + Custom scripts: The settings in server profile were split by + account type. If you use custom scripts then please perform these + steps for each server profile that uses them: + + + + Open server profile and switch to tab "Module + settings" + + + + Review the automated migration of the custom scripts + settings + + + + Save the server profile + + + + +
+
9.0 -> 9.1 From a942c1a91d39806f2b32ad292143088903ae6a0e Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 2 May 2025 07:59:40 +0200 Subject: [PATCH 3/7] #409 split config of custom scripts --- lam/tests/lib/modules/CustomScriptsTest.php | 36 ++++----------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/lam/tests/lib/modules/CustomScriptsTest.php b/lam/tests/lib/modules/CustomScriptsTest.php index 49ece0d30..bad5313c7 100644 --- a/lam/tests/lib/modules/CustomScriptsTest.php +++ b/lam/tests/lib/modules/CustomScriptsTest.php @@ -51,16 +51,13 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) { 'LAM_TEXT_COMMENT: Comment=no comment', 'LAM_TEXT_AMOUNT:Amount', 'LAM_GROUP: Group 1', - 'user manual LAMLABEL="echo uid" echo $uid$', + 'manual LAMLABEL="echo uid" echo $uid$', 'LAM_GROUP: Group 2', - 'user manual echo $description$', - 'user postModify echo $dn$', - 'gon preModify echo NEW $member$ OLD $ORIG.member$', + 'manual echo $description$', + 'postModify echo $dn$', '', ' ', - 'group:group_3 manual echo group3', - 'group:group_3 postCreate echo group3', - 'group preCreate echo group', + 'preCreate echo user', ]; $this->configLinesSelfService = [ 'postModify echo $dn$', @@ -73,8 +70,7 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) { $scripts = $parser->parse($this->configLines); $this->assertNotEmpty($scripts); - $this->assertEquals(7, count($scripts)); - $typeManager = new TypeManager(); + $this->assertEquals(4, count($scripts)); $script = $scripts[0]; $this->assertTrue($script->isManual()); @@ -99,27 +95,7 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) { $script = $scripts[3]; $this->assertFalse($script->isManual()); - $this->assertEquals('echo NEW $member$ OLD $ORIG.member$', $script->getCommand()); - $this->assertEquals('preModify', $script->getType()); - $this->assertNull($script->getLabel()); - $this->assertEquals(_('Pre-modify'), $script->getTypeLabel()); - - $script = $scripts[4]; - $this->assertTrue($script->isManual()); - $this->assertEquals('echo group3', $script->getCommand()); - $this->assertEquals('manual', $script->getType()); - $this->assertNull($script->getLabel()); - - $script = $scripts[5]; - $this->assertFalse($script->isManual()); - $this->assertEquals('echo group3', $script->getCommand()); - $this->assertEquals('postCreate', $script->getType()); - $this->assertNull($script->getLabel()); - $this->assertEquals(_('Post-create'), $script->getTypeLabel()); - - $script = $scripts[6]; - $this->assertFalse($script->isManual()); - $this->assertEquals('echo group', $script->getCommand()); + $this->assertEquals('echo user', $script->getCommand()); $this->assertEquals('preCreate', $script->getType()); $this->assertNull($script->getLabel()); $this->assertEquals(_('Pre-create'), $script->getTypeLabel()); From cfe93d6dcad36c3c3610fe48b9527efd8fde5327 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 2 May 2025 08:00:06 +0200 Subject: [PATCH 4/7] #409 split config of custom scripts --- lam/tests/lib/modules/CustomScriptsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lam/tests/lib/modules/CustomScriptsTest.php b/lam/tests/lib/modules/CustomScriptsTest.php index bad5313c7..d0b95566d 100644 --- a/lam/tests/lib/modules/CustomScriptsTest.php +++ b/lam/tests/lib/modules/CustomScriptsTest.php @@ -9,7 +9,7 @@ use PHPUnit\Framework\TestCase; /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2024 Roland Gruber + Copyright (C) 2024 - 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 From a81c6e64f39066dc7b2ecb04be40f249801b3930 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Mon, 5 May 2025 07:30:24 +0200 Subject: [PATCH 5/7] #409 split config of custom scripts --- lam/docs/manual-sources/chapter-installation.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lam/docs/manual-sources/chapter-installation.xml b/lam/docs/manual-sources/chapter-installation.xml index 363b4679a..e88dc9f9a 100644 --- a/lam/docs/manual-sources/chapter-installation.xml +++ b/lam/docs/manual-sources/chapter-installation.xml @@ -616,8 +616,9 @@ Custom scripts: The settings in server profile were split by - account type. If you use custom scripts then please perform these - steps for each server profile that uses them: + account type. If you use custom scripts then you need to perform + these steps for each server profile that uses them (no scripts + will be executed till migration was done): From 14b8968f0690bd773e25a8b72528bac1cf1b60f7 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Mon, 5 May 2025 07:42:31 +0200 Subject: [PATCH 6/7] #409 split config of custom scripts --- lam/docs/manual-sources/chapter-installation.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lam/docs/manual-sources/chapter-installation.xml b/lam/docs/manual-sources/chapter-installation.xml index e88dc9f9a..9acaaaff7 100644 --- a/lam/docs/manual-sources/chapter-installation.xml +++ b/lam/docs/manual-sources/chapter-installation.xml @@ -628,7 +628,8 @@ Review the automated migration of the custom scripts - settings + settings (complex configurations will need manual + adaptions) From 57b1b98aeaf206f88a1c4694d4a473a5c600e48d Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Mon, 5 May 2025 07:49:20 +0200 Subject: [PATCH 7/7] refactoring --- lam/lib/config.inc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lam/lib/config.inc b/lam/lib/config.inc index 52ce8d7dd..4d933bc02 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -120,9 +120,9 @@ function setlanguage() { * @param string $target owner, group or other * @param string $chmod the chmod rights * - * @return true, if the chmod $right for $target were set + * @return bool true, if the chmod $right for $target were set */ -function checkChmod($right, $target, $chmod) { +function checkChmod($right, $target, $chmod): bool { $right_arr = ["read", "write", "execute"]; $target_arr = ["owner", "group", "other"]; @@ -133,13 +133,13 @@ function checkChmod($right, $target, $chmod) { $chmod_num = -1; // owner: - if ($target == "owner") { + if ($target === "owner") { $chmod_num = 0; } - if ($target == "group") { + if ($target === "group") { $chmod_num = 1; } - if ($target == "other") { + if ($target === "other") { $chmod_num = 2; } @@ -153,9 +153,9 @@ function checkChmod($right, $target, $chmod) { $write = [2, 3, 6, 7]; // What numbers allow "execute" $execute = [1, 3, 5, 7]; - return (($right == "read") && in_array($chmod_num, $read)) - || (($right == "write") && in_array($chmod_num, $write)) - || (($right == "execute") && in_array($chmod_num, $execute)); + return (($right === "read") && in_array($chmod_num, $read)) + || (($right === "write") && in_array($chmod_num, $write)) + || (($right === "execute") && in_array($chmod_num, $execute)); } /**