diff --git a/bffhd/audit.rs b/bffhd/audit.rs index 2fee201..d58884e 100644 --- a/bffhd/audit.rs +++ b/bffhd/audit.rs @@ -6,8 +6,6 @@ use std::sync::Mutex; use crate::Config; use serde::{Serialize, Deserialize}; use serde_json::Serializer; -use time::OffsetDateTime; -use crate::db::machine::{MachineIdentifier, MachineState}; #[derive(Debug)] pub struct AuditLog { @@ -17,8 +15,8 @@ pub struct AuditLog { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct AuditLogLine { timestamp: i64, - machine: MachineIdentifier, - state: MachineState, + machine: String, + state: String, } impl AuditLog { @@ -28,9 +26,9 @@ impl AuditLog { Ok(Self { writer }) } - pub fn log(&self, machine: &MachineIdentifier, state: &MachineState) -> io::Result<()> { - let timestamp = OffsetDateTime::now_utc().unix_timestamp(); - let line = AuditLogLine { timestamp, machine: machine.clone(), state: state.clone() }; + pub fn log(&self, machine: &str, state: &str) -> io::Result<()> { + let timestamp = chrono::Utc::now().timestamp(); + let line = AuditLogLine { timestamp, machine: machine.to_string(), state: state.to_string() }; let mut guard = self.writer.lock().unwrap(); let mut writer: &mut LineWriter = &mut *guard; diff --git a/bffhd/config.rs b/bffhd/config.rs index b711057..bc78fa4 100644 --- a/bffhd/config.rs +++ b/bffhd/config.rs @@ -42,6 +42,7 @@ pub struct Config { pub init_connections: Vec<(String, String)>, pub db_path: PathBuf, + pub auditlog_path: PathBuf, pub roles: HashMap, @@ -166,6 +167,7 @@ impl Default for Config { ], db_path: PathBuf::from("/run/bffh/database"), + auditlog_path: PathBuf::from("/var/log/bffh/audit.log"), roles: HashMap::new(), tlsconfig: TlsListen {