use getConfiguredScriptServers()

This commit is contained in:
Roland Gruber 2019-10-22 21:22:32 +02:00
parent 162ed79946
commit d074e2377d
2 changed files with 50 additions and 76 deletions

View File

@ -332,6 +332,20 @@
<para><ulink <para><ulink
url="https://hub.docker.com/r/ldapaccountmanager/lampro">https://hub.docker.com/r/ldapaccountmanager/lampro</ulink></para> url="https://hub.docker.com/r/ldapaccountmanager/lampro">https://hub.docker.com/r/ldapaccountmanager/lampro</ulink></para>
<para><emphasis role="bold">Configuration files</emphasis></para>
<para>All configuration files are stored in:</para>
<itemizedlist>
<listitem>
<para>/etc/ldap-account-manager</para>
</listitem>
<listitem>
<para>/var/lib/ldap-account-manager</para>
</listitem>
</itemizedlist>
</section> </section>
<section> <section>

View File

@ -199,6 +199,11 @@ class posixAccount extends baseModule implements passwordService {
$return['upload_preDepends'] = array('inetOrgPerson'); $return['upload_preDepends'] = array('inetOrgPerson');
// user specific upload options // user specific upload options
if (($this->get_scope() == 'user') && isLoggedIn()) { if (($this->get_scope() == 'user') && isLoggedIn()) {
$lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
$lamdaemonOptions = array();
foreach ($lamdaemonServers as $lamdaemonServer) {
$lamdaemonOptions[] = $lamdaemonServer->getServer();
}
$return['upload_columns'] = array( $return['upload_columns'] = array(
array( array(
'name' => 'posixAccount_userName', 'name' => 'posixAccount_userName',
@ -239,7 +244,7 @@ class posixAccount extends baseModule implements passwordService {
'description' => _('Create home directory'), 'description' => _('Create home directory'),
'help' => 'createhomedir', 'help' => 'createhomedir',
'example' => 'localhost', 'example' => 'localhost',
'values' => $_SESSION['config']->get_scriptServers() 'values' => implode(', ', $lamdaemonOptions)
), ),
array( array(
'name' => 'posixAccount_shell', 'name' => 'posixAccount_shell',
@ -702,18 +707,14 @@ class posixAccount extends baseModule implements passwordService {
$messages = array_merge($messages, $this->setExopPassword($this->moduleSettings)); $messages = array_merge($messages, $this->setExopPassword($this->moduleSettings));
// create home directories if needed // create home directories if needed
$homeDirAttr = $this->getHomedirAttrName($modules); $homeDirAttr = $this->getHomedirAttrName($modules);
$lamdaemonServerList = $_SESSION['config']->getConfiguredScriptServers();
$lamdaemonServerNames = array();
foreach ($lamdaemonServerList as $lamdaemonServer) {
$lamdaemonServerNames[] = $lamdaemonServer->getServer();
}
if (sizeof($this->lamdaemonServers) > 0) { if (sizeof($this->lamdaemonServers) > 0) {
$server = null; foreach ($lamdaemonServerNames as $server) {
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); if (!in_array($server, $this->lamdaemonServers)) {
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
$temp = explode(":", $lamdaemonServers[$i]);
$server = $temp[0];
if (isset($temp[1])) {
if (!in_array($temp[1], $this->lamdaemonServers)) {
continue;
}
}
elseif (!in_array($temp[0], $this->lamdaemonServers)) {
continue; continue;
} }
$remote = new \LAM\REMOTE\Remote(); $remote = new \LAM\REMOTE\Remote();
@ -746,13 +747,7 @@ class posixAccount extends baseModule implements passwordService {
// move home directory if needed // move home directory if needed
if (!empty($this->orig[$homeDirAttr][0]) && !empty($this->attributes[$homeDirAttr][0]) if (!empty($this->orig[$homeDirAttr][0]) && !empty($this->attributes[$homeDirAttr][0])
&& ($this->orig[$homeDirAttr][0] != $this->attributes[$homeDirAttr][0])) { && ($this->orig[$homeDirAttr][0] != $this->attributes[$homeDirAttr][0])) {
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); foreach ($lamdaemonServerNames as $server) {
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
if (empty($lamdaemonServers[$i])) {
continue;
}
$temp = explode(":", $lamdaemonServers[$i]);
$server = $temp[0];
$remote = new \LAM\REMOTE\Remote(); $remote = new \LAM\REMOTE\Remote();
$remote->connect($server); $remote->connect($server);
$result = $remote->execute( $result = $remote->execute(
@ -779,13 +774,7 @@ class posixAccount extends baseModule implements passwordService {
// set new group on homedirectory // set new group on homedirectory
if (!empty($this->orig[$homeDirAttr][0]) && !empty($this->attributes[$homeDirAttr][0]) if (!empty($this->orig[$homeDirAttr][0]) && !empty($this->attributes[$homeDirAttr][0])
&& ($this->orig['gidNumber'][0] != $this->attributes['gidNumber'][0])) { && ($this->orig['gidNumber'][0] != $this->attributes['gidNumber'][0])) {
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); foreach ($lamdaemonServerNames as $server) {
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
if (empty($lamdaemonServers[$i])) {
continue;
}
$temp = explode(":", $lamdaemonServers[$i]);
$server = $temp[0];
$remote = new \LAM\REMOTE\Remote(); $remote = new \LAM\REMOTE\Remote();
$remote->connect($server); $remote->connect($server);
$result = $remote->execute( $result = $remote->execute(
@ -941,16 +930,12 @@ class posixAccount extends baseModule implements passwordService {
$modules = $this->getAccountContainer()->get_type()->getModules(); $modules = $this->getAccountContainer()->get_type()->getModules();
$homeDirAttr = $this->getHomedirAttrName($modules); $homeDirAttr = $this->getHomedirAttrName($modules);
// get list of lamdaemon servers // get list of lamdaemon servers
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
$temp = explode(":", $lamdaemonServers[$i]);
$lamdaemonServers[$i] = $temp[0];
}
// try to delete directory on all servers // try to delete directory on all servers
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) { foreach ($lamdaemonServers as $lamdaemonServer) {
$remote = new \LAM\REMOTE\Remote(); $remote = new \LAM\REMOTE\Remote();
try { try {
$remote->connect($lamdaemonServers[$i]); $remote->connect($lamdaemonServer->getServer());
$result = $remote->execute( $result = $remote->execute(
implode( implode(
self::$SPLIT_DELIMITER, self::$SPLIT_DELIMITER,
@ -1036,7 +1021,9 @@ class posixAccount extends baseModule implements passwordService {
$this->attributes['loginShell'][0] = $_POST['loginShell']; $this->attributes['loginShell'][0] = $_POST['loginShell'];
} }
if (!$this->isBooleanConfigOptionSet('posixAccount_' . $typeId . '_hidegecos')) { if (!$this->isBooleanConfigOptionSet('posixAccount_' . $typeId . '_hidegecos')) {
if (isset($_POST['gecos'])) $this->attributes['gecos'][0] = $_POST['gecos']; if (isset($_POST['gecos'])) {
$this->attributes['gecos'][0] = $_POST['gecos'];
}
} }
if (isset($this->orig['uid'][0]) && ($this->orig['uid'][0] != '') && (trim($_POST['uid']) != $this->attributes['uid'][0])) { if (isset($this->orig['uid'][0]) && ($this->orig['uid'][0] != '') && (trim($_POST['uid']) != $this->attributes['uid'][0])) {
$errors[] = $this->messages['uid'][0]; $errors[] = $this->messages['uid'][0];
@ -1067,16 +1054,11 @@ class posixAccount extends baseModule implements passwordService {
$errors[] = $errorMessage; $errors[] = $errorMessage;
} }
// get list of DNS names or IPs // get list of DNS names or IPs
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
$temp = explode(":", $lamdaemonServers[$i]);
if (isset($temp[1])) $lamdaemonServers[$i] = $temp[1];
else $lamdaemonServers[$i] = $temp[0];
}
$this->lamdaemonServers = array(); $this->lamdaemonServers = array();
for ($h = 0; $h < sizeof($lamdaemonServers); $h++) { for ($h = 0; $h < sizeof($lamdaemonServers); $h++) {
if (isset($_POST['createhomedir_' . $h]) && ($_POST['createhomedir_' . $h] = 'on')) { if (isset($_POST['createhomedir_' . $h]) && ($_POST['createhomedir_' . $h] = 'on')) {
$this->lamdaemonServers[] = $lamdaemonServers[$h]; $this->lamdaemonServers[] = $lamdaemonServers[$h]->getServer();
} }
} }
if (isset($_POST['homeDirectory'])) { if (isset($_POST['homeDirectory'])) {
@ -1483,12 +1465,11 @@ class posixAccount extends baseModule implements passwordService {
function process_homedir() { function process_homedir() {
$return = array(); $return = array();
// get list of lamdaemon servers // get list of lamdaemon servers
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
$modules = $this->getAccountContainer()->get_type()->getModules(); $modules = $this->getAccountContainer()->get_type()->getModules();
$homeDirAttr = $this->getHomedirAttrName($modules); $homeDirAttr = $this->getHomedirAttrName($modules);
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) { for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
$temp = explode(":", $lamdaemonServers[$i]); $server = $lamdaemonServers[$i]->getServer();
$server = $temp[0];
if (isset($_POST['form_subpage_' . get_class($this) . '_homedir_create_' . $i])) { if (isset($_POST['form_subpage_' . get_class($this) . '_homedir_create_' . $i])) {
$remote = new \LAM\REMOTE\Remote(); $remote = new \LAM\REMOTE\Remote();
$remote->connect($server); $remote->connect($server);
@ -1676,21 +1657,12 @@ class posixAccount extends baseModule implements passwordService {
if (($_SESSION['config']->get_scriptPath() != null) && ($_SESSION['config']->get_scriptPath() != '')) { if (($_SESSION['config']->get_scriptPath() != null) && ($_SESSION['config']->get_scriptPath() != '')) {
if ($this->getAccountContainer()->isNewAccount) { if ($this->getAccountContainer()->isNewAccount) {
// get list of lamdaemon servers // get list of lamdaemon servers
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
$temp = explode(":", $lamdaemonServers[$i]);
if (isset($temp[1])) {
$lamdaemonServers[$i] = $temp[1];
}
else {
$lamdaemonServers[$i] = $temp[0];
}
}
$homeDirLabel = new htmlOutputText(_('Create home directory')); $homeDirLabel = new htmlOutputText(_('Create home directory'));
$return->addLabel($homeDirLabel); $return->addLabel($homeDirLabel);
$homeServerContainer = new htmlTable(); $homeServerContainer = new htmlTable();
for ($h = 0; $h < sizeof($lamdaemonServers); $h++) { for ($h = 0; $h < sizeof($lamdaemonServers); $h++) {
$homeServerContainer->addElement(new htmlTableExtendedInputCheckbox('createhomedir_' . $h, in_array($lamdaemonServers[$h], $this->lamdaemonServers), $lamdaemonServers[$h], null, false)); $homeServerContainer->addElement(new htmlTableExtendedInputCheckbox('createhomedir_' . $h, in_array($lamdaemonServers[$h], $this->lamdaemonServers), $lamdaemonServers[$h]->getLabel(), null, false));
if ($h === 0) { if ($h === 0) {
$homeDirHelp = new htmlHelpLink('createhomedir'); $homeDirHelp = new htmlHelpLink('createhomedir');
$homeServerContainer->addElement($homeDirHelp); $homeServerContainer->addElement($homeDirHelp);
@ -1936,14 +1908,10 @@ class posixAccount extends baseModule implements passwordService {
$return->addField(new htmlOutputText($this->attributes[$homeDirAttr][0])); $return->addField(new htmlOutputText($this->attributes[$homeDirAttr][0]));
$return->addVerticalSpacer('2rem'); $return->addVerticalSpacer('2rem');
// get list of lamdaemon servers // get list of lamdaemon servers
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) { for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
$temp = explode(":", $lamdaemonServers[$i]); $server = $lamdaemonServers[$i]->getServer();
$server = $temp[0]; $label = $lamdaemonServers[$i]->getLabel();
$label = $temp[0];
if (isset($temp[1])) {
$label = $temp[1];
}
$remote = new \LAM\REMOTE\Remote(); $remote = new \LAM\REMOTE\Remote();
$remote->connect($server); $remote->connect($server);
$result = $remote->execute( $result = $remote->execute(
@ -2036,14 +2004,11 @@ class posixAccount extends baseModule implements passwordService {
// lamdaemon settings // lamdaemon settings
if ($_SESSION['config']->get_scriptPath() != null) { if ($_SESSION['config']->get_scriptPath() != null) {
$return->add(new htmlSubTitle(_('Create home directory')), 12); $return->add(new htmlSubTitle(_('Create home directory')), 12);
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
$temp = explode(":", $lamdaemonServers[$i]);
if (isset($temp[1])) $lamdaemonServers[$i] = $temp[1];
else $lamdaemonServers[$i] = $temp[0];
}
for ($h = 0; $h < sizeof($lamdaemonServers); $h++) { for ($h = 0; $h < sizeof($lamdaemonServers); $h++) {
$return->add(new htmlResponsiveInputCheckbox('posixAccount_createHomedir_' . $h, in_array($lamdaemonServers[$h], $this->lamdaemonServers), $lamdaemonServers[$h], 'createhomedir', false), 12); $server = $lamdaemonServers[$h]->getServer();
$label = $lamdaemonServers[$h]->getLabel();
$return->add(new htmlResponsiveInputCheckbox('posixAccount_createHomedir_' . $h, in_array($server, $this->lamdaemonServers), $label, 'createhomedir', false), 12);
} }
} }
} }
@ -2090,16 +2055,11 @@ class posixAccount extends baseModule implements passwordService {
} }
// lamdaemon // lamdaemon
if (($this->get_scope() == 'user') && $this->getAccountContainer()->isNewAccount) { if (($this->get_scope() == 'user') && $this->getAccountContainer()->isNewAccount) {
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
$temp = explode(":", $lamdaemonServers[$i]);
if (isset($temp[1])) $lamdaemonServers[$i] = $temp[1];
else $lamdaemonServers[$i] = $temp[0];
}
$this->lamdaemonServers = array(); $this->lamdaemonServers = array();
for ($h = 0; $h < sizeof($lamdaemonServers); $h++) { for ($h = 0; $h < sizeof($lamdaemonServers); $h++) {
if (isset($profile['posixAccount_createHomedir_' . $h][0]) && ($profile['posixAccount_createHomedir_' . $h][0] == 'true')) { if (isset($profile['posixAccount_createHomedir_' . $h][0]) && ($profile['posixAccount_createHomedir_' . $h][0] == 'true')) {
$this->lamdaemonServers[] = $lamdaemonServers[$h]; $this->lamdaemonServers[] = $lamdaemonServers[$h]->getServer();
} }
} }
} }