diff options
-rw-r--r-- | apis/update.inc.php | 3 | ||||
-rw-r--r-- | inc/configmodule.inc.php | 2 | ||||
-rw-r--r-- | inc/configtgz.inc.php | 5 | ||||
-rw-r--r-- | inc/download.inc.php | 32 | ||||
-rw-r--r-- | inc/trigger.inc.php | 9 | ||||
-rw-r--r-- | lang/de/templates/sysconfig/ad-checkcredentials.json | 1 | ||||
-rw-r--r-- | lang/en/templates/sysconfig/ad-checkcredentials.json | 1 | ||||
-rw-r--r-- | modules/backup.inc.php | 2 | ||||
-rw-r--r-- | modules/sysconfig/addmodule_adauth.inc.php | 33 | ||||
-rw-r--r-- | modules/systemstatus.inc.php | 30 | ||||
-rw-r--r-- | style/default.css | 5 | ||||
-rw-r--r-- | templates/sysconfig/ad-checkconnection.html | 8 | ||||
-rw-r--r-- | templates/sysconfig/ad-checkcredentials.html | 3 | ||||
-rw-r--r-- | templates/systemstatus/_page.html | 22 |
14 files changed, 137 insertions, 19 deletions
diff --git a/apis/update.inc.php b/apis/update.inc.php index 21950cff..134e7ad8 100644 --- a/apis/update.inc.php +++ b/apis/update.inc.php @@ -224,6 +224,9 @@ function update_8() return true; } +// ####################### +// ##### 2015-05-21 +// Add statistics table, for future logging of eg. function update_9() { Database::exec("CREATE TABLE IF NOT EXISTS `statistic` ( diff --git a/inc/configmodule.inc.php b/inc/configmodule.inc.php index 4dd7c951..5c613f1b 100644 --- a/inc/configmodule.inc.php +++ b/inc/configmodule.inc.php @@ -184,6 +184,7 @@ abstract class ConfigModule * Module specific version of generate. * * @param string $tgz File name of tgz module to write final output to + * @param string $parent Parent task of this task * @return array|boolean true if generation is completed immediately, * a task struct if some task needs to be run for generation, * false on error @@ -307,6 +308,7 @@ abstract class ConfigModule * Updating the database etc. will happen later through a callback. * * @param boolean $deleteOnError if true, the db entry will be deleted if generation failed + * @param string $parent Parent task of this task * @param int $timeoutMs maximum time in milliseconds we wait for completion * @return string|boolean task id if deferred generation was started, * true if generation succeeded (without using a task or within $timeoutMs) diff --git a/inc/configtgz.inc.php b/inc/configtgz.inc.php index 8ddd4523..b51d2787 100644 --- a/inc/configtgz.inc.php +++ b/inc/configtgz.inc.php @@ -38,6 +38,11 @@ class ConfigTgz return true; } + public function isActive() + { + return readlink(CONFIG_HTTP_DIR . '/default/config.tgz') === $this->file; + } + public function getModuleIds() { $ret = array(); diff --git a/inc/download.inc.php b/inc/download.inc.php index 6485ee24..5347e2ee 100644 --- a/inc/download.inc.php +++ b/inc/download.inc.php @@ -59,6 +59,38 @@ class Download } /** + * POST-Download file, obey given timeout in seconds + * Return data on success, false on failure + * @param string $url URL to fetch + * @param array $params POST params to set in body, list of key-value-pairs + * @param int $timeout timeout in seconds + * @param int $code HTTP response code, or 999 on error + */ + public static function asStringPost($url, $params, $timeout, &$code) + { + $string = ''; + foreach ($params as $k => $v) { + if (!empty($string)) { + $string .= '&'; + } + $string .= $k . '=' . urlencode($v); + } + $ch = self::initCurl($url, $timeout, $head); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $string); + $data = curl_exec($ch); + $head = self::getContents($head); + if (preg_match('#^HTTP/\d+\.\d+ (\d+) #', $head, $out)) { + $code = (int) $out[1]; + } else { + $code = 999; + } + curl_close($ch); + return $data; + } + + /** * Download a file from a URL to file. * * @param string $target destination path to download file to diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php index 0b1f00c5..9062cafd 100644 --- a/inc/trigger.inc.php +++ b/inc/trigger.inc.php @@ -160,15 +160,6 @@ class Trigger private static function triggerDaemons($action, $parent, &$taskids) { - $task = Taskmanager::submit('SyncdaemonLauncher', array( - 'operation' => $action, - 'parentTask' => $parent, - 'failOnParentFail' => false - )); - if (isset($task['id'])) { - $taskids['syncid'] = $task['id']; - $parent = $task['id']; - } $task = Taskmanager::submit('DozmodLauncher', array( 'operation' => $action, 'parentTask' => $parent, diff --git a/lang/de/templates/sysconfig/ad-checkcredentials.json b/lang/de/templates/sysconfig/ad-checkcredentials.json index 17415bc4..f0ab6e15 100644 --- a/lang/de/templates/sysconfig/ad-checkcredentials.json +++ b/lang/de/templates/sysconfig/ad-checkcredentials.json @@ -1,5 +1,6 @@ { "lang_back": "Zur\u00fcck", "lang_connectionWait": "Die Verbindung zum angegebenen AD-Server wird nun \u00fcberpr\u00fcft. Bitte haben Sie einen Moment Geduld.", + "lang_onProblemSearchBase": "Falls dieser Schritt fehlschl\u00e4gt, und Sie keine Suchbasis angegeben haben, versuchen Sie es erneut unter expliziter Angabe einer Suchbasis.", "lang_skip": "\u00dcberspringen" }
\ No newline at end of file diff --git a/lang/en/templates/sysconfig/ad-checkcredentials.json b/lang/en/templates/sysconfig/ad-checkcredentials.json index 5ae50d59..2b83a231 100644 --- a/lang/en/templates/sysconfig/ad-checkcredentials.json +++ b/lang/en/templates/sysconfig/ad-checkcredentials.json @@ -1,5 +1,6 @@ { "lang_back": "Back", "lang_connectionWait": "The connection to the specified AD server is now checked. Please wait a moment.", + "lang_onProblemSearchBase": "If this step fails and you didn't supply a search base, try again with a valid one.", "lang_skip": "Skip" }
\ No newline at end of file diff --git a/modules/backup.inc.php b/modules/backup.inc.php index 2a44997a..02b02b0e 100644 --- a/modules/backup.inc.php +++ b/modules/backup.inc.php @@ -97,7 +97,7 @@ class Page_Backup extends Page $parent = $task['id']; } EventLog::info('Creating backup, v' . Database::getExpectedSchemaVersion() . ' on ' . Property::getServerIp()); - // Finally run backup + // Finally run restore $task = Taskmanager::submit('BackupRestore', array( 'mode' => 'restore', 'backupFile' => $tempfile, diff --git a/modules/sysconfig/addmodule_adauth.inc.php b/modules/sysconfig/addmodule_adauth.inc.php index c9b42ee5..1b04eab0 100644 --- a/modules/sysconfig/addmodule_adauth.inc.php +++ b/modules/sysconfig/addmodule_adauth.inc.php @@ -31,6 +31,9 @@ class AdAuth_Start extends AddModule_Base 'ssl' => Request::post('ssl') ); } + if (preg_match('/^(.*)\:(636|3269|389|3268)$/', $data['server'], $out)) { + $data['server'] = $out[1]; + } $data['step'] = 'AdAuth_CheckConnection'; Render::addDialog(Dictionary::translate('config-module', 'adAuth_title'), false, 'sysconfig/ad-start', $data); } @@ -211,14 +214,17 @@ class AdAuth_Finish extends AddModule_Base $module = ConfigModule::getInstance('AdAuth'); else $module = $this->edit; + $ssl = Request::post('ssl', 'off') === 'on'; $module->setData('server', Request::post('server')); $module->setData('searchbase', $searchbase); $module->setData('binddn', $binddn); $module->setData('bindpw', Request::post('bindpw')); $module->setData('home', Request::post('home')); - $module->setData('ssl', Request::post('ssl', 'off') === 'on'); - if (Request::post('fingerprint')) { - $module->setData('fingerprint', Request::post('fingerprint')); + $module->setData('ssl', $ssl); + if ($ssl) { + $module->setData('fingerprint', Request::post('fingerprint', '')); + } else { + $module->setData('fingerprint', ''); } if ($this->edit !== false) $ret = $module->update($title); @@ -228,7 +234,8 @@ class AdAuth_Finish extends AddModule_Base Message::addError('value-invalid', 'any', 'any'); $tgz = false; } else { - $tgz = $module->generate($this->edit === false, NULL, 200); + $parent = $this->stopOldInstance(); + $tgz = $module->generate($this->edit === false, $parent); } if ($tgz === false) { AddModule_Base::setStep('AdAuth_Start'); // Continues with AdAuth_Start for render() @@ -238,6 +245,24 @@ class AdAuth_Finish extends AddModule_Base 'tm-config' => $tgz, ); } + + private function stopOldInstance() + { + if ($this->edit === false) + return NULL; + $list = ConfigTgz::getAllForModule($this->edit->id()); + if (!is_array($list)) + return NULL; + $parent = NULL; + foreach ($list as $tgz) { + if (!$tgz->isActive()) + continue; + $task = Trigger::ldadp($tgz->id(), $parent); + if (isset($task['id'])) + $parent = $task['id']; + } + return $parent; + } protected function renderInternal() { diff --git a/modules/systemstatus.inc.php b/modules/systemstatus.inc.php index e80179ad..a477b252 100644 --- a/modules/systemstatus.inc.php +++ b/modules/systemstatus.inc.php @@ -208,6 +208,36 @@ class Page_SystemStatus extends Page echo '<pre>', htmlspecialchars(substr($data, strpos($data, "\n") + 1)), '</pre>'; } + protected function ajaxNetstat() + { + $taskId = Taskmanager::submit('Netstat'); + if ($taskId === false) + return; + $status = Taskmanager::waitComplete($taskId, 3500); + + if (isset($status['data']['messages'])) + $data = $status['data']['messages']; + else + $data = 'Taskmanager error'; + + echo '<pre>', htmlspecialchars($data), '</pre>'; + } + + protected function ajaxPsList() + { + $taskId = Taskmanager::submit('PsList'); + if ($taskId === false) + return; + $status = Taskmanager::waitComplete($taskId, 3500); + + if (isset($status['data']['messages'])) + $data = $status['data']['messages']; + else + $data = 'Taskmanager error'; + + echo '<pre>', htmlspecialchars($data), '</pre>'; + } + private function usageColor($percent) { if ($percent <= 50) { diff --git a/style/default.css b/style/default.css index c154a203..901da5e9 100644 --- a/style/default.css +++ b/style/default.css @@ -62,6 +62,11 @@ body { text-align: left; } +.slx-ga2 { + min-width: 12em; + text-align: left; +} + .slx-dialog { width: 100%; min-width: 600px; diff --git a/templates/sysconfig/ad-checkconnection.html b/templates/sysconfig/ad-checkconnection.html index 1c3a1091..f5fcb2a8 100644 --- a/templates/sysconfig/ad-checkconnection.html +++ b/templates/sysconfig/ad-checkconnection.html @@ -51,13 +51,15 @@ var ports = task.data.ports; for (var i = 0; i < ports.length; ++i) { if (ports[i].open && ports[i].port && (!ssl || ports[i].certFingerprint.length > 10)) { + if ($.isNumeric($('#port').val()) && $('#port').val() < ports[i].port) continue; // Prefer the global LDAP ports over the specific AD ports $('#port').val(ports[i].port); if (ssl) $('#fingerprint').val(ports[i].certFingerprint); - $('#nextbutton').show(); - $('#nextform').submit(); - return; } } + if ($('#port').val() > 0) { + $('#nextbutton').show(); + $('#nextform').submit(); + } } } </script> diff --git a/templates/sysconfig/ad-checkcredentials.html b/templates/sysconfig/ad-checkcredentials.html index e1d15678..9378adad 100644 --- a/templates/sysconfig/ad-checkcredentials.html +++ b/templates/sysconfig/ad-checkcredentials.html @@ -6,7 +6,8 @@ <div data-tm-id="{{self-search}}" data-tm-log="messages" data-tm-callback="selfCb">LDAP Self-Query</div> <div data-tm-id="{{tm-search}}" data-tm-log="messages" data-tm-callback="ldapCb">LDAP Test-Query</div> </div> -<br> +<i>{{lang_onProblemSearchBase}}</i> +<br><br> <div class="pull-left"> <form role="form" method="post" action="?do=SysConfig&action=addmodule&step=AdAuth_Start"> <input type="hidden" name="token" value="{{token}}"> diff --git a/templates/systemstatus/_page.html b/templates/systemstatus/_page.html index 22eeb7d3..79024ad6 100644 --- a/templates/systemstatus/_page.html +++ b/templates/systemstatus/_page.html @@ -86,11 +86,31 @@ <span class="glyphicon glyphicon-refresh slx-rotation"></span> </div> </div> +<div class="panel panel-default"> + <div class="panel-heading"> + netstat -tulpn + </div> + <div class="panel-body" id="netstat"> + <span class="glyphicon glyphicon-refresh slx-rotation"></span> + </div> +</div> +<div class="panel panel-default"> + <div class="panel-heading"> + ps auxf + </div> + <div class="panel-body" id="pslist"> + <span class="glyphicon glyphicon-refresh slx-rotation"></span> + </div> +</div> <script type="text/javascript"> loadContent('#diskstat', '?do=SystemStatus&action=DiskStat'); loadContent('#addresses', '?do=SystemStatus&action=AddressList'); loadContent('#systeminfo', '?do=SystemStatus&action=SystemInfo'); loadContent('#services', '?do=SystemStatus&action=Services'); - loadContent('#dmsd-log', '?do=SystemStatus&action=DmsdLog'); + setTimeout(function() { + loadContent('#dmsd-log', '?do=SystemStatus&action=DmsdLog'); + loadContent('#netstat', '?do=SystemStatus&action=Netstat'); + loadContent('#pslist', '?do=SystemStatus&action=PsList'); + }, 500); </script> |