@@ -13,6 +13,7 @@ use cap_std_ext::cap_std;
13
13
use cap_std_ext:: cap_std:: fs:: Dir ;
14
14
use clap:: Parser ;
15
15
use clap:: ValueEnum ;
16
+ use composefs:: fsverity;
16
17
use fn_error_context:: context;
17
18
use ostree:: gio;
18
19
use ostree_container:: store:: PrepareResult ;
@@ -376,6 +377,21 @@ pub(crate) enum SchemaType {
376
377
Progress ,
377
378
}
378
379
380
+ /// Options for consistency checking
381
+ #[ derive( Debug , clap:: Subcommand , PartialEq , Eq ) ]
382
+ pub ( crate ) enum FsverityOpts {
383
+ /// Measure the fsverity digest of the target file.
384
+ Measure {
385
+ /// Path to file
386
+ path : Utf8PathBuf ,
387
+ } ,
388
+ /// Enable fsverity on the target file.
389
+ Enable {
390
+ /// Ptah to file
391
+ path : Utf8PathBuf ,
392
+ } ,
393
+ }
394
+
379
395
/// Hidden, internal only options
380
396
#[ derive( Debug , clap:: Subcommand , PartialEq , Eq ) ]
381
397
pub ( crate ) enum InternalsOpts {
@@ -392,6 +408,8 @@ pub(crate) enum InternalsOpts {
392
408
#[ clap( long) ]
393
409
of : SchemaType ,
394
410
} ,
411
+ #[ clap( subcommand) ]
412
+ Fsverity ( FsverityOpts ) ,
395
413
/// Perform cleanup actions
396
414
Cleanup ,
397
415
/// Proxy frontend for the `ostree-ext` CLI.
@@ -1113,6 +1131,24 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
1113
1131
)
1114
1132
. await
1115
1133
}
1134
+ // We don't depend on fsverity-utils today, so re-expose some helpful CLI tools.
1135
+ InternalsOpts :: Fsverity ( args) => match args {
1136
+ FsverityOpts :: Measure { path } => {
1137
+ let fd =
1138
+ std:: fs:: File :: open ( & path) . with_context ( || format ! ( "Reading {path}" ) ) ?;
1139
+ let digest =
1140
+ fsverity:: measure_verity_digest :: < _ , fsverity:: Sha256HashValue > ( & fd) ?;
1141
+ let digest = hex:: encode ( digest) ;
1142
+ println ! ( "{digest}" ) ;
1143
+ Ok ( ( ) )
1144
+ }
1145
+ FsverityOpts :: Enable { path } => {
1146
+ let fd =
1147
+ std:: fs:: File :: open ( & path) . with_context ( || format ! ( "Reading {path}" ) ) ?;
1148
+ fsverity:: ioctl:: fs_ioc_enable_verity :: < _ , fsverity:: Sha256HashValue > ( & fd) ?;
1149
+ Ok ( ( ) )
1150
+ }
1151
+ } ,
1116
1152
InternalsOpts :: FixupEtcFstab => crate :: deploy:: fixup_etc_fstab ( & root) ,
1117
1153
InternalsOpts :: PrintJsonSchema { of } => {
1118
1154
let schema = match of {
0 commit comments