diff --git a/lam/config/lam.conf_sample b/lam/config/lam.conf_sample
index 2811e7b4..9b56289d 100644
--- a/lam/config/lam.conf_sample
+++ b/lam/config/lam.conf_sample
@@ -27,18 +27,6 @@ hostsuffix: ou=machines,dc=my-domain,dc=com
# e.g. ou=domains,dc=yourdomain,dc=org
domainsuffix: ou=domains,dc=my-domain,dc=com
-# minimum and maximum UID numbers
-minUID: 10000
-maxUID: 20000
-
-# minimum and maximum GID numbers
-minGID: 10000
-maxGID: 20000
-
-# minimum and maximum UID numbers for Samba Hosts
-minMachine: 25000
-maxMachine: 35000
-
# list of attributes to show in user list
# entries can either be predefined values (e.g. '#cn' or '#uid')
# or individual ones (e.g. 'uid:User ID' or 'host:Host Name')
@@ -75,3 +63,12 @@ cachetimeout: 5
# Password hash algorithm (CRYPT/MD5/SMD5/SHA/SSHA/PLAIN).
pwdhash: SSHA
+# Module settings
+
+modules: posixAccount_minUID: 10000
+modules: posixAccount_maxUID: 30000
+modules: posixAccount_minMachine: 50000
+modules: posixAccount_maxMachine: 60000
+modules: posixGroup_minGID: 10000
+modules: posixGroup_maxGID: 20000
+
diff --git a/lam/help/help.inc b/lam/help/help.inc
index cca557da..2dadc442 100644
--- a/lam/help/help.inc
+++ b/lam/help/help.inc
@@ -138,8 +138,7 @@ $helpArray = array (
"400" => array ("ext" => "FALSE", "Headline" => _("Username"),
"Text" => _("Username of the user who should be created. Valid characters are: a-z,0-9, .-_. Lam does not allow a number as first character because useradd also does not allow it. Lam does not allow capital letters A-Z because it can cause several problems. If username is already used username will be expanded with a number. The next free number will be used. Warning: Older systems have problems with usernames longer than 8 characters. You can not log in to Windows if username is longer than 16 characters.")),
"401" => array ("ext" => "FALSE", "Headline" => _("UID number"),
- "Text" => _("If empty UID number will be generated automaticly. Valid values are between %s and %s."),
- "variables" => array($_SESSION['config']->get_minUID(), $_SESSION['config']->get_maxUID())),
+ "Text" => _("If empty UID number will be generated automaticly.")),
"402" => array ("ext" => "FALSE", "Headline" => _("Additional groups"),
"Text" => _("Hold the CTRL-key to (de)select multiple groups."). ' '. _("Can be left empty.")),
"403" => array ("ext" => "FALSE", "Headline" => _("Home directory"),
@@ -159,8 +158,7 @@ $helpArray = array (
"410" => array ("ext" => "FALSE", "Headline" => _("Host name"),
"Text" => _("Host name of the host which should be created. Valid characters are: a-z,0-9, .-_$. Lam does not allow a number as first character because useradd also does not allow it. Lam does not allow capital letters A-Z because it can cause several problems. Hostnames are always ending with $. If last character is not $ it will be added. If hostname is already used hostname will be expanded with a number. The next free number will be used.")),
"411" => array ("ext" => "FALSE", "Headline" => _("UID number"),
- "Text" => _("If empty UID number will be generated automaticly. Valid values are between %s and %s."),
- "variables" => array($_SESSION['config']->get_minMachine(), $_SESSION['config']->get_maxMachine())),
+ "Text" => _("If empty UID number will be generated automaticly.")),
"412" => array ("ext" => "FALSE", "Headline" => _("Primary group"),
"Text" => _("The Primary group the host should be member of.")),
"413" => array ("ext" => "FALSE", "Headline" => _("Gecos"),
diff --git a/lam/lib/config.inc b/lam/lib/config.inc
index 2dbf2b91..b085cc14 100644
--- a/lam/lib/config.inc
+++ b/lam/lib/config.inc
@@ -119,15 +119,6 @@ class Config {
/** LDAP suffix for Samba 3 domains */
var $domainsuffix;
- /** Minimum UID number for users */
- var $MinUID;
- /** Maximum UID number for users */
- var $MaxUID;
- /** Minimum UID number for Samba hosts */
- var $MinMachine;
- /** Maximum UID number for Samba hosts */
- var $MaxMachine;
-
/** Attributes that are shown in the user list */
var $userlistAttributes;
/** Attributes that are shown in the group list */
@@ -179,8 +170,7 @@ class Config {
/** List of all settings in config file */
var $settings = array("ServerURL", "Passwd", "Admins", "usersuffix", "groupsuffix", "hostsuffix",
- "domainsuffix", "MinUID", "MaxUID", "MinMachine", "MaxMachine",
- "userlistAttributes", "grouplistAttributes", "hostlistAttributes", "maxlistentries",
+ "domainsuffix", "userlistAttributes", "grouplistAttributes", "hostlistAttributes", "maxlistentries",
"defaultLanguage", "scriptPath", "scriptServer", "cachetimeout", "pwdhash",
"usermodules", "groupmodules", "hostmodules", "modules");
@@ -292,10 +282,6 @@ class Config {
"# e.g. ou=machines,dc=yourdomain,dc=org\n" . "hostsuffix: " . $this->hostsuffix . "\n");
if (!in_array("domainsuffix", $saved)) array_push($file_array, "\n\n# suffix of Samba 3 domains\n" .
"# 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("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')" .
"\n# or individual ones (e.g. 'uid:User ID' or 'host:Host Name')\n# values have to be seperated by semicolons\n" . "userlistAttributes: " . $this->userlistAttributes . "\n");
if (!in_array("grouplistAttributes", $saved)) array_push($file_array, "\n\n# list of attributes to show in group list\n# entries can either be predefined values (e.g. '#cn' or '#gidNumber')" .
@@ -340,10 +326,6 @@ class Config {
echo "" . _("GroupSuffix") . ": " . $this->groupsuffix . "
\n";
echo "" . _("HostSuffix") . ": " . $this->hostsuffix . "
\n";
echo "" . _("DomainSuffix") . ": " . $this->domainsuffix . "
\n";
- echo "" . _("Minimum UID number") . ": " . $this->MinUID . "
\n";
- echo "" . _("Maximum UID number") . ": " . $this->MaxUID . "
\n";
- echo "" . _("Minimum Machine number") . ": " . $this->MinMachine . "
\n";
- echo "" . _("Maximum Machine number") . ": " . $this->MaxMachine . "
\n";
echo "" . _("Attributes in User List") . ": " . $this->userlistAttributes . "
\n";
echo "" . _("Attributes in Group List") . ": " . $this->grouplistAttributes . "
\n";
echo "" . _("Attributes in Host List") . ": " . $this->hostlistAttributes . "
\n";
@@ -541,92 +523,6 @@ class Config {
return true;
}
- /**
- * Returns the minimum UID to use when creating new users
- *
- * @return the minimum UID number
- */
- function get_minUID() {
- return $this->MinUID;
- }
-
- /**
- * Sets the minimum UID to use when creating new users
- *
- * @param $value new minimum UID number
- * @return true if $value has correct format
- */
- function set_minUID($value) {
- if (is_numeric($value)) $this->MinUID = $value;
- else return false;
- return true;
- }
-
- /**
- * Returns the maximum UID to use when creating new users
- *
- * @return the maximum UID number
- */
- function get_maxUID() {
- return $this->MaxUID;
- }
-
- /**
- * Sets the maximum UID to use when creating new users
- *
- * @param $value new maximum UID number
- * @return true if $value has correct format
- */
- function set_maxUID($value) {
- if (is_numeric($value)) $this->MaxUID = $value;
- else return false;
- return true;
- }
-
- /**
- * Returns the minimum UID to use when creating new Samba hosts
- *
- * @return the minimum UID number
- */
- function get_minMachine() {
- return $this->MinMachine;
- }
-
- /**
- * Sets the minimum UID to use when creating new Samba hosts
- *
- * @param $value new minimum UID number
- * @return true if $value has correct format
- */
- function set_minMachine($value) {
- if (! $value && ($this->hostsuffix == "")) $this->MinMachine = "";
- elseif (is_numeric($value)) $this->MinMachine = $value;
- else return false;
- return true;
- }
-
- /**
- * Returns the maximum UID to use when creating new Samba hosts
- *
- * @return the maximum UID number
- */
- function get_maxMachine() {
- return $this->MaxMachine;
- }
-
- /**
- * Sets the maximum UID to use when creating new Samba hosts
- *
- * @param $value new maximum UID number
- * @return true if $value has correct format
- */
- function set_maxMachine($value) {
- if (! $value && ($this->hostsuffix == "")) $this->MaxMachine = "";
- elseif (is_numeric($value)) $this->MaxMachine = $value;
- else return false;
- return true;
- }
-
/**
* Returns the list of attributes to show in user list
*
diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc
index 1f0e2b72..33716a63 100644
--- a/lam/lib/modules/posixAccount.inc
+++ b/lam/lib/modules/posixAccount.inc
@@ -60,6 +60,13 @@ class posixAccount extends baseModule {
function posixAccount($scope) {
// error messages for input checks
$this->messages['homedir'] = array('ERROR', _('Home directory'), _('Homedirectory contains invalid characters.'));
+ $this->messages['minUID'] = array('ERROR', _('Users') . ': ' . _('Minimum UID number'), _("Minimum UID number is invalid!"));
+ $this->messages['maxUID'] = array('ERROR', _('Users') . ': ' . _('Maximum UID number'), _("Maximum UID number is invalid!"));
+ $this->messages['minMachine'] = array('ERROR', _('Hosts') . ': ' . _('Minimum UID number'), _("Minimum UID number is invalid!"));
+ $this->messages['maxMachine'] = array('ERROR', _('Hosts') . ': ' . _('Maximum UID number'), _("Maximum UID number is invalid!"));
+ $this->messages['cmp_UID'] = array('ERROR', _('Users') . ': ' . _('Maximum UID number'), _("Maximum UID number must be greater than minimum UID number!"));
+ $this->messages['cmp_Machine'] = array('ERROR', _('Hosts') . ': ' . _('Maximum UID number'), _("Maximum UID number must be greater than minimum UID number!"));
+ $this->messages['cmp_both'] = array('ERROR', _('UID ranges'), _("The UID ranges for users and hosts overlap! This is a problem because LAM uses the highest UID in use + 1. Please set the minimum UID to equal values or use independent ranges."));
// call parent constructor
parent::baseModule($scope);
}
@@ -91,6 +98,35 @@ class posixAccount extends baseModule {
// profile checks
$return['profile_checks']['posixAccount_homeDirectory'] = array('type' => 'regex_i', 'regex' => $this->regex_homedir,
'error_message' => $this->messages['homedir']);
+ // configuration options
+ $return['config_options']['user'] = array(
+ array(
+ 0 => array('kind' => 'text', 'text' => '' . _("Users") . ': ' . _('Minimum UID number') . ": "),
+ 1 => array('kind' => 'input', 'name' => 'posixAccount_minUID', 'type' => 'text', 'size' => '10', 'maxlength' => '255'),
+ 2 => array('kind' => 'text', 'value' => ' '),
+ 3 => array('kind' => 'text', 'text' => _('Maximum UID number') . ": "),
+ 4 => array('kind' => 'input', 'name' => 'posixAccount_maxUID', 'type' => 'text', 'size' => '10', 'maxlength' => '255'),
+ 5 => array('kind' => 'help', 'value' => 'TODO'))
+ );
+ $return['config_options']['host'] = array(
+ array(
+ 0 => array('kind' => 'text', 'text' => '' . _("Hosts") . ': ' . _('Minimum UID number') . ": "),
+ 1 => array('kind' => 'input', 'name' => 'posixAccount_minMachine', 'type' => 'text', 'size' => '10', 'maxlength' => '255'),
+ 2 => array('kind' => 'text', 'value' => ' '),
+ 3 => array('kind' => 'text', 'text' => _('Maximum UID number') . ": "),
+ 4 => array('kind' => 'input', 'name' => 'posixAccount_maxMachine', 'type' => 'text', 'size' => '10', 'maxlength' => '255'),
+ 5 => array('kind' => 'help', 'value' => 'TODO'))
+ );
+ // configuration descriptions
+ $return['config_descriptions'] = array(
+ 'legend' => _("UID ranges for Unix accounts"),
+ 'descriptions' => array(
+ 'posixAccount_minUID' => _("Minimum UID number for Unix accounts (users)"),
+ 'posixAccount_maxUID' => _("Maximum UID number for Unix accounts (users)"),
+ 'posixAccount_minMachine' => _("Minimum UID number for Unix accounts (hosts)"),
+ 'posixAccount_maxMachine' => _("Maximum UID number for Unix accounts (hosts)"),
+ )
+ );
return $return;
}
@@ -418,12 +454,12 @@ class posixAccount extends baseModule {
// Check if UID is valid. If none value was entered, the next useable value will be inserted
// load min and may uidNumber
if ($_SESSION[$this->base]->type=='user') {
- $minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minUID());
- $maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxUID());
+ $minID = intval($this->moduleSettings['posixAccount_minUID'][0]);
+ $maxID = intval($this->moduleSettings['posixAccount_maxUID'][0]);
}
if ($_SESSION[$this->base]->type=='host') {
- $minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minMachine());
- $maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxMachine());
+ $minID = intval($this->moduleSettings['posixAccount_minMachine'][0]);
+ $maxID = intval($this->moduleSettings['posixAccount_maxMachine'][0]);
}
$dn_uids = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uidNumber', 'posixAccount', '*');
// get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
@@ -747,6 +783,64 @@ class posixAccount extends baseModule {
);
}
+ /**
+ * Checks input values of module settings.
+ *
+ * @param array $scopes list of account types which are used
+ * @param array $options hash array containing the settings (array('option' => array('value')))
+ * @return array list of error messages
+ */
+ function check_configOptions($scopes, $options) {
+ $return = array();
+ // user settings
+ if (in_array('user', $scopes)) {
+ // min/maxUID are required, check if they are numeric
+ if (!isset($options['posixAccount_minUID'][0]) || !ereg('^[0-9]+$', $options['posixAccount_minUID'][0])) {
+ $return[] = $this->messages['minUID'];
+ }
+ if (!isset($options['posixAccount_maxUID'][0]) || !ereg('^[0-9]+$', $options['posixAccount_maxUID'][0])) {
+ $return[] = $this->messages['maxUID'];
+ }
+ // minUID < maxUID
+ if (isset($options['posixAccount_minUID'][0]) && isset($options['posixAccount_maxUID'][0])) {
+ if ($options['posixAccount_minUID'][0] > $options['posixAccount_maxUID'][0]) {
+ $return[] = $this->messages['cmp_UID'];
+ }
+ }
+ }
+ // host settings
+ if (in_array('host', $scopes)) {
+ // min/maxUID are required, check if they are numeric
+ if (!isset($options['posixAccount_minMachine'][0]) || !ereg('^[0-9]+$', $options['posixAccount_minMachine'][0])) {
+ $return[] = $this->messages['minMachine'];
+ }
+ if (!isset($options['posixAccount_maxMachine'][0]) || !ereg('^[0-9]+$', $options['posixAccount_maxMachine'][0])) {
+ $return[] = $this->messages['maxMachine'];
+ }
+ // minUID < maxUID
+ if (isset($options['posixAccount_minMachine'][0]) && isset($options['posixAccount_maxMachine'][0])) {
+ if ($options['posixAccount_minMachine'][0] > $options['posixAccount_maxMachine'][0]) {
+ $return[] = $this->messages['cmp_Machine'];
+ }
+ }
+ }
+ // check if user and host ranges overlap
+ if (in_array('user', $scopes) && in_array('host', $scopes)) {
+ if (isset($options['posixAccount_minUID'][0]) && isset($options['posixAccount_maxUID'][0]) &&
+ isset($options['posixAccount_minMachine'][0]) && isset($options['posixAccount_maxMachine'][0])) {
+ if (($options['posixAccount_minMachine'][0] > $options['posixAccount_minUID'][0]) &&
+ ($options['posixAccount_minMachine'][0] < $options['posixAccount_maxUID'][0])) {
+ $return[] = $this->messages['cmp_both'];
+ }
+ if (($options['posixAccount_minUID'][0] > $options['posixAccount_minMachine'][0]) &&
+ ($options['posixAccount_minUID'][0] < $options['posixAccount_maxMachine'][0])) {
+ $return[] = $this->messages['cmp_both'];
+ }
+ }
+ }
+ return $return;
+ }
+
}
?>
diff --git a/lam/session-vars.txt b/lam/session-vars.txt
index 83afa43e..9d005fd1 100644
--- a/lam/session-vars.txt
+++ b/lam/session-vars.txt
@@ -66,10 +66,6 @@ convsave, confmain, conflogin:
- conf_suffgroups: Eingabe von confmain
- conf_suffhosts: Eingabe von confmain
- conf_suffdomains: Eingabe von confmain
-- conf_minUID: Eingabe von confmain
-- conf_maxUID: Eingabe von confmain
-- conf_minMach: Eingabe von confmain
-- conf_maxMach: Eingabe von confmain
- conf_usrlstattr: Eingabe von confmain
- conf_grplstattr: Eingabe von confmain
- conf_hstlstattr: Eingabe von confmain
diff --git a/lam/templates/config/conflogin.php b/lam/templates/config/conflogin.php
index 0fb58a22..8001cedc 100644
--- a/lam/templates/config/conflogin.php
+++ b/lam/templates/config/conflogin.php
@@ -50,10 +50,6 @@ unset($_SESSION['conf_admins']);
unset($_SESSION['conf_suffusers']);
unset($_SESSION['conf_suffgroups']);
unset($_SESSION['conf_suffhosts']);
-unset($_SESSION['conf_minUID']);
-unset($_SESSION['conf_maxUID']);
-unset($_SESSION['conf_minMach']);
-unset($_SESSION['conf_maxMach']);
unset($_SESSION['conf_usrlstattr']);
unset($_SESSION['conf_grplstattr']);
unset($_SESSION['conf_hstlstattr']);
diff --git a/lam/templates/config/confmain.php b/lam/templates/config/confmain.php
index 001f47c9..a612810e 100644
--- a/lam/templates/config/confmain.php
+++ b/lam/templates/config/confmain.php
@@ -57,10 +57,6 @@ if ($_POST['back'] || $_POST['submitconf'] || $_POST['editmodules']){
$_SESSION['conf_suffgroups'] = $_POST['suffgroups'];
$_SESSION['conf_suffhosts'] = $_POST['suffhosts'];
$_SESSION['conf_suffdomains'] = $_POST['suffdomains'];
- $_SESSION['conf_minUID'] = $_POST['minUID'];
- $_SESSION['conf_maxUID'] = $_POST['maxUID'];
- $_SESSION['conf_minMach'] = $_POST['minMach'];
- $_SESSION['conf_maxMach'] = $_POST['maxMach'];
$_SESSION['conf_usrlstattr'] = $_POST['usrlstattr'];
$_SESSION['conf_grplstattr'] = $_POST['grplstattr'];
$_SESSION['conf_hstlstattr'] = $_POST['hstlstattr'];
@@ -127,10 +123,6 @@ if ($_GET["modulesback"] == "true") {
$conf->set_GroupSuffix($_SESSION['conf_suffgroups']);
$conf->set_HostSuffix($_SESSION['conf_suffhosts']);
$conf->set_DomainSuffix($_SESSION['conf_suffdomains']);
- $conf->set_minUID($_SESSION['conf_minUID']);
- $conf->set_maxUID($_SESSION['conf_maxUID']);
- $conf->set_minMachine($_SESSION['conf_minMach']);
- $conf->set_maxMachine($_SESSION['conf_maxMach']);
$conf->set_userlistAttributes($_SESSION['conf_usrlstattr']);
$conf->set_grouplistAttributes($_SESSION['conf_grplstattr']);
$conf->set_hostlistAttributes($_SESSION['conf_hstlstattr']);
@@ -297,34 +289,6 @@ for ($m = 0; $m < sizeof($modules); $m++) {
}
-echo ("