mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
ssh: Use privileged decorator for actions
Tests: - Functional tests work - Updating SSH keys in user edit page sets the SSH keys. File is updated properly. Page shows newly set SSH keys. - Entering invalid auth credentials throws error - Enabling/disabling SSH password authentication works. - Configuration file is updated. - App page shows proper value Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
8bdb73df9a
commit
12cf5065b0
5 files changed
+51
-121
No files matched your search
@@ -15,6 +15,7 @@ from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy
|
||||
|
||||
import plinth.forms
|
||||
import plinth.modules.ssh.privileged as ssh_privileged
|
||||
from plinth import actions
|
||||
from plinth.errors import ActionError
|
||||
from plinth.modules import first_boot
|
||||
@@ -294,16 +295,10 @@ class UserUpdateForm(ValidNewUsernameCheckMixin, PasswordConfirmForm,
|
||||
_('Failed to add user to group.'))
|
||||
|
||||
try:
|
||||
actions.superuser_run('ssh', [
|
||||
'set-keys',
|
||||
'--username',
|
||||
user.get_username(),
|
||||
'--keys',
|
||||
self.cleaned_data['ssh_keys'].strip(),
|
||||
'--auth-user',
|
||||
auth_username,
|
||||
], input=confirm_password.encode())
|
||||
except ActionError:
|
||||
ssh_privileged.set_keys(user.get_username(),
|
||||
self.cleaned_data['ssh_keys'].strip(),
|
||||
auth_username, confirm_password)
|
||||
except Exception:
|
||||
messages.error(self.request, _('Unable to set SSH keys.'))
|
||||
|
||||
is_active = self.cleaned_data['is_active']
|
||||
|
||||
Reference in new issue
Block a user