1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<?php
ConfigModule::registerModule(
ConfigModule_SshConfig::MODID, // ID
Dictionary::translateFile('config-module', 'sshconfig_title'), // Title
Dictionary::translateFile('config-module', 'sshconfig_description'), // Description
Dictionary::translateFile('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;
}
}
|