added domain and mapping suffix

This commit is contained in:
Roland Gruber 2003-07-25 15:41:51 +00:00
parent 7ea74fe3c2
commit 16635cfadd
3 changed files with 99 additions and 59 deletions

View File

@ -494,7 +494,7 @@ class Config {
// needs a string that contains all admin users seperated by semicolons
function set_Adminstring($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)) {
eregi("^([a-z0-9]|-)+=([a-z0-9]|-)+(,([a-z0-9]|-)+=([a-z0-9]|-)+)+(;([a-z0-9]|-)+=([a-z0-9]|-)+(,([a-z0-9]|-)+=([a-z0-9]|-)+)+)*$", $value)) {
$this->Adminstring = $value;
$this->Admins = explode(";", $value);
}
@ -713,8 +713,8 @@ class Config {
// sets the path to the external script
function set_scriptPath($value) {
if (!$value) $value = ""; // optional parameter
if (is_string($value) && eregi("^()|(/([a-z]|[0-9]|-|_|/)*)$", $value)) $this->scriptPath = $value;
if (!$value) $this->scriptPath = ""; // optional parameter
elseif (is_string($value) && eregi("^/([a-z0-9_\\-])+(/([a-z0-9_\\-])+)+$", $value)) $this->scriptPath = $value;
else StatusMessage("WARN", "", _("Config->set_scriptPath failed!") . " (" . $value . ")");
}
@ -726,7 +726,7 @@ 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]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$", $value) || $value == "")) {
if (is_string($value)) {
$this->scriptServer = $value;
}
else StatusMessage("WARN", "", _("Config->set_scriptServer failed!") . " (" . $value . ")");

View File

@ -46,6 +46,8 @@ if ($_POST['back'] || $_POST['submitconf']){
if ($_POST['suffusers']) $suffusers = $_POST['suffusers'];
if ($_POST['suffgroups']) $suffgroups = $_POST['suffgroups'];
if ($_POST['suffhosts']) $suffhosts = $_POST['suffhosts'];
if ($_POST['suffdomains']) $suffdomains = $_POST['suffdomains'];
if ($_POST['suffmap']) $suffmap = $_POST['suffmap'];
if ($_POST['minUID']) $minUID = $_POST['minUID'];
if ($_POST['maxUID']) $maxUID = $_POST['maxUID'];
if ($_POST['minGID']) $minGID = $_POST['minGID'];
@ -66,9 +68,9 @@ if ($_POST['back'] || $_POST['submitconf']){
else $scriptserver = "";
if ($_POST['filename']) $filename = $_POST['filename'];
session_register('passwd', 'passwd1', 'passwd2', 'serverurl', 'admins', 'suffusers',
'suffgroups', 'suffhosts', 'minUID', 'maxUID', 'minGID', 'maxGID', 'minMach',
'maxMach', 'usrlstattr', 'grplstattr', 'hstlstattr', 'maxlistentries', 'lang',
'scriptpath', 'scriptserver', 'samba3', 'domainSID', 'filename');
'suffgroups', 'suffhosts', 'suffdomains', 'suffmap', 'minUID', 'maxUID', 'minGID',
'maxGID', 'minMach', 'maxMach', 'usrlstattr', 'grplstattr', 'hstlstattr', 'maxlistentries',
'lang', 'scriptpath', 'scriptserver', 'samba3', 'domainSID', 'filename');
echo("<meta http-equiv=\"refresh\" content=\"0; URL=confsave.php\">");
}
// back to login
@ -117,7 +119,7 @@ echo ("<form action=\"confmain.php\" method=\"post\">\n");
echo ("<fieldset><legend><b>" . _("Server settings") . "</b></legend>");
echo ("<table border=0>");
// serverURL
echo ("<tr><td align=\"right\"><b>" . _("Server Address") . ": </b></td>".
echo ("<tr><td align=\"right\"><b>" . _("Server Address") . " *: </b></td>".
"<td align=\"left\">".
"<input size=50 type=\"text\" name=\"serverurl\" value=\"" . $conf->get_ServerURL() . "\">".
"</td>\n");
@ -128,19 +130,29 @@ echo ("<tr><td colspan=3>&nbsp</td></tr>");
// user suffix
echo ("<tr><td align=\"right\"><b>".
_("UserSuffix") . ": </b></td>".
_("UserSuffix") . " *: </b></td>".
"<td><input size=50 type=\"text\" name=\"suffusers\" value=\"" . $conf->get_UserSuffix() . "\"></td>\n");
echo ("<td><a href=\"../help.php?HelpNumber=202\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
// group suffix
echo ("<tr><td align=\"right\"><b>".
_("GroupSuffix") . ": </b></td>".
_("GroupSuffix") . " *: </b></td>".
"<td><input size=50 type=\"text\" name=\"suffgroups\" value=\"" . $conf->get_GroupSuffix() . "\"></td>\n");
echo ("<td><a href=\"../help.php?HelpNumber=202\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
// host suffix
echo ("<tr><td align=\"right\"><b>".
_("HostSuffix") . ": </b></td>".
_("HostSuffix") . " *: </b></td>".
"<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");
// domain suffix
echo ("<tr><td align=\"right\"><b>".
_("DomainSuffix") . " **: </b></td>".
"<td><input size=50 type=\"text\" name=\"suffdomains\" value=\"" . $conf->get_DomainSuffix() . "\"></td>\n");
echo ("<td><a href=\"../help.php?HelpNumber=215\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
// mapping suffix
echo ("<tr><td align=\"right\"><b>".
_("MappingSuffix") . ": </b></td>".
"<td><input size=50 type=\"text\" name=\"suffmap\" value=\"" . $conf->get_MapSuffix() . "\"></td>\n");
echo ("<td><a href=\"../help.php?HelpNumber=216\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
echo ("</table>");
echo ("</fieldset>");
@ -161,7 +173,7 @@ echo ("<tr><td colspan=3>&nbsp</td></tr>");
// Samba domain SID
echo ("<tr><td align=\"right\"><b>".
_("Domain SID (Samba 3 only)") . ": </b></td>".
_("Domain SID") . " **: </b></td>".
"<td><input size=50 type=\"text\" name=\"domainSID\" value=\"" . $conf->get_domainSID() . "\"></td>\n");
echo ("<td><a href=\"../help.php?HelpNumber=214\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
@ -174,28 +186,28 @@ echo ("<table border=0>");
// minUID
echo ("<tr><td align=\"right\"><b>".
_("Minimum UID number") . ": </b>".
_("Minimum UID number") . " *: </b>".
"<input size=6 type=\"text\" name=\"minUID\" value=\"" . $conf->get_minUID() . "\"></td>\n");
// maxUID
echo ("<td align=\"right\"><b>" . _("Maximum UID number") . ": </b>".
echo ("<td align=\"right\"><b>" . _("Maximum UID number") . " *: </b>".
"<input size=6 type=\"text\" name=\"maxUID\" value=\"" . $conf->get_maxUID() . "\"></td>\n");
// UID text
echo ("<td><a href=\"../help.php?HelpNumber=203\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
// minGID
echo ("<tr><td align=\"right\"><b>".
_("Minimum GID number") . ": </b>".
_("Minimum GID number") . " *: </b>".
"<input size=6 type=\"text\" name=\"minGID\" value=\"" . $conf->get_minGID() . "\"></td>\n");
// maxGID
echo ("<td align=\"right\"><b>" . _("Maximum GID number").": </b>".
echo ("<td align=\"right\"><b>" . _("Maximum GID number")." *: </b>".
"<input size=6 type=\"text\" name=\"maxGID\" value=\"" . $conf->get_maxGID() . "\"></td>\n");
// GID text
echo ("<td><a href=\"../help.php?HelpNumber=204\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
// minMach
echo ("<tr><td align=\"right\"><b>".
_("Minimum Machine number") . ": </b>".
_("Minimum Machine number") . " *: </b>".
"<input size=6 type=\"text\" name=\"minMach\" value=\"" . $conf->get_minMachine() . "\"></td>\n");
// maxMach
echo ("<td align=\"right\"><b>" . _("Maximum Machine number") . ": </b>".
echo ("<td align=\"right\"><b>" . _("Maximum Machine number") . " *: </b>".
"<input size=6 type=\"text\" name=\"maxMach\" value=\"" . $conf->get_maxMachine() . "\"></td>\n");
// Machine text
echo ("<td><a href=\"../help.php?HelpNumber=205\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
@ -209,17 +221,17 @@ echo ("<table border=0>\n");
// user list attributes
echo ("<tr><td align=\"right\"><b>".
_("Attributes in User List") . ":</b></td>".
_("Attributes in User List") . " *:</b></td>".
"<td><input size=50 type=\"text\" name=\"usrlstattr\" value=\"" . $conf->get_userlistAttributes() . "\"></td>");
echo ("<td><a href=\"../help.php?HelpNumber=206\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
// user list attributes
echo ("<tr><td align=\"right\"><b>".
_("Attributes in Group List") . ":</b></td>".
_("Attributes in Group List") . " *:</b></td>".
"<td><input size=50 type=\"text\" name=\"grplstattr\" value=\"" . $conf->get_grouplistAttributes() . "\"></td>");
echo ("<td><a href=\"../help.php?HelpNumber=206\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
// user list attributes
echo ("<tr><td align=\"right\"><b>".
_("Attributes in Host List") . ":</b></td>".
_("Attributes in Host List") . " *:</b></td>".
"<td><input size=50 type=\"text\" name=\"hstlstattr\" value=\"" . $conf->get_hostlistAttributes() . "\"></td>");
echo ("<td><a href=\"../help.php?HelpNumber=206\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
@ -227,7 +239,7 @@ echo ("<tr><td colspan=3>&nbsp</td></tr>\n");
// maximum list entries
echo ("<tr><td align=\"right\"><b>".
_("Maximum list entries") . ": </b></td>".
_("Maximum list entries") . " *: </b></td>".
"<td><select name=\"maxlistentries\">\n<option selected>".$conf->get_MaxListEntries()."</option>\n");
if ($conf->get_MaxListEntries() != 10) echo("<option>10</option>\n");
if ($conf->get_MaxListEntries() != 20) echo("<option>20</option>\n");
@ -247,7 +259,7 @@ echo ("<table border=0>\n");
// language
echo ("<tr>");
echo ("<td><b>" . _("Default Language") . "</b></td><td>\n");
echo ("<td><b>" . _("Default Language") . ":</b></td><td>\n");
// read available languages
$languagefile = "../../config/language";
if(is_file($languagefile))
@ -304,7 +316,7 @@ echo ("<fieldset><legend><b>" . _("Security settings") . "</b></legend>\n");
echo ("<table border=0>\n");
// admin list
echo ("<tr><td align=\"right\"><b>".
_("List of valid users") . ": </b></td>".
_("List of valid users") . " *: </b></td>".
"<td colspan=2><input size=50 type=\"text\" name=\"admins\" value=\"" . $conf->get_Adminstring() . "\"></td>\n");
echo ("<td><a href=\"../help.php?HelpNumber=207\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
echo ("</table>\n");
@ -340,6 +352,9 @@ echo ("</table>\n");
echo ("<p></p>");
echo ("<p>* = ". _("required") . "</p>");
echo ("<p>** = ". _("required for Samba 3 schema") . "</p>");
// password for configuration
echo ("<p><input type=\"hidden\" name=\"passwd\" value=\"" . $passwd . "\"></p>\n");

View File

@ -42,6 +42,8 @@ if ($_SESSION['admins']) $admins = $_SESSION['admins'];
if ($_SESSION['suffusers']) $suffusers = $_SESSION['suffusers'];
if ($_SESSION['suffgroups']) $suffgroups = $_SESSION['suffgroups'];
if ($_SESSION['suffhosts']) $suffhosts = $_SESSION['suffhosts'];
if ($_SESSION['suffdomains']) $suffdomains = $_SESSION['suffdomains'];
if ($_SESSION['suffmap']) $suffmap = $_SESSION['suffmap'];
if ($_SESSION['minUID']) $minUID = $_SESSION['minUID'];
if ($_SESSION['maxUID']) $maxUID = $_SESSION['maxUID'];
if ($_SESSION['minGID']) $minGID = $_SESSION['minGID'];
@ -82,73 +84,83 @@ if (!$serverurl) {
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$admins) {
echo ("<font color=\"red\"><b>" . _("List of admin users is empty!") . "</b></font>");
if (!$admins || !eregi("^([a-z0-9]|-)+=([a-z0-9]|-)+(,([a-z0-9]|-)+=([a-z0-9]|-)+)+(;([a-z0-9]|-)+=([a-z0-9]|-)+(,([a-z0-9]|-)+=([a-z0-9]|-)+)+)*$", $admins)) {
echo ("<font color=\"red\"><b>" . _("List of admin users is empty or invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$suffusers) {
echo ("<font color=\"red\"><b>" . _("UserSuffix is empty!") . "</b></font>");
if (!$suffusers || !eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $suffusers)) {
echo ("<font color=\"red\"><b>" . _("UserSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$suffgroups) {
echo ("<font color=\"red\"><b>" . _("UserSuffix is empty!") . "</b></font>");
if (!$suffgroups || !eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $suffgroups)) {
echo ("<font color=\"red\"><b>" . _("UserSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$suffhosts) {
echo ("<font color=\"red\"><b>" . _("HostSuffix is empty!") . "</b></font>");
if (!$suffhosts || !eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $suffhosts)) {
echo ("<font color=\"red\"><b>" . _("HostSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$minUID) {
echo ("<font color=\"red\"><b>" . _("MinUID is empty!") . "</b></font>");
if (($samba3 == "yes") && !eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $suffdomains)) {
echo ("<font color=\"red\"><b>" . _("DomainSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$maxUID) {
echo ("<font color=\"red\"><b>" . _("MaxUID is empty!") . "</b></font>");
if ($suffmap && !eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $suffmap)) {
echo ("<font color=\"red\"><b>" . _("MappingSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$minGID) {
echo ("<font color=\"red\"><b>" . _("MinGID is empty!") . "</b></font>");
if (!$minUID || !is_numeric($minUID)) {
echo ("<font color=\"red\"><b>" . _("MinUID is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$maxGID) {
echo ("<font color=\"red\"><b>" . _("MaxGID is empty!") . "</b></font>");
if (!$maxUID || !is_numeric($maxUID)) {
echo ("<font color=\"red\"><b>" . _("MaxUID is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$minMach) {
echo ("<font color=\"red\"><b>" . _("MinMachine is empty!") . "</b></font>");
if (!$minGID || !is_numeric($minGID)) {
echo ("<font color=\"red\"><b>" . _("MinGID is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$maxMach) {
echo ("<font color=\"red\"><b>" . _("MaxMachine is empty!") . "</b></font>");
if (!$maxGID || !is_numeric($maxGID)) {
echo ("<font color=\"red\"><b>" . _("MaxGID is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$usrlstattr) {
echo ("<font color=\"red\"><b>" . _("No attributes in user list!") . "</b></font>");
if (!$minMach || !is_numeric($minMach)) {
echo ("<font color=\"red\"><b>" . _("MinMachine is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$grplstattr) {
echo ("<font color=\"red\"><b>" . _("No attributes in group list!") . "</b></font>");
if (!$maxMach || !is_numeric($maxMach)) {
echo ("<font color=\"red\"><b>" . _("MaxMachine is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$hstlstattr) {
echo ("<font color=\"red\"><b>" . _("No attributes in host list!") . "</b></font>");
if (!$usrlstattr || !eregi("^((#[a-z]*)|([a-z]*:[a-z*]))(;((#[a-z]*)|([a-z]*:[a-z]*)))*$", $usrlstattr)) {
echo ("<font color=\"red\"><b>" . _("User list attributes are invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$maxlistentries) {
echo ("<font color=\"red\"><b>" . _("Max list entries is empty!") . "</b></font>");
if (!$grplstattr || !eregi("^((#[a-z]*)|([a-z]*:[a-z*]))(;((#[a-z]*)|([a-z]*:[a-z]*)))*$", $grplstattr)) {
echo ("<font color=\"red\"><b>" . _("Group list attributes are invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$hstlstattr || !eregi("^((#[a-z]*)|([a-z]*:[a-z*]))(;((#[a-z]*)|([a-z]*:[a-z]*)))*$", $hstlstattr)) {
echo ("<font color=\"red\"><b>" . _("Host list attributes are invalidUser list attributes are invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$maxlistentries || !is_numeric($maxlistentries)) {
echo ("<font color=\"red\"><b>" . _("Max list entries is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
@ -165,8 +177,20 @@ if (!$samba3) {
exit;
}
if (($samba3 == "yes") && (!$domainSID)) {
echo ("<font color=\"red\"><b>" . _("Samba 3 needs a domain SID!") . "</b></font>");
if (($samba3 == "yes") && !eregi("^S-[0-9]-[0-9]-[0-9]{2,2}-[0-9]*-[0-9]*-[0-9]*$", $domainSID)) {
echo ("<font color=\"red\"><b>" . _("Samba 3 domain SID is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if ($scriptpath && !eregi("^/[a-z0-9_\\-]+(/[a-z0-9_\\-]+)+$", $scriptpath)) {
echo ("<font color=\"red\"><b>" . _("Script path is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if ($scriptserver && !is_string($scriptserver)) {
echo ("<font color=\"red\"><b>" . _("Script server is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
@ -177,6 +201,8 @@ $conf->set_Adminstring($admins);
$conf->set_UserSuffix($suffusers);
$conf->set_GroupSuffix($suffgroups);
$conf->set_HostSuffix($suffhosts);
$conf->set_DomainSuffix($suffdomains);
$conf->set_MapSuffix($suffmap);
$conf->set_minUID($minUID);
$conf->set_maxUID($maxUID);
$conf->set_minGID($minGID);
@ -190,11 +216,8 @@ $conf->set_MaxListEntries($maxlistentries);
$conf->set_defaultLanguage($lang);
$conf->set_samba3($samba3);
$conf->set_domainSID($domainSID);
// optional
if ($_SESSION['scriptpath']) $conf->set_scriptpath($scriptpath);
else $conf->set_scriptpath("");
if ($_SESSION['scriptserver']) $conf->set_scriptserver($scriptserver);
else $conf->set_scriptserver("");
$conf->set_scriptpath($scriptpath);
$conf->set_scriptserver($scriptserver);
@ -225,6 +248,8 @@ session_unregister('admins');
session_unregister('suffusers');
session_unregister('suffgroups');
session_unregister('suffhosts');
session_unregister('suffdomains');
session_unregister('suffmap');
session_unregister('minUID');
session_unregister('maxUID');
session_unregister('minGID');