Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

key: better key handling and additional sub commands #983

Open
kapitainsky opened this issue Jan 1, 2024 · 3 comments
Open

key: better key handling and additional sub commands #983

kapitainsky opened this issue Jan 1, 2024 · 3 comments
Labels
A-architecture Area: Related to `rustic`s architecture A-commands Area: Related to commands in `rustic` A-core Area: Generally related to `rustic_core` A-encryption Area: Related to encryption C-enhancement Category: New feature or request

Comments

@kapitainsky
Copy link
Contributor

kapitainsky commented Jan 1, 2024

$ rustic --version
rustic v0.6.1
$ rustic key list
error: unrecognized subcommand 'list'

Usage: rustic key [OPTIONS] <COMMAND>

For more information, try '--help'.
$ rustic key --help
Manage keys

Usage: rustic key [OPTIONS] <COMMAND>

Commands:
  add   Add a new key to the repository
  help  Print this message or the help of the given subcommand(s)

Options:
  -h, --help
          Print help (see a summary with '-h')

Looks like key list command has got lost during latest refactoring...

Unless documentation is wrong:
https://rustic.cli.rs/docs/commands/misc/key.html

Possibly also remove and passwd

@github-actions github-actions bot added the S-triage Status: Waiting for a maintainer to triage this issue/PR label Jan 1, 2024
@simonsan
Copy link
Contributor

simonsan commented Jan 1, 2024

The documentation is copied from restic, so some things need to be adapted.

For the Key management, I think this is currently a bit of a hackery and I think might need to rework it a bit, to add the other options more ergonomic way.

@simonsan simonsan changed the title rustic key list missing key: better key handling and additional sub commands Jan 1, 2024
@simonsan simonsan added C-enhancement Category: New feature or request A-commands Area: Related to commands in `rustic` A-encryption Area: Related to encryption A-core Area: Generally related to `rustic_core` A-architecture Area: Related to `rustic`s architecture and removed S-triage Status: Waiting for a maintainer to triage this issue/PR labels Jan 1, 2024
@aawsome
Copy link
Member

aawsome commented Jan 1, 2024

@kapitainsky Thanks for opening the issue - for the key there are indeed some subcommands which were never implemented.

You can use rustic list key to get a list of present key ids. Also the keys can be read manually in the repository as they are plaintext json files.

But I agree, the other subcommands for key handling need to be added.
Anyone up for a PR? This should be pretty straightforward to implement...

@simonsan
Copy link
Contributor

simonsan commented Jan 1, 2024

Anyone up for a PR? This should be pretty straightforward to implement...

A PR would be nice, though I wouldn't say, that it is straight forward to implement, as there needs to be a bit more design work, I feel. Currently it's rather hacky, with creating a new fake repository to add a key:

        let repo = open_repository(&config)?;

        // create new "artificial" repo using the given password options
        let repo_opts = RepositoryOptions {
            password_file: self.new_password_file.clone(),
            repository: Some(String::new()), // fake repository to make Repository::new() not bail
            ..Default::default()
        };
        let repo_newpass = Repository::new(&repo_opts)?;

        let pass = repo_newpass
            .password()
            .map_err(|err| err.into())
            .transpose()
            .unwrap_or_else(|| -> Result<_> {
                Ok(Password::new()
                    .with_prompt("enter password for new key")
                    .allow_empty_password(true)
                    .with_confirmation("confirm password", "passwords do not match")
                    .interact()?)
            })?;

        let id = repo.add_key(&pass, &self.key_opts)?;

Also, we don't have anything really about key management in rustic_core I believe? So it would be good to create something there. I could imagine a trait for managing keys and implementing it for different repository states. We should also keep in mind how that interacts with future changes to encryption algorithms and where and how it connects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-architecture Area: Related to `rustic`s architecture A-commands Area: Related to commands in `rustic` A-core Area: Generally related to `rustic_core` A-encryption Area: Related to encryption C-enhancement Category: New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants