mirror of
https://github.com/Kruhlmann/punlock.git
synced 2025-10-28 14:43:35 +00:00
Compare commits
2 Commits
993da22357
...
08e3b6025a
| Author | SHA1 | Date | |
|---|---|---|---|
| 08e3b6025a | |||
| 4ce91d617f |
@@ -5,8 +5,8 @@ use tokio::process::Command;
|
|||||||
use crate::{config::PunlockConfigurationEntry, email::Email};
|
use crate::{config::PunlockConfigurationEntry, email::Email};
|
||||||
|
|
||||||
pub struct Bitwarden<S> {
|
pub struct Bitwarden<S> {
|
||||||
email: Email,
|
pub email: Email,
|
||||||
session: S,
|
pub session: S,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bitwarden<()> {
|
impl Bitwarden<()> {
|
||||||
@@ -104,7 +104,10 @@ impl Bitwarden<String> {
|
|||||||
|
|
||||||
let secret = match result.as_string() {
|
let secret = match result.as_string() {
|
||||||
Some(s) => s.to_owned(),
|
Some(s) => s.to_owned(),
|
||||||
None => anyhow::bail!("invalid item"),
|
None => {
|
||||||
|
tracing::error!(?data, ?expr, "find secret");
|
||||||
|
anyhow::bail!("invalid item")
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(secret)
|
Ok(secret)
|
||||||
|
|||||||
16
src/store.rs
16
src/store.rs
@@ -1,6 +1,11 @@
|
|||||||
use std::{os::unix::fs::PermissionsExt, path::PathBuf, sync::Arc};
|
use std::{
|
||||||
|
os::unix::fs::PermissionsExt,
|
||||||
|
path::PathBuf,
|
||||||
|
process::{Command, Stdio},
|
||||||
|
sync::Arc,
|
||||||
|
};
|
||||||
|
|
||||||
use futures::{StreamExt, stream::FuturesUnordered};
|
use futures::{stream::FuturesUnordered, StreamExt, TryFutureExt};
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -52,6 +57,12 @@ impl UnixSecretStore {
|
|||||||
|
|
||||||
pub async fn write_secrets(&self, entries: &[PunlockConfigurationEntry]) -> anyhow::Result<()> {
|
pub async fn write_secrets(&self, entries: &[PunlockConfigurationEntry]) -> anyhow::Result<()> {
|
||||||
let mut tasks = FuturesUnordered::new();
|
let mut tasks = FuturesUnordered::new();
|
||||||
|
Command::new("bw")
|
||||||
|
.args(["sync", "--session", &self.bitwarden.session])
|
||||||
|
.stdout(Stdio::piped())
|
||||||
|
.stderr(Stdio::piped())
|
||||||
|
.spawn()
|
||||||
|
.inspect_err(|error| tracing::error!(?error, "spawn get"))?;
|
||||||
|
|
||||||
for entry in entries.iter() {
|
for entry in entries.iter() {
|
||||||
let root = self.root_path.clone();
|
let root = self.root_path.clone();
|
||||||
@@ -116,6 +127,7 @@ impl UnixSecretStore {
|
|||||||
std::os::windows::fs::symlink_file(&src, &dst)?;
|
std::os::windows::fs::symlink_file(&src, &dst)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
.inspect_err(|error| tracing::error!(src = ?path, dst = ?link_path, ?error, "symlink failed"))
|
||||||
.await
|
.await
|
||||||
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))??;
|
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))??;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user