diff options
author | Simon Rettberg | 2020-11-16 14:03:21 +0100 |
---|---|---|
committer | Simon Rettberg | 2020-11-16 14:03:21 +0100 |
commit | 11c488215620d12c1f79fc9b05deb9928d2cab39 (patch) | |
tree | d6d546f5c1729325482976587a232e1e7a0378fc /modules-available/sysconfig/addmodule_sshkey.inc.php | |
parent | [statistics] Honor filters for clients with special mode (diff) | |
download | slx-admin-11c488215620d12c1f79fc9b05deb9928d2cab39.tar.gz slx-admin-11c488215620d12c1f79fc9b05deb9928d2cab39.tar.xz slx-admin-11c488215620d12c1f79fc9b05deb9928d2cab39.zip |
[sysconfig] SSH: Split pubkey and rest of config, add more options
Now we can have exactly one SSH-Config per sysconfig, which avoids
confusion due to config mismatch regarding "allow pw" and "port".
The install include takes care of splitting the key into a new module
for existing modules, but doesn't remove duplicate SshConfig modules
from sysconfigs, as this might lead to additional confusion. Next time
the user edits a sysconfig, they are forced to pick exactly one
SshConfig module.
The "allow password login" option was extended to allow password login
for non-root users only in addition to simply being "yes" or "no".
There's an additional option that can entirely limit the group of users
allowed to log in via SSH.
Diffstat (limited to 'modules-available/sysconfig/addmodule_sshkey.inc.php')
-rw-r--r-- | modules-available/sysconfig/addmodule_sshkey.inc.php | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/modules-available/sysconfig/addmodule_sshkey.inc.php b/modules-available/sysconfig/addmodule_sshkey.inc.php new file mode 100644 index 00000000..b5ab4ad6 --- /dev/null +++ b/modules-available/sysconfig/addmodule_sshkey.inc.php @@ -0,0 +1,72 @@ +<?php + +/* + * Wizard for configuring the sshd (client side). + */ + +class SshKey_Start extends AddModule_Base +{ + + protected function renderInternal() + { + if ($this->edit !== false) { + $data = $this->edit->getData(false) + array( + 'title' => $this->edit->title(), + 'edit' => $this->edit->id(), + ); + } else { + $data = array(); + } + Render::addDialog(Dictionary::translateFile('config-module', 'sshkey_title'), false, 'sshkey-start', $data + array( + 'step' => 'SshKey_Finish', + )); + } + +} + +class SshKey_Finish extends AddModule_Base +{ + + protected function preprocessInternal() + { + $title = Request::post('title'); + if (empty($title)) { + Message::addError('missing-title'); + return; + } + // Seems ok, create entry + if ($this->edit === false) { + $module = ConfigModule::getInstance('SshKey'); + } else { + $module = $this->edit; + } + if ($module === false) { + Message::addError('main.error-read', 'sshkey.inc.php'); + Util::redirect('?do=SysConfig&action=addmodule&step=SshKey_Start'); + } + if (!$module->setData('publicKey', Request::post('publicKey'))) { + Message::addError('main.value-invalid', 'pubkey', Request::post('publicKey')); + Util::redirect('?do=SysConfig&action=addmodule&step=SshKey_Start'); + } + if ($this->edit !== false) { + $ret = $module->update($title); + } else { + $ret = $module->insert($title); + } + if (!$ret) { + Util::redirect('?do=SysConfig&action=addmodule&step=SshKey_Start'); + } elseif (!$module->generate($this->edit === false, NULL, 200)) { + Util::redirect('?do=SysConfig&action=addmodule&step=SshKey_Start'); + } + // Yay + if ($this->edit !== false) { + Message::addSuccess('module-edited'); + } else { + Message::addSuccess('module-added'); + AddModule_Base::setStep('AddModule_Assign', $module->id()); + return; + } + Util::redirect('?do=SysConfig'); + } + +} |