From dd6a7b96232dd12c57d3d54af9ae74a72890c191 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Wed, 28 May 2003 15:37:48 +0000 Subject: [PATCH] added option for Samba 3.x --- lam/config/lam.conf_sample | 3 +++ lam/help/help.inc | 5 +++- lam/lib/config.inc | 38 +++++++++++++++++++++++++++---- lam/templates/config/confmain.php | 13 ++++++++++- lam/templates/config/confsave.php | 9 ++++++++ lam/tests/conf-test.php | 5 ++++ 6 files changed, 66 insertions(+), 7 deletions(-) diff --git a/lam/config/lam.conf_sample b/lam/config/lam.conf_sample index 7f382346..3801243c 100644 --- a/lam/config/lam.conf_sample +++ b/lam/config/lam.conf_sample @@ -64,3 +64,6 @@ scriptPath: # Server of external Script scriptServer: + +# Set to "yes" only if you use the new Samba 3.x schema. +samba3: no diff --git a/lam/help/help.inc b/lam/help/help.inc index 112f0925..383a4c62 100644 --- a/lam/help/help.inc +++ b/lam/help/help.inc @@ -86,7 +86,10 @@ $helpArray = array ( "

Use it at your own risk and read the documentation for lamdaemon before you use it!"), "SeeAlso" => "TODO link to lamdaemon doku"), "212" => array ("ext" => "FALSE", "Headline" => _("Configuration Wizard - Change Password"), - "Text" => _("If you want to change the current preferences password, please enter it here.")) + "Text" => _("If you want to change the current preferences password, please enter it here.")), + "213" => array ("ext" => "FALSE", "Headline" => _("Configuration Wizard - Samba version"), + "Text" => _("If you use Samba 3.x with the new LDAP schema say \"yes\" here, otherwise \"no\".". + "

LAM will not work if version is wrong!")) /* This is a sample help entry. Just copy this line an modify the vakues between the [] brackets. Help text is located in the array: "[Helpnumber]" => array ("ext" => "FALSE", "Headline" => _("[Headline]"), "Text" => _("[Text]"), "SeeAlso" => "[SeeAlso link]"), diff --git a/lam/lib/config.inc b/lam/lib/config.inc index 647235ff..84ca0082 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -87,6 +87,9 @@ class Config { var $scriptPath; var $scriptServer; + // if "yes" use the new LDAP schema for Samba 3.x + var $samba3; + // constructor, loads preferences from ../config/lam.conf function Config() { $this->reload(); @@ -179,6 +182,10 @@ class Config { $this->scriptServer = chop(substr($line, 14, strlen($line)-14)); continue; } + if (substr($line, 0, 8) == "samba3: ") { + $this->samba3 = chop(substr($line, 8, strlen($line)-8)); + continue; + } } fclose($file); } @@ -195,7 +202,7 @@ class Config { $save_serverURL = $save_passwd = $save_admins = $save_suffusr = $save_suffgrp = $save_suffhst = $save_minUID = $save_maxUID = $save_minGID = $save_maxGID = $save_minMach = $save_maxMach = $save_usrlstatrr = $save_grplstatrr = $save_hstlstatrr = $save_maxlstent = $save_deflang = - $save_scriptPath = $save_scriptServer = False; + $save_scriptPath = $save_scriptServer = $save_samba3 = False; $file = fopen($conffile, "r"); $file_array = array(); while (!feof($file)) { @@ -300,6 +307,11 @@ class Config { $save_scriptServer = True; continue; } + if (substr($file_array[$i], 0, 8) == "samba3: ") { + $file_array[$i] = "samba3: " . $this->samba3 . "\n"; + $save_samba3 = True; + continue; + } } // check if we have to add new entries (e.g. if user upgraded LAM and has an old lam.conf) if (!$save_serverURL == True) array_push($file_array, "\n\n# server address (e.g. ldap://localhost:389 or ldaps://localhost:636)\n" . "serverURL: " . $this->ServerURL); @@ -329,6 +341,7 @@ class Config { if (!$save_deflang == True) array_push($file_array, "\n\n# default language (a line from language.conf)\n" . "defaultLanguage: " . $this->defaultLanguage); if (!$save_scriptPath == True) array_push($file_array, "\n\n# Path to external Script\n" . "scriptPath: " . $this->scriptPath); if (!$save_scriptServer == True) array_push($file_array, "\n\n# Server of external Script\n" . "scriptServer: " . $this->scriptServer); + if (!$save_samba3 == True) array_push($file_array, "\n\n# Set to \"yes\" only if you use the new Samba 3.x schema.\n" . "samba3: " . $this->samba3); $file = fopen($conffile, "w"); if ($file) { for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); @@ -344,7 +357,7 @@ class Config { // prints current preferences function printconf() { echo _("ServerURL: ") . $this->ServerURL . "
"; - echo _("Admins: ") . $this->Adminstring . "
"; + echo _("Samba3: ") . $this->samba3 . "
"; echo _("UserSuffix: ") . $this->Suff_users . "
"; echo _("GroupSuffix: ") . $this->Suff_groups . "
"; echo _("HostSuffix: ") . $this->Suff_hosts . "
"; @@ -360,7 +373,8 @@ class Config { echo _("maxlistentries: ") . $this->maxlistentries . "
"; echo _("defaultLanguage: ") . $this->defaultLanguage . "
"; echo _("scriptPath: ") . $this->scriptPath . "
"; - echo _("scriptServer: ") . $this->scriptServer; + echo _("scriptServer: ") . $this->scriptServer . "
"; + echo _("Admins: ") . $this->Adminstring; } // functions to read/write preferences @@ -403,7 +417,8 @@ class Config { // needs a string that contains all admin users seperated by semicolons function set_Adminstring($value) { - if (is_string($value) && eregi("^([a-z]|-)*=([a-z]|-)*(,([a-z]|-)*=([a-z]|-)*)*(;([a-z]|-)*=([a-z]|-)*(,([a-z]|-)*=([a-z]|-)*)*)*$", $value)) { + if (is_string($value) && + ereg("^([a-zA-Z0-9]|-)+=([a-zA-Z0-9]|-)+(,([a-zA-Z0-9]|-)+=([a-zA-Z0-9]|-)+)+(;([a-zA-Z0-9]|-)+=([a-zA-Z0-9]|-)+(,([a-zA-Z0-9]|-)+=([a-zA-Z0-9]|-)+)+)*$", $value)) { $this->Adminstring = $value; $this->Admins = explode(";", $value); } @@ -607,12 +622,25 @@ class Config { // sets the server of the external script function set_scriptServer($value) { if (!$value) $value = ""; // optional parameter - if (is_string($value) && (eregi("^([0-9]{3}.[0-9]{3}.[0-9]{3}.[0-9]{3})$", $value) || $value == "")) { + if (is_string($value) && (eregi("^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$", $value) || $value == "")) { $this->scriptServer = $value; } else StatusMessage("WARN", "", _("Config->set_scriptServer failed!") . " " . $value); } + // returns "yes" if Samba 3.x schema is used, otherwise "no" + function get_samba3() { + return $this->samba3; + } + + // set Samba version: "yes" means 3.x schema, "no" means 2.2.x schema + function set_samba3($value) { + if (is_string($value) && eregi("^(yes|no)$", $value)) { + $this->samba3 = $value; + } + else StatusMessage("WARN", "", _("Config->set_samba3 failed!") . " " . $value); + } + } diff --git a/lam/templates/config/confmain.php b/lam/templates/config/confmain.php index e00c4e03..6c6ec213 100644 --- a/lam/templates/config/confmain.php +++ b/lam/templates/config/confmain.php @@ -56,13 +56,14 @@ if ($_POST['back'] || $_POST['submitconf']){ if ($_POST['maxlistentries']) $maxlistentries = $_POST['maxlistentries']; if ($_POST['language']) $language = $_POST['language']; if ($_POST['scriptpath']) $scriptpath = $_POST['scriptpath']; + if ($_POST['samba3']) $samba3 = $_POST['samba3']; else $scriptpath = ""; if ($_POST['scriptserver']) $scriptserver = $_POST['scriptserver']; else $scriptserver = ""; session_register('passwd', 'passwd1', 'passwd2', 'serverurl', 'admins', 'suffusers', 'suffgroups', 'suffhosts', 'minUID', 'maxUID', 'minGID', 'maxGID', 'minMach', 'maxMach', 'usrlstattr', 'grplstattr', 'hstlstattr', 'maxlistentries', 'language', - 'scriptpath', 'scriptserver'); + 'scriptpath', 'scriptserver', 'samba3'); echo(""); } // back to login @@ -131,6 +132,16 @@ echo ("

". "get_HostSuffix() . "\">\n"); echo ("" . _("Help") . "\n"); +// new line +echo (" "); + +// Samba version +echo ("

". + _("Samba 3.x schema") . ":