added option for Samba 3.x

This commit is contained in:
Roland Gruber 2003-05-28 15:37:48 +00:00
parent 29c27d652c
commit dd6a7b9623
6 changed files with 66 additions and 7 deletions

View File

@ -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

View File

@ -86,7 +86,10 @@ $helpArray = array (
"<br><br><b>Use it at your own risk and read the documentation for lamdaemon before you use it!</b>"),
"SeeAlso" => "<a href=\"./help.php?HelpNumber=210\" target=\"_self\">TODO link to lamdaemon doku</a>"),
"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\".".
"<br><br><b>LAM will not work if version is wrong!</b>"))
/* 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]"),

View File

@ -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 _("<b>ServerURL: </b>") . $this->ServerURL . "<br>";
echo _("<b>Admins: </b>") . $this->Adminstring . "<br>";
echo _("<b>Samba3: </b>") . $this->samba3 . "<br>";
echo _("<b>UserSuffix: </b>") . $this->Suff_users . "<br>";
echo _("<b>GroupSuffix: </b>") . $this->Suff_groups . "<br>";
echo _("<b>HostSuffix: </b>") . $this->Suff_hosts . "<br>";
@ -360,7 +373,8 @@ class Config {
echo _("<b>maxlistentries: </b>") . $this->maxlistentries . "<br>";
echo _("<b>defaultLanguage: </b>") . $this->defaultLanguage . "<br>";
echo _("<b>scriptPath: </b>") . $this->scriptPath . "<br>";
echo _("<b>scriptServer: </b>") . $this->scriptServer;
echo _("<b>scriptServer: </b>") . $this->scriptServer . "<br>";
echo _("<b>Admins: </b>") . $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);
}
}

View File

@ -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("<meta http-equiv=\"refresh\" content=\"0; URL=confsave.php\">");
}
// back to login
@ -131,6 +132,16 @@ echo ("<tr><td><p align=\"right\"><b>".
"<td><input size=50 type=\"text\" name=\"suffhosts\" value=\"" . $conf->get_HostSuffix() . "\"></td>\n");
echo ("<td><a href=\"../help.php?HelpNumber=202\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
// new line
echo ("<tr><td>&nbsp</td></tr>");
// Samba version
echo ("<tr><td><p align=\"right\"><b>".
_("Samba 3.x schema") . ": </b></p></td><td><select name=\"samba3\">\n");
if ($conf->get_samba3() == "no") echo ("<option>no</option><option>yes</option></td>");
elseif ($conf->get_samba3() == "yes") echo ("<option>yes</option><option>no</option></td>");
echo ("<td><a href=\"../help.php?HelpNumber=213\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
echo ("</table>");
echo ("</fieldset>");
echo ("<br>");

View File

@ -53,6 +53,7 @@ if ($_SESSION['maxlistentries']) $maxlistentries = $_SESSION['maxlistentries'];
if ($_SESSION['language']) $language = $_SESSION['language'];
if ($_SESSION['scriptpath']) $scriptpath = $_SESSION['scriptpath'];
if ($_SESSION['scriptserver']) $scriptserver = $_SESSION['scriptserver'];
if ($_SESSION['samba3']) $samba3 = $_SESSION['samba3'];
// check if password is correct
// if not: load login page
@ -151,6 +152,12 @@ if (chop($language) == "") {
exit;
}
if (chop($samba3) == "") {
echo _("<font color=\"red\"><b>" . _("Samba version is not defined!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
// set new preferences
$conf->set_ServerURL($serverurl);
$conf->set_Adminstring($admins);
@ -168,6 +175,7 @@ $conf->set_grouplistAttributes($grplstattr);
$conf->set_hostlistAttributes($hstlstattr);
$conf->set_MaxListEntries($maxlistentries);
$conf->set_defaultLanguage($language);
$conf->set_samba3($samba3);
// optional
if ($_SESSION['scriptpath']) $conf->set_scriptpath($scriptpath);
else $conf->set_scriptpath("");
@ -216,5 +224,6 @@ unset($_SESSION['maxlistentries']);
unset($_SESSION['language']);
unset($_SESSION['scriptpath']);
unset($_SESSION['scriptserver']);
unset($_SESSION['samba3']);
?>

View File

@ -25,6 +25,7 @@ $Id$
include ("../lib/config.inc");
$conf = new Config();
echo "<html><head><title></title><link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\"></head><body>";
echo ("<b> Current Config</b><br><br>");
$conf->printconf();
echo ("<br><br><big><b> Starting Test...</b></big><br><br>");
@ -50,6 +51,7 @@ $maxlistentries = $conf->get_maxlistentries();
$defaultlanguage = $conf->get_defaultlanguage();
$scriptpath = $conf->get_scriptPath();
$scriptServer = $conf->get_scriptServer();
$samba3 = $conf->get_samba3();
echo ("done<br>");
// next we modify them and save lam.conf
echo ("Changing preferences...");
@ -73,6 +75,7 @@ $conf->set_maxlistentries("54");
$conf->set_defaultlanguage("de_AT:iso639_de:Deutsch (Oesterreich)");
$conf->set_scriptPath("/var/www/lam/lib/script");
$conf->set_scriptServer("127.0.0.1");
$conf->set_samba3("yes");
$conf->save();
echo ("done<br>");
// at last all preferences are read from lam.conf and compared
@ -100,6 +103,7 @@ if ($conf->get_maxlistentries() != "54") echo ("<br><font color=\"#FF0000\">Savi
if ($conf->get_defaultlanguage() != "de_AT:iso639_de:Deutsch (Oesterreich)") echo ("<br><font color=\"#FF0000\">Saving default language failed!</font><br>");
if ($conf->get_scriptPath() != "/var/www/lam/lib/script") echo ("<br><font color=\"#FF0000\">Saving script path failed!</font><br>");
if ($conf->get_scriptServer() != "127.0.0.1") echo ("<br><font color=\"#FF0000\">Saving script server failed!</font><br>");
if ($conf->get_samba3() != "yes") echo ("<br><font color=\"#FF0000\">Saving samba3 failed!</font><br>");
echo ("done<br>");
// restore old values
echo ("Restoring old preferences...");
@ -123,6 +127,7 @@ $conf->set_maxlistentries($maxlistentries);
$conf->set_defaultLanguage($defaultlanguage);
$conf->set_scriptPath($scriptpath);
$conf->set_scriptServer($scriptserver);
$conf->set_samba3($samba3);
$conf->save();
echo ("done<br>");
// finished