mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
- Integrate SSH error handling into borg error handling. - Move logic to migrate SSH keys into lower levels (Repository class) so that it can performed at more instances such as when initializing repository. It also provides better abstraction keeping the view logic simpler. - Drop ability to mount repository using password. This is important next step for mounting using systemd unit files. - Use exceptions to eliminate return value checking. - Create a special exception for exceptions raised during SSH operations. Raise this at lower levels and handle these using the common error handler. Tests: - Adding a remote repository with key and password authentication works with and without encryption. Adding works with SSH host key pre-verified works too. - Trying to add a remote repository with incorrect passpharse fails with the simplified error message. Redirect happens to add remote repository page. Error message with SSH host key pre-verified works too. Repository is removed. - Trying to provide wrong SSH password fails with a simplified error message. Redirect happens to add remote repository page. Repository is removed. - Mounting a repository after unmounting it works. - Mounting a repository with SSH password in its configuration works. Migration is performed and SSH password is replaced with SSH key file path. - A schedule for a repository with SSH password runs successfully. An archive is created. Migration is performed and SSH password is replaced with SSH key file path. - SSH identity files are created with plinth:plinth ownership. Private key file is created with 0o600 permissions and public key file is created with 0o644 permissions. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import subprocess
|
|
|
|
from plinth.errors import PlinthError
|
|
|
|
|
|
class BorgError(PlinthError):
|
|
"""Generic borg errors."""
|
|
|
|
|
|
class BorgRepositoryDoesNotExistError(BorgError):
|
|
"""Borg access to a repository works but the repository does not exist."""
|
|
|
|
|
|
class SshError(subprocess.CalledProcessError):
|
|
"""Error when running an SSH command."""
|
|
|
|
|
|
class SshfsError(PlinthError):
|
|
"""Generic sshfs errors."""
|
|
|
|
|
|
class BorgRepositoryExists(BorgError):
|
|
"""A repository at target location already exists during initialization."""
|
|
|
|
|
|
class BorgUnencryptedRepository(BorgError):
|
|
"""Attempt to provide password on an unencrypted repository."""
|
|
|
|
|
|
class BorgArchiveExists(BorgError):
|
|
"""A archive with the given name already exists in the repository."""
|
|
|
|
|
|
class BorgArchiveDoesNotExist(BorgError):
|
|
"""Specified archive does not exist in the repository."""
|
|
|
|
|
|
class BorgBusy(BorgError):
|
|
"""Borg could not acquire lock being busy with another operation."""
|
|
|
|
|
|
class BorgNoSpace(BorgError):
|
|
"""There is not enough space left on the device to perform operation."""
|