Skip to content

Commit bdcc491

Browse files
committed
keylime_agent: Move secure_mount.rs to the library
Signed-off-by: Anderson Toshiyuki Sasaki <[email protected]>
1 parent 430ad64 commit bdcc491

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

keylime-agent/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ mod notifications_handler;
4040
mod payloads;
4141
mod quotes_handler;
4242
mod revocation;
43-
mod secure_mount;
4443

4544
use actix_web::{dev::Service, http, middleware, rt, web, App, HttpServer};
4645
use base64::{engine::general_purpose, Engine as _};
@@ -62,7 +61,7 @@ use keylime::{
6261
list_parser::parse_list,
6362
permissions,
6463
registrar_client::RegistrarClientBuilder,
65-
serialization,
64+
secure_mount, serialization,
6665
tpm::{self, IAKResult, IDevIDResult},
6766
};
6867
use log::*;

keylime/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub mod list_parser;
1818
pub mod permissions;
1919
pub mod quote;
2020
pub mod registrar_client;
21+
pub mod secure_mount;
2122
pub mod serialization;
2223
pub mod structures;
2324
pub mod tpm;

keylime-agent/src/secure_mount.rs renamed to keylime/src/secure_mount.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// Copyright 2021 Keylime Authors
3-
4-
use super::*;
5-
6-
use keylime::error::{Error, Result};
7-
use std::fs;
8-
use std::io::BufRead;
9-
use std::os::unix::fs::PermissionsExt;
10-
use std::path::PathBuf;
11-
use std::process::Command;
3+
use crate::error::{Error, Result};
4+
use log::*;
5+
use std::{
6+
fs,
7+
io::{BufRead, BufReader},
8+
os::unix::fs::PermissionsExt,
9+
path::{Path, PathBuf},
10+
process::Command,
11+
};
1212

1313
pub static MOUNTINFO: &str = "/proc/self/mountinfo";
1414

@@ -27,7 +27,7 @@ pub static MOUNTINFO: &str = "/proc/self/mountinfo";
2727
* - false if not mounted
2828
*
2929
*/
30-
fn check_mount(secure_dir: &Path) -> Result<bool> {
30+
pub fn check_mount(secure_dir: &Path) -> Result<bool> {
3131
let f = fs::File::open(MOUNTINFO)?;
3232
let f = BufReader::new(f);
3333
let lines = f.lines();
@@ -39,7 +39,7 @@ fn check_mount(secure_dir: &Path) -> Result<bool> {
3939
// Skip all fields up to the separator
4040
let mut iter = iter.skip_while(|&x| x != "-");
4141

42-
if let Some(separator) = iter.next() {
42+
if let Some(_separator) = iter.next() {
4343
// The file system type is the first element after the separator
4444
if let Some(fs_type) = iter.next() {
4545
if fs_type == "tmpfs" {
@@ -80,7 +80,7 @@ fn check_mount(secure_dir: &Path) -> Result<bool> {
8080
* implementation as the original python version, but the chown/geteuid
8181
* functions are unsafe function in Rust to use.
8282
*/
83-
pub(crate) fn mount(work_dir: &Path, secure_size: &str) -> Result<PathBuf> {
83+
pub fn mount(work_dir: &Path, secure_size: &str) -> Result<PathBuf> {
8484
// Mount the directory to file system
8585
let secure_dir_path = Path::new(work_dir).join("secure");
8686

@@ -140,6 +140,7 @@ pub(crate) fn mount(work_dir: &Path, secure_size: &str) -> Result<PathBuf> {
140140

141141
Ok(secure_dir_path)
142142
}
143+
143144
#[cfg(test)]
144145
mod tests {
145146
use super::*;
@@ -148,7 +149,7 @@ mod tests {
148149
fn test_secure_mount() {
149150
let temp_workdir = tempfile::tempdir().unwrap(); //#[allow_ci]
150151
let secure_size = "1m";
151-
let test_mount = mount(temp_workdir.path(), secure_size);
152+
let _test_mount = mount(temp_workdir.path(), secure_size);
152153
assert!(check_mount(temp_workdir.path()).is_ok());
153154
}
154155
}

0 commit comments

Comments
 (0)