moved min/maxGID to module settings

This commit is contained in:
Roland Gruber 2004-07-26 15:15:30 +00:00
parent a90e481a59
commit 8c6b75e5a5
9 changed files with 48 additions and 97 deletions

View File

@ -153,8 +153,7 @@ $helpArray = array (
"407" => array ("ext" => "FALSE", "Headline" => _("Groupname"),
"Text" => _("Group name of the group which should be created. Valid characters are: a-z,0-9, .-_. Lam does not allow a number as first character because groupadd also does not allow it. Lam does not allow capital letters A-Z because it can cause several problems. If groupname is already used groupname will be expanded with a number. The next free number will be used.")),
"408" => array ("ext" => "FALSE", "Headline" => _("GID number"),
"Text" => _("If empty GID number will be generated automaticly. Valid values are between %s and %s."),
"variables" => array($_SESSION['config']->get_minGID(), $_SESSION['config']->get_maxGID())),
"Text" => _("If empty GID number will be generated automaticly depending on your configuration settings.")),
"409" => array ("ext" => "FALSE", "Headline" => _("Gecos"),
"Text" => _("Group description. If left empty group name will be used.")),
"410" => array ("ext" => "FALSE", "Headline" => _("Host name"),

View File

@ -45,6 +45,9 @@ class baseModule {
/** the account type of this module (user, group, host) */
var $scope;
/** configuration settings of all modules */
var $moduleSettings;
/**
* Creates a new base module class
*
@ -53,6 +56,7 @@ class baseModule {
function baseModule($scope) {
$this->scope = $scope;
$this->meta = $this->get_metaData();
if (isset($_SESSION['config'])) $this->moduleSettings = $_SESSION['config']->get_moduleSettings();
}
/**

View File

@ -123,10 +123,6 @@ class Config {
var $MinUID;
/** Maximum UID number for users */
var $MaxUID;
/** Minimum GID number for groups */
var $MinGID;
/** Maximum GID number for groups */
var $MaxGID;
/** Minimum UID number for Samba hosts */
var $MinMachine;
/** Maximum UID number for Samba hosts */
@ -183,7 +179,7 @@ class Config {
/** List of all settings in config file */
var $settings = array("ServerURL", "Passwd", "Admins", "usersuffix", "groupsuffix", "hostsuffix",
"domainsuffix", "MinUID", "MaxUID", "MinGID", "MaxGID", "MinMachine", "MaxMachine",
"domainsuffix", "MinUID", "MaxUID", "MinMachine", "MaxMachine",
"userlistAttributes", "grouplistAttributes", "hostlistAttributes", "maxlistentries",
"defaultLanguage", "scriptPath", "scriptServer", "cachetimeout", "pwdhash",
"usermodules", "groupmodules", "hostmodules", "modules");
@ -269,6 +265,7 @@ class Config {
$option = substr($line, $keylen + 2, strlen($line) - $keylen - 2);
$pos = strpos($option, ":");
$name = substr($option, 0, $pos);
if (!isset($this->moduleSettings[$name])) continue;
$file_array[$i] = "modules: " . $name . ": " . implode("+::+", $this->moduleSettings[$name]) . "\n";
$mod_saved[] = $name; // mark keyword as saved
}
@ -297,8 +294,6 @@ class Config {
"# e.g. ou=domains,dc=yourdomain,dc=org\n" . "domainsuffix: " . $this->domainsuffix . "\n");
if (!in_array("MinUID", $saved)) array_push($file_array, "\n\n# minimum UID number\n" . "minUID: " . $this->MinUID . "\n");
if (!in_array("MaxUID", $saved)) array_push($file_array, "\n\n# maximum UID number\n" . "maxUID: " . $this->MaxUID . "\n");
if (!in_array("MinGID", $saved)) array_push($file_array, "\n\n# minimum GID number\n" . "minGID: " . $this->MinGID . "\n");
if (!in_array("MaxGID", $saved)) array_push($file_array, "\n\n# maximum GID number\n" . "maxGID: " . $this->MaxGID . "\n");
if (!in_array("MinMachine", $saved)) array_push($file_array, "\n\n# minimum UID number for Samba hosts\n" . "minMachine: " . $this->MinMachine . "\n");
if (!in_array("MaxMachine", $saved)) array_push($file_array, "\n\n# maximum UID number for Samba hosts\n" . "maxMachine: " . $this->MaxMachine . "\n");
if (!in_array("userlistAttributes", $saved)) array_push($file_array, "\n\n# list of attributes to show in user list\n# entries can either be predefined values (e.g. '#cn' or '#uid')" .
@ -347,8 +342,6 @@ class Config {
echo "<b>" . _("DomainSuffix") . ": </b>" . $this->domainsuffix . "<br>\n";
echo "<b>" . _("Minimum UID number") . ": </b>" . $this->MinUID . "<br>\n";
echo "<b>" . _("Maximum UID number") . ": </b>" . $this->MaxUID . "<br>\n";
echo "<b>" . _("Minimum GID number") . ": </b>" . $this->MinGID . "<br>\n";
echo "<b>" . _("Maximum GID number") . ": </b>" . $this->MaxGID . "<br>\n";
echo "<b>" . _("Minimum Machine number") . ": </b>" . $this->MinMachine . "<br>\n";
echo "<b>" . _("Maximum Machine number") . ": </b>" . $this->MaxMachine . "<br>\n";
echo "<b>" . _("Attributes in User List") . ": </b>" . $this->userlistAttributes . "<br>\n";
@ -590,48 +583,6 @@ class Config {
return true;
}
/**
* Returns the minimum GID to use when creating new groups
*
* @return the minimum GID number
*/
function get_minGID() {
return $this->MinGID;
}
/**
* Sets the minimum GID to use when creating new groups
*
* @param $value new minimum GID number
* @return true if $value has correct format
*/
function set_minGID($value) {
if (is_numeric($value)) $this->MinGID = $value;
else return false;
return true;
}
/**
* Returns the maximum GID to use when creating new groups
*
* @return the maximum GID number
*/
function get_maxGID() {
return $this->MaxGID;
}
/**
* Sets the maximum GID to use when creating new groups
*
* @param $value new maximum GID number
* @return true if $value has correct format
*/
function set_maxGID($value) {
if (is_numeric($value)) $this->MaxGID = $value;
else return false;
return true;
}
/**
* Returns the minimum UID to use when creating new Samba hosts
*

View File

@ -54,6 +54,18 @@ $Id$
*/
class posixGroup extends baseModule {
/**
* Creates a new posixGroup object.
*/
function posixGroup($scope) {
// error messages for input checks
$this->messages['minGID'] = array('ERROR', _('Minimum GID number'), _('Minimum GID number is invalid or empty!'));
$this->messages['maxGID'] = array('ERROR', _('Maximum GID number'), _('Maximum GID number is invalid or empty!'));
$this->messages['cmpGID'] = array('ERROR', _('Maximum GID number'), _('Maximum GID number must be greater than minimum GID number!'));
// call parent constructor
parent::baseModule($scope);
}
/**
* Returns meta data that is interpreted by parent class
*
@ -73,6 +85,31 @@ class posixGroup extends baseModule {
$return["alias"] = _('Unix');
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array('inetOrgPerson', 'account', 'sambaDomain'));
// configuration options
$return['config_options']['group'] = array(
array(
0 => array('kind' => 'text', 'text' => '<b>' . _('Minimum GID number') . " *: </b>"),
1 => array('kind' => 'input', 'name' => 'posixGroup_minGID', 'type' => 'text', 'size' => '10', 'maxlength' => '255'),
2 => array('kind' => 'text', 'value' => '&nbsp;'),
3 => array('kind' => 'text', 'text' => '<b>' . _('Maximum GID number') . " *: </b>"),
4 => array('kind' => 'input', 'name' => 'posixGroup_maxGID', 'type' => 'text', 'size' => '10', 'maxlength' => '255'),
5 => array('kind' => 'help', 'value' => 'TODO'))
);
// configuration descriptions
$return['config_descriptions'] = array(
'legend' => _("GID ranges for Unix groups"),
'descriptions' => array(
'posixGroup_minGID' => "Minimum GID number for Unix groups",
'posixGroup_maxGID' => "Maximum GID number for Unix groups",
)
);
// configuration checks
$return['config_checks']['group']['posixGroup_minGID'] = array('type' => 'regex', 'regex' => '^[0-9]+$',
'required' => true, 'required_message' => $this->messages['minGID'], 'error_message' => $this->messages['minGID']);
$return['config_checks']['group']['posixGroup_maxGID'] = array('type' => 'regex', 'regex' => '^[0-9]+$',
'required' => true, 'required_message' => $this->messages['maxGID'], 'error_message' => $this->messages['maxGID']);
$return['config_checks']['group']['cmpGID'] = array('type' => 'int_greater', 'cmp_name1' => 'posixGroup_maxGID',
'cmp_name2' => 'posixGroup_minGID', 'error_message' => $this->messages['cmpGID']);
return $return;
}
@ -357,8 +394,8 @@ class posixGroup extends baseModule {
// Check if UID is valid. If none value was entered, the next useable value will be inserted
// load min and may uidNumber
$minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minGID());
$maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxGID());
$minID = intval($this->moduleSettings['posixGroup_minGID'][0]);
$maxID = intval($this->moduleSettings['posixGroup_maxGID'][0]);
$dn_gids = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('gidNumber', 'posixGroup', '*');
// get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
foreach ($dn_gids as $gid) $gids[] = $gid[0];

View File

@ -68,8 +68,6 @@ convsave, confmain, conflogin:
- conf_suffdomains: Eingabe von confmain
- conf_minUID: Eingabe von confmain
- conf_maxUID: Eingabe von confmain
- conf_minGID: Eingabe von confmain
- conf_maxGID: Eingabe von confmain
- conf_minMach: Eingabe von confmain
- conf_maxMach: Eingabe von confmain
- conf_usrlstattr: Eingabe von confmain

View File

@ -52,8 +52,6 @@ unset($_SESSION['conf_suffgroups']);
unset($_SESSION['conf_suffhosts']);
unset($_SESSION['conf_minUID']);
unset($_SESSION['conf_maxUID']);
unset($_SESSION['conf_minGID']);
unset($_SESSION['conf_maxGID']);
unset($_SESSION['conf_minMach']);
unset($_SESSION['conf_maxMach']);
unset($_SESSION['conf_usrlstattr']);

View File

@ -59,8 +59,6 @@ if ($_POST['back'] || $_POST['submitconf'] || $_POST['editmodules']){
$_SESSION['conf_suffdomains'] = $_POST['suffdomains'];
$_SESSION['conf_minUID'] = $_POST['minUID'];
$_SESSION['conf_maxUID'] = $_POST['maxUID'];
$_SESSION['conf_minGID'] = $_POST['minGID'];
$_SESSION['conf_maxGID'] = $_POST['maxGID'];
$_SESSION['conf_minMach'] = $_POST['minMach'];
$_SESSION['conf_maxMach'] = $_POST['maxMach'];
$_SESSION['conf_usrlstattr'] = $_POST['usrlstattr'];
@ -131,8 +129,6 @@ if ($_GET["modulesback"] == "true") {
$conf->set_DomainSuffix($_SESSION['conf_suffdomains']);
$conf->set_minUID($_SESSION['conf_minUID']);
$conf->set_maxUID($_SESSION['conf_maxUID']);
$conf->set_minGID($_SESSION['conf_minGID']);
$conf->set_maxGID($_SESSION['conf_maxGID']);
$conf->set_minMachine($_SESSION['conf_minMach']);
$conf->set_maxMachine($_SESSION['conf_maxMach']);
$conf->set_userlistAttributes($_SESSION['conf_usrlstattr']);
@ -314,16 +310,6 @@ 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>".
"<input size=6 type=\"text\" name=\"minGID\" value=\"" . $conf->get_minGID() . "\"></td>\n");
echo "<td>&nbsp;&nbsp;&nbsp;</td>\n";
// maxGID
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>".

View File

@ -54,8 +54,6 @@ $suffhosts = $_SESSION['conf_suffhosts'];
$suffdomains = $_SESSION['conf_suffdomains'];
$minUID = $_SESSION['conf_minUID'];
$maxUID = $_SESSION['conf_maxUID'];
$minGID = $_SESSION['conf_minGID'];
$maxGID = $_SESSION['conf_maxGID'];
$minMach = $_SESSION['conf_minMach'];
$maxMach = $_SESSION['conf_maxMach'];
$usrlstattr = $_SESSION['conf_usrlstattr'];
@ -131,16 +129,6 @@ if (!$conf->set_maxUID($maxUID)) {
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_minGID($minGID)) {
echo ("<font color=\"red\"><b>" . _("Minimum GID number is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_maxGID($maxGID)) {
echo ("<font color=\"red\"><b>" . _("Maximum GID number is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_minMachine($minMach)) {
echo ("<font color=\"red\"><b>" . _("Minimum Machine number is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
@ -297,8 +285,6 @@ unset($_SESSION['conf_suffhosts']);
unset($_SESSION['conf_suffdomains']);
unset($_SESSION['conf_minUID']);
unset($_SESSION['conf_maxUID']);
unset($_SESSION['conf_minGID']);
unset($_SESSION['conf_maxGID']);
unset($_SESSION['conf_minMach']);
unset($_SESSION['conf_maxMach']);
unset($_SESSION['conf_usrlstattr']);

View File

@ -41,8 +41,6 @@ $Suff_hosts = $conf->get_HostSuffix();
$Suff_domains = $conf->get_DomainSuffix();
$MinUID = $conf->get_minUID();
$MaxUID = $conf->get_maxUID();
$MinGID = $conf->get_minGID();
$MaxGID = $conf->get_maxGID();
$MinMachine = $conf->get_minMachine();
$MaxMachine = $conf->get_maxMachine();
$userlistAttributes = $conf->get_userlistAttributes();
@ -67,8 +65,6 @@ $conf->set_HostSuffix("ou=testhst,o=test,c=de");
$conf->set_DomainSuffix("ou=testdom,o=test,c=de");
$conf->set_minUID("25");
$conf->set_maxUID("254");
$conf->set_minGID("253");
$conf->set_maxGID("1234");
$conf->set_minMachine("3");
$conf->set_maxMachine("47");
$conf->set_userlistAttributes("#uid;#cn");
@ -79,7 +75,7 @@ $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_pwdhash("SMD5");
$conf->set_moduleSettings(array("test1" => 11, "test2" => "abc", 'test3' => 3));
$conf->set_moduleSettings(array("test1" => array(11), "test2" => array("abc"), 'test3' => array(3)));
$conf->save();
echo ("done<br>");
// at last all preferences are read from lam.conf and compared
@ -95,8 +91,6 @@ if ($conf2->get_HostSuffix() != "ou=testhst,o=test,c=de") echo ("<br><font color
if ($conf2->get_DomainSuffix() != "ou=testdom,o=test,c=de") echo ("<br><font color=\"#FF0000\">Saving domain suffix failed!</font><br>");
if ($conf2->get_minUID() != "25") echo ("<br><font color=\"#FF0000\">Saving minUID failed!</font><br>");
if ($conf2->get_maxUID() != "254") echo ("<br><font color=\"#FF0000\">Saving maxUID failed!</font><br>");
if ($conf2->get_minGID() != "253") echo ("<br><font color=\"#FF0000\">Saving minGID failed!</font><br>");
if ($conf2->get_maxGID() != "1234") echo ("<br><font color=\"#FF0000\">Saving maxGID failed!</font><br>");
if ($conf2->get_minMachine() != "3") echo ("<br><font color=\"#FF0000\">Saving maxMachine failed!</font><br>");
if ($conf2->get_maxMachine() != "47") echo ("<br><font color=\"#FF0000\">Saving minMachine failed!</font><br>");
if ($conf2->get_userlistAttributes() != "#uid;#cn") echo ("<br><font color=\"#FF0000\">Saving userlistAttributes failed!</font><br>");
@ -108,7 +102,7 @@ if ($conf2->get_scriptPath() != "/var/www/lam/lib/script") echo ("<br><font colo
if ($conf2->get_scriptServer() != "127.0.0.1") echo ("<br><font color=\"#FF0000\">Saving script server failed!</font><br>");
if ($conf2->get_pwdhash() != "SMD5") echo ("<br><font color=\"#FF0000\">Saving pwdhash failed!</font><br>");
$msettings = $conf2->get_moduleSettings();
if (($msettings['test1'] != 11) || ($msettings['test2'] != 'abc') || ($msettings['test3'] != '3')) echo ("<br><font color=\"#FF0000\">Saving module settings failed!</font><br>");
if (($msettings['test1'][0] != 11) || ($msettings['test2'][0] != 'abc') || ($msettings['test3'][0] != '3')) echo ("<br><font color=\"#FF0000\">Saving module settings failed!</font><br>");
echo ("done<br>");
// restore old values
echo ("Restoring old preferences...");
@ -122,8 +116,6 @@ $conf2->set_HostSuffix($Suff_hosts);
$conf2->set_DomainSuffix($Suff_domains);
$conf2->set_minUID($MinUID);
$conf2->set_maxUID($MaxUID);
$conf2->set_minGID($MinGID);
$conf2->set_maxGID($MaxGID);
$conf2->set_minMachine($MinMachine);
$conf2->set_maxMachine($MaxMachine);
$conf2->set_userlistAttributes($userlistAttributes);