Skip to content

Conversation

@ueno
Copy link
Contributor

@ueno ueno commented Dec 11, 2025

It is a common use-case to monitor cryptographic usage on the system
at real time. This adds a dedicated CLI tool, crau-monitor, by
combining the functionalities of event-broker and client. Unlike
those, crau-monitor doesn't require any system service but directly
reads the log file.

Copy link
Collaborator

@t184256 t184256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline: less of a review, more of a mixture of high-level questions with learning Rust questions.

use std::time::Duration;
use toml::{Table, Value};

const CONFIG: &str = "/etc/crypto-auditing/monitor.conf";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it needs a config, what's would be a compelling reason to use one you're anticipating?

let inotify_stream = inotify.into_event_stream(buffer)?;
let watch_descriptor = inotify_stream
.watches()
.add(&log_file, WatchMask::MODIFY | WatchMask::CREATE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the circumstances for getting a CREATE on a file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe when someone removes the log file and then re-creates it?

})
}

fn disable_monitor(&mut self) -> Result<()> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More of a Rust question: should this kind of irreversible deinitialization go to drop()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, rewritten as Drop.

reader.read(&event_tx, &mut shutdown_rx2),
publisher.publish(&mut event_rx, &mut shutdown_rx3),
)
.map(|_| ())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't that swallow errors returned from the futures?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's std::result::Result#map, which maps the Ok variant.

@ueno ueno force-pushed the wip/tools branch 2 times, most recently from e0a2750 to dff8e6a Compare December 12, 2025 09:08
ueno added 2 commits December 12, 2025 18:09
It is a common use-case to monitor cryptographic usage on the system
at real time. This adds a dedicated CLI tool, crau-monitor, by
combining the functionalities of event-broker and client. Unlike
those, crau-monitor doesn't require any system service but directly
reads the log file.

Signed-off-by: Daiki Ueno <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants