added some more preferences: minUID, maxUID, minGID, maxGID, minMachine,

maxMachine, default shell, shell list
This commit is contained in:
Roland Gruber 2003-03-13 14:40:19 +00:00
parent acf13732c5
commit 7c70d8460b
4 changed files with 289 additions and 42 deletions

View File

@ -46,14 +46,25 @@ class Config {
var $Adminstring;
// suffix for users
var $suff_users;
var $Suff_users;
// suffix for groups
var $suff_groups;
var $Suff_groups;
// suffix for Samba hosts
var $suff_hosts;
var $Suff_hosts;
// minimum/maximum numbers for UID, GID and UID of Samba Hosts
var $MinUID;
var $MaxUID;
var $MinGID;
var $MaxGID;
var $MinMachine;
var $MaxMachine;
// default shell and list of possible shells
var $DefaultShell;
var $ShellList;
// constructor, loads preferences from ../lam.conf
function Config() {
@ -91,22 +102,54 @@ class Config {
continue;
}
if (substr($line, 0, 12) == "usersuffix: ") {
$this->suff_users = chop(substr($line, 12, strlen($line)-12));
$this->Suff_users = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (substr($line, 0, 13) == "groupsuffix: ") {
$this->suff_groups = chop(substr($line, 13, strlen($line)-13));
$this->Suff_groups = chop(substr($line, 13, strlen($line)-13));
continue;
}
if (substr($line, 0, 12) == "hostsuffix: ") {
$this->suff_hosts = chop(substr($line, 12, strlen($line)-12));
$this->Suff_hosts = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (substr($line, 0, 8) == "minUID: ") {
$this->MinUID = chop(substr($line, 8, strlen($line)-8));
continue;
}
if (substr($line, 0, 8) == "maxUID: ") {
$this->MaxUID = chop(substr($line, 8, strlen($line)-8));
continue;
}
if (substr($line, 0, 8) == "minGID: ") {
$this->MinGID = chop(substr($line, 8, strlen($line)-8));
continue;
}
if (substr($line, 0, 8) == "maxGID: ") {
$this->MaxGID = chop(substr($line, 8, strlen($line)-8));
continue;
}
if (substr($line, 0, 12) == "minMachine: ") {
$this->MinMachine = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (substr($line, 0, 12) == "maxMachine: ") {
$this->MaxMachine = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (substr($line, 0, 14) == "defaultShell: ") {
$this->DefaultShell = chop(substr($line, 14, strlen($line)-14));
continue;
}
if (substr($line, 0, 11) == "shellList: ") {
$this->ShellList = chop(substr($line, 11, strlen($line)-11));
continue;
}
}
fclose($file);
}
else {
echo _("Unable to load lam.conf!"); echo "</br>";
echo _("Unable to load lam.conf!"); echo "<br>";
}
}
@ -114,7 +157,8 @@ class Config {
function save() {
$conffile = "../lam.conf";
if (is_file($conffile) == True) {
$save_ssl = $save_host = $save_port = $save_passwd = $save_admins = $save_suffusr = $save_suffgrp = $save_suffhst = False;
$save_ssl = $save_host = $save_port = $save_passwd = $save_admins = $save_suffusr = $save_suffgrp = $save_suffhst =
$save_minUID = $save_maxUID = $save_minGID = $save_maxGID = $save_minMach = $save_maxMach = $save_defShell = $save_shellList = False;
$file = fopen($conffile, "r");
$file_array = array();
while (!feof($file)) {
@ -149,35 +193,83 @@ class Config {
continue;
}
if (substr($file_array[$i], 0, 12) == "usersuffix: ") {
$file_array[$i] = "usersuffix: " . $this->suff_users . "\n";
$file_array[$i] = "usersuffix: " . $this->Suff_users . "\n";
$save_suffusr = True;
continue;
}
if (substr($file_array[$i], 0, 13) == "groupsuffix: ") {
$file_array[$i] = "groupsuffix: " . $this->suff_groups . "\n";
$file_array[$i] = "groupsuffix: " . $this->Suff_groups . "\n";
$save_suffgrp = True;
continue;
}
if (substr($file_array[$i], 0, 12) == "hostsuffix: ") {
$file_array[$i] = "hostsuffix: " . $this->suff_hosts . "\n";
$file_array[$i] = "hostsuffix: " . $this->Suff_hosts . "\n";
$save_suffhst = True;
continue;
}
if (substr($file_array[$i], 0, 8) == "minUID: ") {
$file_array[$i] = "minUID: " . $this->MinUID . "\n";
$save_minUID = True;
continue;
}
if (substr($file_array[$i], 0, 8) == "maxUID: ") {
$file_array[$i] = "maxUID: " . $this->MaxUID . "\n";
$save_maxUID = True;
continue;
}
if (substr($file_array[$i], 0, 8) == "minGID: ") {
$file_array[$i] = "minGID: " . $this->MinGID . "\n";
$save_minGID = True;
continue;
}
if (substr($file_array[$i], 0, 8) == "maxGID: ") {
$file_array[$i] = "maxGID: " . $this->MaxGID . "\n";
$save_maxGID = True;
continue;
}
if (substr($file_array[$i], 0, 12) == "minMachine: ") {
$file_array[$i] = "minMachine: " . $this->MinMachine . "\n";
$save_minMach = True;
continue;
}
if (substr($file_array[$i], 0, 12) == "maxMachine: ") {
$file_array[$i] = "maxMachine: " . $this->MaxMachine . "\n";
$save_maxMach = True;
continue;
}
if (substr($file_array[$i], 0, 14) == "defaultShell: ") {
$file_array[$i] = "defaultShell: " . $this->DefaultShell . "\n";
$save_defShell = True;
continue;
}
if (substr($file_array[$i], 0, 11) == "shellList: ") {
$file_array[$i] = "shellList: " . $this->ShellList . "\n";
$save_shellList = True;
continue;
}
}
// check if we have to add new entries (e.g. if user upgraded LAM)
if (!$save_ssl == True) array_push($file_array, "\n# use SSL to connect, can be True or False\n" . "ssl: " . $this->SSL);
if (!$save_host == True) array_push($file_array, "\n# hostname of LDAP server (e.g localhost)\n" . "host: " . $this->Host);
if (!$save_port == True) array_push($file_array, "\n# portnumber of LDAP server (default 389)\n" . "port: " . $this->Port);
if (!$save_passwd == True) array_push($file_array, "\n# password to change these preferences via webfrontend\n" . "passwd: " . $this->Passwd);
if (!$save_admins == True) array_push($file_array, "\n# list of users who are allowed to use LDAP Account Manager\n" .
if (!$save_ssl == True) array_push($file_array, "\n\n# use SSL to connect, can be True or False\n" . "ssl: " . $this->SSL);
if (!$save_host == True) array_push($file_array, "\n\n# hostname of LDAP server (e.g localhost)\n" . "host: " . $this->Host);
if (!$save_port == True) array_push($file_array, "\n\n# portnumber of LDAP server (default 389)\n" . "port: " . $this->Port);
if (!$save_passwd == True) array_push($file_array, "\n\n# password to change these preferences via webfrontend\n" . "passwd: " . $this->Passwd);
if (!$save_admins == True) array_push($file_array, "\n\n# list of users who are allowed to use LDAP Account Manager\n" .
"# names have to be seperated by semicolons\n" .
"# e.g. admins: cn=admin,dc=yourdomain,dc=org;cn=root,dc=yourdomain,dc=org\n" . "admins: " . $this->Admins);
if (!$save_suffusr == True) array_push($file_array, "\n# suffix of users\n" .
"# e.g. ou=People,dc=yourdomain,dc=org\n" . "usersuffix: " . $this->suff_users);
if (!$save_suffgrp == True) array_push($file_array, "\n# suffix of groups\n" .
"# e.g. ou=Groups,dc=yourdomain,dc=org\n" . "groupsuffix: " . $this->suff_groups);
if (!$save_suffhst == True) array_push($file_array, "\n# suffix of Samba hosts\n" .
"# e.g. ou=machines,dc=yourdomain,dc=org\n" . "hostsuffix: " . $this->suff_hosts);
if (!$save_suffusr == True) array_push($file_array, "\n\n# suffix of users\n" .
"# e.g. ou=People,dc=yourdomain,dc=org\n" . "usersuffix: " . $this->Suff_users);
if (!$save_suffgrp == True) array_push($file_array, "\n\n# suffix of groups\n" .
"# e.g. ou=Groups,dc=yourdomain,dc=org\n" . "groupsuffix: " . $this->Suff_groups);
if (!$save_suffhst == True) array_push($file_array, "\n\n# suffix of Samba hosts\n" .
"# e.g. ou=machines,dc=yourdomain,dc=org\n" . "hostsuffix: " . $this->Suff_hosts);
if (!$save_minUID == True) array_push($file_array, "\n\n# minimum UID number\n" . "minUID: " . $this->MinUID);
if (!$save_maxUID == True) array_push($file_array, "\n\n# maximum UID number\n" . "maxUID: " . $this->MaxUID);
if (!$save_minGID == True) array_push($file_array, "\n\n# minimum GID number\n" . "minGID: " . $this->MinGID);
if (!$save_maxGID == True) array_push($file_array, "\n\n# maximum GID number\n" . "maxGID: " . $this->MaxGID);
if (!$save_minMach == True) array_push($file_array, "\n\n# minimum UID number for Samba hosts\n" . "minMachine: " . $this->MinMachine);
if (!$save_maxMach == True) array_push($file_array, "\n\n# maximum UID number for Samba hosts\n" . "maxMachine: " . $this->MaxMachine);
if (!$save_defShell == True) array_push($file_array, "\n\n# default shell when creating new user\n" . "defaultShell: " . $this->DefaultShell);
if (!$save_shellList == True) array_push($file_array, "\n\n# list of possible shells\n" . "shellList: " . $this->ShellList);
$file = fopen($conffile, "w");
for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]);
fclose($file);
@ -186,13 +278,21 @@ class Config {
// prints current preferences
function printconf() {
echo _("<b>SSL: </b>" ) . $this->SSL . "</br>";
echo _("<b>Host: </b>") . $this->Host . "</br>";
echo _("<b>Port: </b>") . $this->Port . "</br>";
echo _("<b>Admins: </b>") . $this->Adminstring . "</br>";
echo _("<b>UserSuffix: </b>") . $this->suff_users . "</br>";
echo _("<b>GroupSuffix: </b>") . $this->suff_groups . "</br>";
echo _("<b>HostSuffix: </b>") . $this->suff_hosts;
echo _("<b>SSL: </b>" ) . $this->SSL . "<br>";
echo _("<b>Host: </b>") . $this->Host . "<br>";
echo _("<b>Port: </b>") . $this->Port . "<br>";
echo _("<b>Admins: </b>") . $this->Adminstring . "<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>";
echo _("<b>minUID: </b>") . $this->MinUID . "<br>";
echo _("<b>maxUID: </b>") . $this->MaxUID . "<br>";
echo _("<b>minGID: </b>") . $this->MinGID . "<br>";
echo _("<b>maxGID: </b>") . $this->MaxGID . "<br>";
echo _("<b>minMachine: </b>") . $this->MinMachine . "<br>";
echo _("<b>maxMachine: </b>") . $this->MaxMachine . "<br>";
echo _("<b>Default Shell: </b>") . $this->DefaultShell . "<br>";
echo _("<b>Shell list: </b>") . $this->ShellList;
}
// functions to read/write preferences
@ -264,32 +364,104 @@ class Config {
}
function get_UserSuffix() {
return $this->suff_users;
return $this->Suff_users;
}
function set_UserSuffix($value) {
if (is_string($value)) $this->suff_users = $value;
if (is_string($value)) $this->Suff_users = $value;
else echo _("Config->set_UserSuffix failed!");
}
function get_GroupSuffix() {
return $this->suff_groups;
return $this->Suff_groups;
}
function set_GroupSuffix($value) {
if (is_string($value)) $this->suff_groups = $value;
if (is_string($value)) $this->Suff_groups = $value;
else echo _("Config->set_GroupSuffix failed!");
}
function get_HostSuffix() {
return $this->suff_hosts;
return $this->Suff_hosts;
}
function set_HostSuffix($value) {
if (is_string($value)) $this->suff_hosts = $value;
if (is_string($value)) $this->Suff_hosts = $value;
else echo _("Config->set_HostSuffix failed!");
}
function get_minUID() {
return $this->MinUID;
}
function set_minUID($value) {
if (is_numeric($value)) $this->MinUID = $value;
else echo _("Config->set_minUID failed!");
}
function get_maxUID() {
return $this->MaxUID;
}
function set_maxUID($value) {
if (is_numeric($value)) $this->MaxUID = $value;
else echo _("Config->set_maxUID failed!");
}
function get_minGID() {
return $this->MinGID;
}
function set_minGID($value) {
if (is_numeric($value)) $this->MinGID = $value;
else echo _("Config->set_minGID failed!");
}
function get_maxGID() {
return $this->MaxGID;
}
function set_maxGID($value) {
if (is_numeric($value)) $this->MaxGID = $value;
else echo _("Config->set_maxGID failed!");
}
function get_minMachine() {
return $this->MinMachine;
}
function set_minMachine($value) {
if (is_numeric($value)) $this->MinMachine = $value;
else echo _("Config->set_minMachine failed!");
}
function get_maxMachine() {
return $this->MaxMachine;
}
function set_maxMachine($value) {
if (is_numeric($value)) $this->MaxMachine = $value;
else echo _("Config->set_maxMachine failed!");
}
function get_defaultShell() {
return $this->DefaultShell;
}
function set_defaultShell($value) {
if (is_string($value)) $this->DefaultShell = $value;
else echo _("Config->set_shellList failed!");
}
function get_shellList() {
return $this->ShellList;
}
function set_shellList($value) {
if (is_string($value)) $this->ShellList = $value;
else echo _("Config->set_shellList failed!");
}
}
?>

View File

@ -48,20 +48,37 @@ echo ("<body>\n");
echo ("<p align=\"center\"><img src=\"../graphics/banner.jpg\" border=1></p><hr><br><br>\n");
echo ("<form action=\"confsave.php\" method=\"post\">\n");
echo ("<p align=\"center\"><table border=\"0\">");
echo ("<tr><th><p align=\"right\"><b>" . _("Hostname") . ": </b></th> <th><p align=\"left\"><input type=\"text\" name=\"host\" value=\"" . $conf->get_Host() . "\"></th></tr>\n");
echo ("<tr><th><p align=\"right\"><b>" . _("Hostname") . ": </b></th> <th><p align=\"left\"><input type=\"text\" name=\"host\" value=\"" . $conf->get_Host() . "\"></th>\n");
echo ("<th><p align=\"left\">" . _("Hostname of LDAP server") . "</th></tr>\n");
echo ("<tr><th><p align=\"right\"><b>" . _("Portnumber") . ": </b></th> <th><p align=\"left\"><input type=\"text\" size=5 name=\"port\" value=\"" . $conf->get_Port() . "\"></th>\n");
echo _("<th><p align=\"left\">Default is 389, use 636 for SSL connections</th></tr>\n");
if ($conf->get_SSL() == "True") echo ("<tr><th><p align=\"right\"><b>" . _("Use SSL") . ": </b></th> <th><p align=\"left\"><input type=\"checkbox\" name=\"ssl\" checked></th></tr>\n");
else echo ("<tr><th><p align=\"right\"><b>" . _("Use SSL") . ": </b></th> <th><p align=\"left\"><input type=\"checkbox\" name=\"ssl\"></th></tr>\n");
if ($conf->get_SSL() == "True") echo ("<tr><th><p align=\"right\"><b>" . _("Use SSL") . ": </b></th> <th><p align=\"left\"><input type=\"checkbox\" name=\"ssl\" checked></th>\n");
else echo ("<tr><th><p align=\"right\"><b>" . _("Use SSL") . ": </b></th> <th><p align=\"left\"><input type=\"checkbox\" name=\"ssl\"></th>\n");
echo ("<th><p align=\"left\">" . _("Check if your server supports secure connections.") . "</th></tr>\n");
echo ("<tr><th><p align=\"right\"><b>" . _("List of valid users") . ": </b></th> <th><input size=50 type=\"text\" name=\"admins\" value=\"" . $conf->get_Adminstring() . "\"></th>\n");
echo _("<th><p align=\"left\">Usernames must be seperated by semicolons<br>(e.g. cn=admin,dc=yourcompany,dc=com ; uid=root,ou=people,dc=yourcompany,dc=com)</th></tr>\n");
echo ("<th><p align=\"left\">" . _("Usernames must be seperated by semicolons<br>(e.g. cn=admin,dc=yourcompany,dc=com ; uid=root,ou=people,dc=yourcompany,dc=com)") . "</th></tr>\n");
echo ("<tr><th>&nbsp</th></tr>");
echo ("<tr><th><p align=\"right\"><b>" . _("UserSuffix") . ": </b></th> <th><input size=50 type=\"text\" name=\"suffusers\" value=\"" . $conf->get_UserSuffix() . "\"></th>\n");
echo _("<th><p align=\"left\">This is the suffix from where to search for users.<br>(e.g. ou=People,dc=yourcompany,dc=com)</th></tr>\n");
echo ("<th><p align=\"left\">" . _("This is the suffix from where to search for users.<br>(e.g. ou=People,dc=yourcompany,dc=com)=") . "</th></tr>\n");
echo ("<tr><th><p align=\"right\"><b>" . _("GroupSuffix") . ": </b></th> <th><input size=50 type=\"text\" name=\"suffgroups\" value=\"" . $conf->get_GroupSuffix() . "\"></th>\n");
echo _("<th><p align=\"left\">This is the suffix from where to search for groups.<br>(e.g. ou=group,dc=yourcompany,dc=com)</th></tr>\n");
echo ("<th><p align=\"left\">" . _("This is the suffix from where to search for groups.<br>(e.g. ou=group,dc=yourcompany,dc=com)") . "</th></tr>\n");
echo ("<tr><th><p align=\"right\"><b>" . _("HostSuffix") . ": </b></th> <th><input size=50 type=\"text\" name=\"suffhosts\" value=\"" . $conf->get_HostSuffix() . "\"></th>\n");
echo _("<th><p align=\"left\">This is the suffix from where to search for Samba hosts.<br>(e.g. ou=machines,dc=yourcompany,dc=com)</th></tr>\n");
echo ("<th><p align=\"left\">" . _("This is the suffix from where to search for Samba hosts.<br>(e.g. ou=machines,dc=yourcompany,dc=com)") . "</th></tr>\n");
echo ("<tr><th>&nbsp</th></tr>");
echo ("<tr><th><p align=\"right\"><b>" . _("Minimum UID number") . ": </b></th> <th><p align=\"left\"><input size=6 type=\"text\" name=\"minUID\" value=\"" . $conf->get_minUID() . "\">\n");
echo ("&nbsp <b>" . _("Maximum UID number") . ": </b><input size=6 type=\"text\" name=\"maxUID\" value=\"" . $conf->get_maxUID() . "\"></th>\n");
echo ("<th><p align=\"left\">" . _("These are the minimum and maximum numbers to use for user IDs") . "</th></tr>\n");
echo ("<tr><th><p align=\"right\"><b>" . _("Minimum GID number") . ": </b></th> <th><p align=\"left\"><input size=6 type=\"text\" name=\"minGID\" value=\"" . $conf->get_minGID() . "\">\n");
echo ("&nbsp <b>" . _("Maximum GID number") . ": </b><input size=6 type=\"text\" name=\"maxGID\" value=\"" . $conf->get_maxGID() . "\"></th>\n");
echo ("<th><p align=\"left\">" . _("These are the minimum and maximum numbers to use for group IDs") . "</th></tr>\n");
echo ("<tr><th><p align=\"right\"><b>" . _("Minimum Machine number") . ": </b></th> <th><p align=\"left\"><input size=6 type=\"text\" name=\"minMach\" value=\"" . $conf->get_minMachine() . "\">\n");
echo ("&nbsp <b>" . _("Maximum Machine number") . ": </b><input size=6 type=\"text\" name=\"maxMach\" value=\"" . $conf->get_maxMachine() . "\"></th>\n");
echo ("<th><p align=\"left\">" . _("These are the minimum and maximum numbers to use for Samba hosts. <br> Do not use the same range as for user IDs.") . "</th></tr>\n");
echo ("<tr><th>&nbsp</th></tr>");
echo ("<tr><th><p align=\"right\"><b>" . _("Default shell") . ": </b></th> <th><p align=\"left\"><input type=\"text\" name=\"defShell\" value=\"" . $conf->get_defaultShell() . "\"></th>\n");
echo ("<th><p align=\"left\">" . _("Default shell when creating new users.") . "</th></tr>\n");
echo ("<tr><th><p align=\"right\"><b>" . _("Shell list") . ": </b></th> <th><p align=\"left\"><input type=\"text\" size=50 name=\"shellList\" value=\"" . $conf->get_shellList() . "\"></th>\n");
echo ("<th><p align=\"left\">" . _("List of possible shells when creating new users. <br> The entries have to be separated by semicolons.") . "</th></tr>\n");
echo ("<tr><th>&nbsp</th></tr>");
echo ("<tr><th><p align=\"right\"><b>" . _("New Password") . ": </b></th> <th><p align=\"left\"><input type=\"password\" name=\"pass1\"></th></tr>\n");
echo ("<tr><th><p align=\"right\"><b>" . _("Reenter Password") . ": </b></th> <th><p align=\"left\"><input type=\"password\" name=\"pass2\"></th></tr>\n");

View File

@ -55,6 +55,38 @@ if (chop($suffgroups) == "") {
echo _("<b>" . _("UserSuffix is empty!") . "</b>");
exit;
}
if (chop($minUID) == "") {
echo _("<b>" . _("minUID is empty!") . "</b>");
exit;
}
if (chop($maxUID) == "") {
echo _("<b>" . _("maxUID is empty!") . "</b>");
exit;
}
if (chop($minGID) == "") {
echo _("<b>" . _("minGID is empty!") . "</b>");
exit;
}
if (chop($maxGID) == "") {
echo _("<b>" . _("maxGID is empty!") . "</b>");
exit;
}
if (chop($minMach) == "") {
echo _("<b>" . _("minMachine is empty!") . "</b>");
exit;
}
if (chop($maxMach) == "") {
echo _("<b>" . _("maxMachine is empty!") . "</b>");
exit;
}
if (chop($defShell) == "") {
echo _("<b>" . _("default shell is empty!") . "</b>");
exit;
}
if (chop($shellList) == "") {
echo _("<b>" . _("shell list is empty!") . "</b>");
exit;
}
// set new preferences
$conf->set_Host($host);
@ -65,6 +97,14 @@ else $conf->set_SSL("False");
$conf->set_UserSuffix($suffusers);
$conf->set_GroupSuffix($suffgroups);
$conf->set_HostSuffix($suffhosts);
$conf->set_minUID($minUID);
$conf->set_maxUID($maxUID);
$conf->set_minGID($minGID);
$conf->set_maxGID($maxGID);
$conf->set_minMachine($minMach);
$conf->set_maxMachine($maxMach);
$conf->set_defaultShell($defShell);
$conf->set_shellList($shellList);
echo ("<p align=\"center\"><img src=\"../graphics/banner.jpg\"></p><hr><br><br>");

View File

@ -28,3 +28,21 @@ groupsuffix: ou=group,o=test,c=de
# suffix of Samba hosts
# e.g. ou=machines,dc=yourdomain,dc=org
hostsuffix: ou=machines,o=test,c=de
# 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 possible shells
shellList: /bin/bash;/bin/sh;/bin/false
# default shell when creating new user
defaultShell: /bin/bash