Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "home-watcher"
version = "0.1.1"
version = "0.2.1"
edition = "2021"

[profile.release]
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Note: Common user directories like `Documents`, `Downloads`, `Pictures`, `Videos

## Installation

1. **Build from Source**
1. **Build from source**
Clone the repository and compile the Rust project:
```bash
git clone https://github.com/QazCetelic/home-watcher.git
Expand All @@ -34,11 +34,18 @@ Note: Common user directories like `Documents`, `Downloads`, `Pictures`, `Videos
```
The compiled binary will be available in the `target/release` directory.

2. **Install the Binary**
2. **Install the binary**
Move the binary to a directory in your `PATH`, such as `/usr/local/bin`:
```bash
sudo mv target/release/home-watcher /usr/local/bin/
```

3. **Install the systemd service**
Make sure to change <USER> in home-watcher.service
```bash
sudo cp ./home-watcher.service /etc/systemd/system/home-watcher.service
sudo systemctl enable home-watcher.service --now
```

## Database
The database contains an `files` table with the following data:
Expand Down
11 changes: 11 additions & 0 deletions home-watcher.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Log creation of non-standard home directory files
After=basic.target

[Service]
Restart=on-failure
Type=simple
ExecStart=/usr/local/bin/home-watcher --user <USER> --excluded-dirs .var

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion src/ausearch_parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn parse_csv<I>(mut lines: I) -> Vec<Interaction>
where I: Iterator<Item = String>,
{
let mut interactions: Vec<Interaction> = Vec::new();
let header = lines.next().expect("Output is empty");
let header = if let Some(h) = lines.next() { h } else { return interactions; };
if header != EXPECTED_HEADER {
panic!("Unexpected header")
}
Expand Down
2 changes: 1 addition & 1 deletion src/file_audit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::ausearch_parse::{parse_csv, Interaction};
use crate::time::DateTime;
use std::io::BufRead;
use std::io::{BufRead, Read};
use std::process::{Command, Output, Stdio};

pub const AUDITD_RULE_TAG: &str = "home_watcher_rule";
Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::user_env::UserEnvironment;
use crate::util::{create_db_file, get_default_db_path, get_excluded_directories, get_user};
use clap::Parser;
use std::collections::HashSet;
use std::env::set_var;
use std::path::PathBuf;
use std::thread::sleep;
use std::time::Duration;
Expand Down Expand Up @@ -43,6 +44,9 @@ struct Args {
}

fn main() {
// Use IS8601 / RFC3339 date (YYYY-MM-DD) to avoid issues with ausearch
set_var("LC_TIME", "en_DK.UTF-8");

let args = Args::parse();
let mut excluded_executables: HashSet<String> = Default::default();
let excluded_executables_str: String;
Expand Down