@@ -7,10 +7,6 @@ use fn_error_context::context;
7
7
use ostree_ext:: ostree:: Deployment ;
8
8
use ostree_ext:: sysroot:: SysrootLock ;
9
9
use rustix:: fd:: BorrowedFd ;
10
- use rustix:: fs:: { OFlags , ResolveFlags } ;
11
- use std:: fs:: File ;
12
- use std:: io:: Read ;
13
- use std:: os:: unix:: io:: AsFd ;
14
10
15
11
const BOUND_IMAGE_DIR : & str = "usr/lib/bootc-experimental/bound-images.d" ;
16
12
@@ -37,6 +33,9 @@ fn parse_spec_dir(root: &Dir, spec_dir: &str) -> Result<Vec<BoundImage>> {
37
33
let Some ( bound_images_dir) = root. open_dir_optional ( spec_dir) ? else {
38
34
return Ok ( Default :: default ( ) ) ;
39
35
} ;
36
+ // And open a view of the dir that uses RESOLVE_IN_ROOT so we
37
+ // handle absolute symlinks.
38
+ let absroot = & root. open_dir_rooted_ext ( "." ) ?;
40
39
41
40
let mut bound_images = Vec :: new ( ) ;
42
41
@@ -59,19 +58,7 @@ fn parse_spec_dir(root: &Dir, spec_dir: &str) -> Result<Vec<BoundImage>> {
59
58
60
59
//parse the file contents
61
60
let path = Utf8Path :: new ( spec_dir) . join ( file_name) ;
62
- let mut file: File = rustix:: fs:: openat2 (
63
- root. as_fd ( ) ,
64
- path. as_std_path ( ) ,
65
- OFlags :: CLOEXEC | OFlags :: RDONLY ,
66
- rustix:: fs:: Mode :: empty ( ) ,
67
- ResolveFlags :: IN_ROOT ,
68
- )
69
- . context ( "Unable to openat" ) ?
70
- . into ( ) ;
71
-
72
- let mut file_contents = String :: new ( ) ;
73
- file. read_to_string ( & mut file_contents)
74
- . context ( "Unable to read file contents" ) ?;
61
+ let file_contents = absroot. read_to_string ( & path) ?;
75
62
76
63
let file_ini = tini:: Ini :: from_string ( & file_contents) . context ( "Parse to ini" ) ?;
77
64
let file_extension = Utf8Path :: new ( file_name) . extension ( ) ;
0 commit comments