Skip to content

Commit 7bcb8b1

Browse files
authored
Merge pull request #1266 from allisonkarlitskaya/new-fsverity
various: adapt to new composefs-rs fsverity API
2 parents 0886b20 + 7eadcb6 commit 7bcb8b1

File tree

6 files changed

+55
-21
lines changed

6 files changed

+55
-21
lines changed

Cargo.lock

Lines changed: 45 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deny.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[licenses]
22
allow = ["Apache-2.0", "Apache-2.0 WITH LLVM-exception", "MIT",
33
"BSD-3-Clause", "BSD-2-Clause", "Zlib",
4-
"Unlicense", "CC0-1.0",
4+
"Unlicense", "CC0-1.0", "BSL-1.0",
55
"Unicode-DFS-2016", "Unicode-3.0"]
66
private = { ignore = true }
77

lib/src/cli.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,16 +1197,15 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
11971197
FsverityOpts::Measure { path } => {
11981198
let fd =
11991199
std::fs::File::open(&path).with_context(|| format!("Reading {path}"))?;
1200-
let digest =
1201-
fsverity::measure_verity_digest::<_, fsverity::Sha256HashValue>(&fd)?;
1200+
let digest: fsverity::Sha256HashValue = fsverity::measure_verity(&fd)?;
12021201
let digest = hex::encode(digest);
12031202
println!("{digest}");
12041203
Ok(())
12051204
}
12061205
FsverityOpts::Enable { path } => {
12071206
let fd =
12081207
std::fs::File::open(&path).with_context(|| format!("Reading {path}"))?;
1209-
fsverity::ioctl::fs_ioc_enable_verity::<_, fsverity::Sha256HashValue>(&fd)?;
1208+
fsverity::enable_verity::<fsverity::Sha256HashValue>(&fd)?;
12101209
Ok(())
12111210
}
12121211
},

lib/src/fsck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ fn verity_state_of_objects(
164164
};
165165
let f = d.open(&name)?;
166166
let r: Option<composefs::fsverity::Sha256HashValue> =
167-
composefs::fsverity::ioctl::fs_ioc_measure_verity(f.as_fd())?;
167+
composefs::fsverity::measure_verity_opt(f.as_fd())?;
168168
drop(f);
169169
if r.is_some() {
170170
enabled += 1;

ostree-ext/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ostree = { features = ["v2025_1"], version = "0.20.0" }
2020
anyhow = { workspace = true }
2121
bootc-utils = { path = "../utils" }
2222
camino = { workspace = true, features = ["serde1"] }
23-
composefs = { git = "https://github.com/containers/composefs-rs", rev = "55ae2e9ba72f6afda4887d746e6b98f0a1875ac4" }
23+
composefs = { git = "https://github.com/containers/composefs-rs", rev = "821eeae93e48f1ee381c49b8cd4d22fda92d27a2" }
2424
chrono = { workspace = true }
2525
olpc-cjson = "0.1.1"
2626
clap = { workspace = true, features = ["derive","cargo"] }

ostree-ext/src/fsverity.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ pub fn is_verity_enabled(repo: &ostree::Repo) -> Result<RepoVerityState> {
4646
.with_context(|| format!("Opening repository {CONFIG_PATH}"))?;
4747
// We use the flag of having fsverity set on the repository config as a flag to say that
4848
// fsverity is fully enabled; all objects have it.
49-
let enabled =
50-
composefs_fsverity::measure_verity_digest::<_, composefs_fsverity::Sha256HashValue>(
51-
config.as_fd(),
52-
)
53-
.is_ok();
49+
let enabled = composefs_fsverity::measure_verity::<Sha256HashValue>(config.as_fd()).is_ok();
5450
Ok(RepoVerityState { desired, enabled })
5551
}
5652

@@ -67,10 +63,9 @@ fn enable_fsverity_in_objdir(d: &Dir) -> anyhow::Result<()> {
6763
};
6864
let f = d.open(&name)?;
6965
let enabled =
70-
composefs::fsverity::ioctl::fs_ioc_measure_verity::<_, Sha256HashValue>(f.as_fd())?
71-
.is_some();
66+
composefs::fsverity::measure_verity_opt::<Sha256HashValue>(f.as_fd())?.is_some();
7267
if !enabled {
73-
composefs_fsverity::ioctl::fs_ioc_enable_verity::<_, Sha256HashValue>(&f)?;
68+
composefs_fsverity::enable_verity::<Sha256HashValue>(&f)?;
7469
}
7570
}
7671
Ok(())
@@ -128,11 +123,9 @@ pub async fn ensure_verity(repo: &ostree::Repo) -> Result<()> {
128123
// And finally, enable fsverity as a flag that we have successfully
129124
// enabled fsverity on all objects.
130125
let f = repodir.open(CONFIG_PATH)?;
131-
match composefs_fsverity::ioctl::fs_ioc_enable_verity::<_, composefs_fsverity::Sha256HashValue>(
132-
f.as_fd(),
133-
) {
126+
match composefs_fsverity::enable_verity::<Sha256HashValue>(f.as_fd()) {
134127
Ok(()) => Ok(()),
135-
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => Ok(()),
128+
Err(composefs_fsverity::EnableVerityError::AlreadyEnabled) => Ok(()),
136129
Err(e) => Err(e.into()),
137130
}
138131
}

0 commit comments

Comments
 (0)