-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
keep pass in keyring while executing program, delete it on exit
get pass from keyring when is needed to refresh the encryption key
- Loading branch information
1 parent
d5658e8
commit eda0c62
Showing
5 changed files
with
80 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use keyring::Entry; | ||
use secrecy::{ExposeSecret, SecretString}; | ||
|
||
const KEYRING_SERVICE: &'static str = "rencfs"; | ||
const KEYRING_USER: &'static str = "encrypted_fs"; | ||
|
||
pub(crate) fn save(password: SecretString, suffix: &str) -> Result<(), keyring::Error> { | ||
let entry = Entry::new(KEYRING_SERVICE, &format!("{KEYRING_USER}.{suffix}"))?; | ||
entry.set_password(password.expose_secret()) | ||
} | ||
|
||
pub(crate) fn delete(suffix: &str) -> Result<(), keyring::Error> { | ||
let entry = Entry::new(KEYRING_SERVICE, &format!("{KEYRING_USER}.{suffix}"))?; | ||
entry.delete_password() | ||
} | ||
|
||
pub(crate) fn get(suffix: &str) -> Result<SecretString, keyring::Error> { | ||
let entry = Entry::new(KEYRING_SERVICE, &format!("{KEYRING_USER}.{suffix}"))?; | ||
Ok(SecretString::new(entry.get_password()?)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters