summaryrefslogtreecommitdiffstats
path: root/inc/configmodule/sshconfig.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2015-02-06 16:12:45 +0100
committerSimon Rettberg2015-02-06 16:12:45 +0100
commit161180cdf4e915526bc8d62c0301a09130fbf59e (patch)
tree3f59fd0da89fe42c2838885eef82b23064cac8a4 /inc/configmodule/sshconfig.inc.php
parentFinish config module editing (diff)
downloadslx-admin-161180cdf4e915526bc8d62c0301a09130fbf59e.tar.gz
slx-admin-161180cdf4e915526bc8d62c0301a09130fbf59e.tar.xz
slx-admin-161180cdf4e915526bc8d62c0301a09130fbf59e.zip
Add sshd config module
Diffstat (limited to 'inc/configmodule/sshconfig.inc.php')
-rw-r--r--inc/configmodule/sshconfig.inc.php63
1 files changed, 63 insertions, 0 deletions
diff --git a/inc/configmodule/sshconfig.inc.php b/inc/configmodule/sshconfig.inc.php
new file mode 100644
index 00000000..853acf6a
--- /dev/null
+++ b/inc/configmodule/sshconfig.inc.php
@@ -0,0 +1,63 @@
+<?php
+
+ConfigModule::registerModule(
+ ConfigModule_SshConfig::MODID, // ID
+ Dictionary::translate('config-module', 'sshconfig_title'), // Title
+ Dictionary::translate('config-module', 'sshconfig_description'), // Description
+ Dictionary::translate('config-module', 'group_sshconfig'), // Group
+ true // Only one per config?
+);
+
+class ConfigModule_SshConfig extends ConfigModule
+{
+ const MODID = 'SshConfig';
+ const VERSION = 1;
+
+ protected function generateInternal($tgz, $parent)
+ {
+ if (!$this->validateConfig())
+ return false;
+ $config = $this->moduleData + array(
+ 'filename' => $tgz,
+ 'failOnParentFail' => false,
+ 'parent' => $parent
+ );
+ // Create config module, which will also check if the pubkey is valid
+ return Taskmanager::submit('SshdConfigGenerator', $config);
+ }
+
+ protected function moduleVersion()
+ {
+ return self::VERSION;
+ }
+
+ protected function validateConfig()
+ {
+ return isset($this->moduleData['publicKey']) && isset($this->moduleData['allowPasswordLogin']) && isset($this->moduleData['listenPort']);
+ }
+
+ public function setData($key, $value)
+ {
+ switch ($key) {
+ case 'publicKey':
+ break;
+ case 'allowPasswordLogin':
+ if ($value === true || $value === 'yes')
+ $value = 'yes';
+ elseif ($value === false || $value === 'no')
+ $value = 'no';
+ else
+ return false;
+ break;
+ case 'listenPort':
+ if (!is_numeric($value) || $value < 1 || $value > 65535)
+ return false;
+ break;
+ default:
+ return false;
+ }
+ $this->moduleData[$key] = $value;
+ return true;
+ }
+
+}